Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this 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');
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)

Was this topic helpful?