LH Computer Vision and Imaging - Lab 2
The lab sheet and files can be downloaded here
Introduction 介紹
In this lab exercise, you will look at applying different noise removal filters and investigate the effect on edge detection. 在本實驗練習中,您將了解應用不同的噪聲消除濾波器並研究其對邊緣檢測的影響。
You are asked to write a short (no more than 2 pages) report of your work, answering specific questions, and showing example images. This work is not assessed (it will not count towards your module mark) but you will get formative feedback. 你被要求寫一份簡短的(不超過 2 頁)工作報告,回答具體問題,並展示示例圖片。這項工作不會被評估(它不會計入你的模塊分數)但你會得到形成性的反饋。
STEP 1
Download the zip file and extract the .m script files, .mat saved variable files and the data files (.gif) for Lab 2 from CANVAS and save them in your working directory 從 CANVAS 下載 zip 文件並提取 .m 腳本文件、.mat 保存的變量文件和 Lab 2 的數據文件 (.gif),並將它們保存在您的工作目錄中
In MATLAB type 在 MATLAB 中鍵入
shakey = read_image('','shakey.150.gif');
This will load up the .gif file from the current directory into the variable shakey. 這將從當前目錄加載 .gif 文件到變量 shakey 中
You should also load up some noise and edge filters, type 在 MATLAB 中鍵入
load filters
Using the built-in procedure
conv2
convolve the image with the 3x3 Gaussian filter, and then the 5x5 filter. Can you see any difference between them? Try applying an edge filter to each and thresholding. 使用內置程序conv2
將圖像與 3x3 高斯濾波器和 5x5 濾波器進行卷積。你能看出它們之間有什麼區別嗎?嘗試對每個應用邊緣過濾器和閾值。
TASK 1
Can you describe the effect in comparison with applying the edge filter to the image directly? 你能描述一下與直接對圖像應用邊緣濾鏡相比的效果嗎?
STEP 2
Using the function N(m,s,-3:1:3) you can create a discrete sample from a Gaussian (Normal) density. You need to specify the mean m (keep it at 0, think about why) and the standard deviation s. The last term simply uses the code to create a vector in Matlab. So you can create larger and smaller vectors by altering the step size (the number between the two colons) or the limits of the vector (the starting and ending numbers of the last term). So now try creating a 9x9 Gaussian mask. To do this you will need to use matrix multiplication in the right way. Try some initial exploratory experiments with this, what happens to the image as you increase the size of the mask? What happens as you increase the size of s? Make detailed notes as you proceed about what you did and what you observed. 使用函數 N(m,s,-3:1:3)您可以從高斯(正態)密度創建離散樣本。您需要指定均值 m(保持為 0,想想為什麼)和標準差 s。最後一項只是使用代碼在 Matlab 中創建一個向量。因此,您可以通過改變步長(兩個冒號之間的數字)或向量的限制(最後一項的開始和結束數字)來創建更大或更小的向量。所以現在嘗試創建一個 9x9 高斯蒙版。為此,您需要以正確的方式使用矩陣乘法。嘗試一些初步的探索性實驗,當你增加蒙版的大小時,圖像會發生什麼變化?當你增加 s 的大小時會發生什麼?在你繼續做的和觀察到的事情時做詳細的記錄。
Now apply gradient operators such as the Sobel operators to the blurred images. What happens to the edges in the heavily blurred case? 現在將梯度運算符(例如 Sobel 運算符)應用於模糊圖像。在嚴重模糊的情況下邊緣會發生什麼變化?
TASK 2
- What is the effect of increasing the size of the Gaussian Filter (3x3 versus 5x5 for example)? 增加高斯濾波器的大小有什麼影響(例如 3x3 與 5x5)?
- What is the effect of changing the standard deviation s? Why do you see what you see? 改變標準偏差 s有什麼影響?為什麼你看到你所看到的?
STEP 3
- Now compare the speed of applying two large 1D Gaussian filters in sequence, with applying a single equivalent 2D Gaussian filter that results from their multiplication. To test the CPU time used you can use a function called "tic"-"toc". Can you detect differences in the CPU times as the mask sizes increase? You should check that the results are the same by examining areas of the image matrix in detail. Are there any effects due to small floating point errors? 現在比較依次應用兩個大型 1D 高斯濾波器的速度,以及應用由它們相乘產生的單個等效 2D 高斯濾波器的速度。要測試使用的 CPU 時間,您可以使用名為"tic"-"toc"的函數。隨著掩碼大小的增加,您能否檢測到 CPU 時間的差異?您應該通過詳細檢查圖像矩陣的區域來檢查結果是否相同。小的浮點錯誤是否有任何影響?
STEP 4
- Look at your Lecture notes and produce a 2D Laplacian filter. 查看您的講義並生成 2D 拉普拉斯濾波器。
- Now try applying the Laplacian operator to the Shakey image. You will need to calculate the zero-crossing for edges: you can use I_out = edge(I_in,'zerocross') , where I_in is the image convolved with the Laplacian, and I_out is the calculated edges. Think about the result. Why does it produce a poor result compared to the other operators? 現在嘗試將拉普拉斯算子應用於 Shakey 圖像。您將需要計算邊緣的零交叉:您可以使用 I_out = edge(I_in,'zerocross'),其中 I_in是與拉普拉斯算子卷積的圖像,而 I_out是計算出的邊。想想結果。與其他運算符相比,為什麼它會產生較差的結果?
TASK 3
- I mentioned the Laplacian of the Gaussian in the lecture. How could you combine the idea of the Laplacian operator with the idea of Gaussian smoothing? Try out your ideas. 我在講座中提到了高斯的拉普拉斯算子。如何將拉普拉斯算子的思想與高斯平滑的思想結合起來?嘗試你的想法。