This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

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.

I = imread('pout.tif');
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.


Was this topic helpful?