MATLAB Language Image processing Image Filtering


Example

Let's say you have an image rgbImg, e.g., read in using imread.

>> rgbImg = imread('pears.png');
>> figure, imshow(rgbImg), title('Original Image')

enter image description here

Use fspecial to create a 2D filter:

>> h = fspecial('disk', 7);
>> figure, imshow(h, []), title('Filter')

enter image description here

Use imfilter to apply the filter on the image:

>> filteredRgbImg = imfilter(rgbImg, h);
>> figure, imshow(filteredRgbImg), title('Filtered Image')

enter image description here