| Image Processing Toolbox™ | ![]() |
Filling is a process that fills a region of interest (ROI) by interpolating the pixel values from the borders of the region. This process can be used to make objects in an image seem to disappear as they are replaced with values that blend in with the background area.
To fill an ROI, you can use the roifill function. This function is useful for image editing, including removal of extraneous details or artifacts.
roifill performs the fill operation using an interpolation method based on Laplace's equation. This method results in the smoothest possible fill, given the values on the boundary of the region.
As with roipoly, you select the region of interest with the mouse. When you complete the selection, roifill returns an image with the selected ROI filled in.
This example shows how to use roifill to fill an ROI in an image.
Read an image into the MATLAB® workspace and display it. Because the image is an indexed image, the example uses ind2gray to convert it to a grayscale image.
load trees I = ind2gray(X,map); imshow(I)
Call roifill to specify
the ROI you want to fill. When you move the pointer over the image,
the pointer shape changes to cross hairs
. Define the ROI by clicking
the mouse to specify the vertices of a polygon. You can use the mouse
to adjust the size and position of the ROI.
I2 = roifill;

Perform the fill operation. Double-click inside the ROI or right-click and select Fill Area. roifill returns the modified image in I2. View the output image to see how roifill filled in the area defined by the ROI.
imshow(I2)

![]() | Filtering an ROI | Image Deblurring | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |