www.gusucode.com > images 案例代码 matlab源码程序 > images/ApplyFilterToRegionOfInterestInAnImageExample.m
%% Apply Filter to Region of Interest in an Image % This example shows how to use masked filtering to increase the contrast % of a specific region of an image. %% % Read a grayscale image into the workspace. % Copyright 2015 The MathWorks, Inc. I = imread('pout.tif'); figure h_img = imshow(I); %% % Draw an ellipse over the image to specify the region of interest, using % the |imellipse| function. The coordinates used to specify the size of % the ellipse have been predetermined. imellipse returns an |imellipse| % object. e = imellipse(gca,[55 10 120 120]); %% % Create the mask. Use the |createMask| method of the |imellipse| object. mask = createMask(e,h_img); %% % Create the filter using the |fspecial| function. h = fspecial('unsharp'); %% % Apply the filter to the specified region of interest, using |roifilt2| . I2 = roifilt2(h,I,mask); %% % Display the result. figure imshow(I2)