Programming 3

Image Filtering and Edge Detection

1.denoise.cpp: write a program code to run Gaussian, Mean, and Median filters for one image.  

Gaussian Filter(高斯濾波器):

Mean Filter(均值濾波器):

Median Filter(中值濾波器):

1.將影像讀取為灰階影像並顯示。

2.對影像進行高斯濾波處理,kernel 分別設定為 3x3 , 7x7 , 11x11 並顯示,目的為觀察 kernel 大小對結果的影響。

3.對影像進行均值濾波處理,kernel 分別設定為 3x3 , 7x7 , 11x11 並顯示,目的為觀察 kernel 大小對結果的影響。

4.對影像進行中值濾波處理,kernel 分別設定為 3x3 , 7x7 , 11x11 並顯示,目的為觀察 kernel 大小對結果的影響。

結果分析:

以相同影像去做不同方式的模糊濾波處理得到的結果中,kernel 使用越大會有越模糊的效果,而其中高斯及均值濾波的效果比較接近,而中值濾波在 kernel 為 11x11 時,部分邊緣已經丟失,所以在做中值濾波時,如果需要保留影像內較細的邊緣或細節時,要避免設定過大的 kernel 。

結果分析:

結果分析:

2.edge_detection: write a program code to run Sobel and Laplacian filters.

Sobel Filter : 

Laplacian Filter : 


結果分析:

結果分析:

3.canny_detector: write a program code to run the Canny edge detector by OpenCV.

Canny 邊緣檢測器由 John F. Canny 於 1986 年開發。也被許多人稱為最佳檢測器,Canny 算法旨在滿足三個主要標準:

接著我在使用Canny檢測之前加入了高司濾波器,目的是為了減少雜訊,並且將Canny檢測後的結果反白顯示,及黑線為檢測之邊緣。

結果分析:

ReferenceOpenCV 4 Computer Vision Application Programming Cookbook CH6, by D. M. Escrivá, R. Laganiere, Fourth Edition, Packt Publishing, 2019.[Book URL]  [GitHub

Open Source Computer Vision Canny Edge Detector.Generated on Fri Apr 14 2023 for OpenCV by doxygen 1.8.13.