You are here : matlabImage Processingimreconstruct

imreconstruct() - Image Processing

IM = imreconstruct(marker,mask) performs
morphological reconstruction of the image marker under
the image mask. The arguments marker and mask can
be intensity images or binary images with the same size. The returned
image IM is the same as the input image. Elements
of marker must be less than or equal to the corresponding
elements of mask. If values in marker are
greater than corresponding elements in mask, imreconstruct clips
the values to the mask level. Both input images
must be 2-D. The optional connectivity argument (conn)
can be 4 or 8. If not specified, imreconstruct uses
a 4-connected neighborhood.IM = imreconstruct(marker,mask,conn) performs
morphological reconstruction with the specified connectivity. exampleIM = imreconstruct(gpuarrayMarker,gpuarrayMask) performs
morphological reconstruction on a GPU. The input marker image and
mask image must be gpuArrays. This syntax requires the Parallel Computing Toolbox™.Code Generation support:
Yes.MATLAB Function Block support:


IM = imreconstruct(marker,mask) exampleIM = imreconstruct(marker,mask,conn)IM = imreconstruct(gpuarrayMarker,gpuarrayMask) example


Perform Opening-by-Reconstruction to Identify High Intensity ObjectsOpen This Example
Read a grayscale image and display it.I = imread('snowflakes.png');

Adjust the contast of the image to create the mask image and display results.mask = adapthisteq(I);

Create a marker image that identifies high-intensity objects in the image using morphological erosion and display = strel('disk',5);
marker = imerode(mask,se);

Perform morphological opening on the mask image, using the marker image to identify high-intensity objects in the mask.  Display results.obr = imreconstruct(marker,mask);

Use Reconstruction to Segment an ImageOpen This Example
Read a logical image into workspace and display it. This is the mask image.mask = imread('text.png');

Create a marker image that identifies the object in the image you want to extract through segmentation.  For this example, identify the "w" in the word "watershed".marker = false(size(mask));
marker(13,94) = true;
Perform segmentation of the mask image using the marker = imreconstruct(marker,mask);

Use Reconstruction to Segment an Image on a GPURead mask image and create gpuArray.mask = gpuArray(imread('text.png'));
figure, imshow(mask),Create marker image gpuArray.marker = gpuArray.false(size(mask));
marker(13,94) = true;
Perform the segmentation and display the = imreconstruct(marker,mask);
figure, imshow(im)

Output / Return Value


Alternatives / See Also