www.gusucode.com > images 案例代码 matlab源码程序 > images/CreateFilterAndApplyItExample.m

    %% Create Filter and Apply It
% 
%%
% Read a color image into the workspace and display it.
originalRGB = imread('peppers.png');
imshow(originalRGB)
%%
% Create a motion-blur filter using the |fspecial| function.
h = fspecial('motion', 50, 45);
%%
% Apply the filter to the original image to create an image with motion
% blur. Note that |imfilter| is more memory efficient than some other
% filtering functions in that it outputs an array of the same data type as
% the input image array. In this example, the output is an array of
% |uint8|.
filteredRGB = imfilter(originalRGB, h);
figure, imshow(filteredRGB)
%%
% Filter the image again, this time specifying the replicate boundary
% option.
boundaryReplicateRGB = imfilter(originalRGB, h, 'replicate');
figure, imshow(boundaryReplicateRGB)