Module: Morph

Morph performs low-level morphological operations on binary or grayscale images

This module performs a series of morphological operations on a binary image or grayscale image, resulting in an image of the same type. Many require some image processing knowledge to understand how best to use these morphological filters in order to achieve the desired result. Note that the algorithms minimize the interference of masked pixels; for instance, the dilate operation will only consider unmasked pixels in the neighborhood of a pixel when determining the maximum within that neighborhood.

The following operations are available:

OperationDescription Input image type allowed
Bothat Bottom-hat filter: A bottom-hat filter enhances black spots in a white background. It subtracts the morphological Close of the image from the image. See below for a description of Close. Binary, grayscale
Branchpoints Removes all pixels except those that are the branchpoints of a skeleton. This operation should be applied to an image after skeletonizing. It leaves only those pixels that are at the intersection of branches.
10000
01000
00100
01010
10001
?0000
00000
00100
00000
?000?
Binary
Bridge Sets a pixel to 1 if it has two non-zero neighbors that are on opposite sides of this pixel:
100
000
001
100
010
001
Binary
Clean Removes isolated pixels:
000
000
000
000
010
000
Binary
Close Performs a dilation followed by an erosion. The effect is to fill holes and join nearby objects. Binary, grayscale
Convex hull Finds the convex hull of a binary image. The convex hull is the smallest convex polygon that fits around all foreground pixels of the image: it is the shape that a rubber band would take if stretched around the foreground pixels. The convex hull can be used to regularize the boundary of a large, single object in an image, for instance, the edge of a well. Binary
Diag Fills in pixels whose neighbors are diagnonally connected to 4-connect pixels that are 8-connected:
01
10
11
11
 , 
01
11
11
11
Binary
Dilate For binary, replaces any 0 pixel by 1 if any of its neighbors is 1. For grayscale, each pixel is replaced by the maximum of its neighbors and itself. Binary, grayscale
Distance Computes the distance transform of a binary image. The distance of each foreground pixel is computed to the nearest background pixel. The resulting image is then scaled so that the largest distance is 1. Binary
Erode For binary, replaces any 1 pixel by 0 if any of its neighbors is 0. For grayscale, each pixel is replaced by the minimum of its neighbors and itself. Binary, grayscale
Endpoints Removes all pixels except the ones that are at the end of a skeleton:
00000
01010
00100
01010
01001
00000
01010
00000
00000
0?00?
Binary
Fill Sets a pixel to 1 if all of its neighbors are 1:
111
101
111
111
111
111
Binary
Fill small holes Sets background pixels surrounded by foreground pixels to 1.
This operation fills in small holes in a binary image. You can set the maximum area of a hole in order to restrict the operation to holes of a given size or smaller.
Binary
Hbreak Removes pixels that form vertical bridges between horizontal lines:
111
010
111
111
000
111
Binary
Invert For a binary image, transforms background to foreground and vice-versa. For a grayscale image, invert its intensity. Binary, Grayscale
Majority Each pixel takes on the value of the majority that surround it (keep pixel value to break ties):
111
101
000
111
111
000
Binary
LifeApplies the interaction rules from the Game of Life, an example of a cellular automaton. Binary
OpenPerforms an erosion followed by a dilation. The effect is to break bridges between objects and remove single pixels. Binary, grayscale
Remove Removes pixels that are otherwise surrounded by others (4 connected). The effect is to leave the perimeter of a solid object:
010
111
010
010
101
010
Binary
Shrink Performs a thinning operation that erodes unless that operation would change the image's Euler number. This means that blobs are reduced to single points and blobs with holes are reduced to rings if shrunken indefinitely. Binary
Skel Performs a skeletonizing operation (medial axis transform). Preserves the points at the edges of objects but erodes everything else to lines that connect those edges. See here for a description. Binary
SkelPE Performs a skeletonizing operation using the metric, PE * D to control the erosion order. PE is the Poisson Equation (see Gorelick, "Shape representation and classification using the Poisson Equation", IEEE Transactions on Pattern Analysis and Machine Intelligence V28, # 12, 2006) evaluated within the foreground with the boundary condition that the background is zero. D is the distance transform (distance of a pixel to the nearest edge). The resulting skeleton has fewer spurs but some bit of erosion at the endpoints in the binary image. Binary
Spur Removes spur pixels, i.e., pixels that have exactly one 8-connected neighbor. This operation essentially removes the endpoints of lines.
0000
0100
0010
1111
0000
0000
0010
1111
Binary
Thicken Dilates the exteriors of objects where that dilation does not 8-connect the object with another. The image is labeled and the labeled objects are filled. Unlabeled points adjacent to uniquely labeled points change from background to foreground. Binary
Thin Thin lines preserving the Euler number using the thinning algorithm # 1 described in Guo, "Parallel Thinning with Two Subiteration Algorithms", Communications of the ACM, Vol 32 #3, page 359. The result generally preserves the lines in an image while eroding their thickness. Binary
Tophat Subtracts the morphological opening of the image from the image. This enhances white spots in a black background. Binary, grayscale
Vbreak Removes pixels that form horizontal bridges between vertical lines:
101
111
101
101
101
101
Binary

Settings:

Select the input image

Select the image that you want to perform a morphological operation on. A grayscale image can be converted to binary using the ApplyThreshold module. Objects can be converted to binary using the ConvertToImage module.

Name the output image

Enter the name for the output image It will be of the same type as the input image.

Select the operation to perform

Choose one of the operations described in this module's help.

Number of times to repeat operation

This setting controls the number of times that the same operation is applied successively to the image.

Repetition number

(Used only if Custom selected)
Enter the number of times to repeat the operation

Scale

Morphological open, close, erode and dialate are performed with structuring elements which determine the diameter of the circle enclosing the pixels to consider when applying the operation. This setting controls the diameter of the structuring element.

Structuring element

(Used only for bothat, close, dilate, erode, open and tophat)
The structuring element controls which neighboring pixels participate in the operation. For instance, for the erode operation, all pixels in the neighborhood of the pixel must be in the foreground for the pixel to be in the foreground in the output image. If a circular structuring element is used, then a pixel will be in the foreground only if all neighborhood pixels within a circle surrounding the pixel are in the foreground in the input image.

The structuring elements are:

X offset

(Used only for the Pair and Periodic line settings). The X offset to the first neighborhood pixel in the structuring element.

Y offset

(Used only for the Pair and Periodic line structuring elements). The Y offset to the first neighborhood pixel in the structuring element.

Angle

(Used only for the Line structuring element). The angle, in degrees counter-clockwise from the horizontal, of the line.

Width

(Used only for the Rectangle structuring element). The width of the rectangle in pixels.

Height

(Used only for the Rectangle structuring element). The height of the rectangle in pixels.

Custom

(Used only for the Custom structuring element). This control lets you specify a custom structuring element.

Rescale values from 0 to 1?

(Used only for the distance operation).

Select Yes to rescale the transformed values to lie between 0 and 1. This is the option to use if the distance transformed image is to be used for thresholding by an Identify module or the like, which assumes a 0-1 scaling.

Select No to leave the values in absolute pixel units. This useful in cases where the actual pixel distances are to be used downstream as input for a measurement module.