MorphologicalBinarize

MorphologicalBinarize[image,{t1,t2}]

creates a binary image from image by replacing all values above the upper threshold t2 with 1, also including pixels with intensities above the lower threshold t1 that are connected to the foreground.

MorphologicalBinarize[image,t]

uses t as the upper threshold, automatically choosing a suitable value for the lower threshold.

MorphologicalBinarize[image]

chooses the lower and the upper threshold automatically.

Details and Options

  • MorphologicalBinarize effectively performs hysteresis thresholding and is typically used as part of edge-detection methods.
  • MorphologicalBinarize works with 2D as well as 3D images. It converts multichannel and color images into grayscale images, then produces an image in which every pixel has value 0 or 1.
  • The following short forms can be used for the second argument:
  • t{Automatic,t}t1 computed automatically
    {t}{t,Automatic}t2 computed automatically
    {func}{t1,t2}t1=func[t2] with t2 automatic
    {t,func}{t,t2}t2=func[t]
  • The following options can be given:
  • CornerNeighborsTruewhether to include corner neighbors
    Method"Cluster"method to use to specify the upper threshold
  • MorphologicalBinarize[image,{t},Method->method] specifies the method to use to determine the threshold. See the reference page for FindThreshold for full documentation of available methods.

Examples

open allclose all

Basic Examples  (1)

Binarization of an image using double thresholding:

Scope  (6)

Find connected foreground regions between the two specified thresholds:

Use a fixed upper threshold and compute the lower threshold automatically:

Use a fixed lower threshold and compute the upper threshold automatically:

Compute the lower threshold as a function of the automatically computed upper threshold:

Find the upper and lower thresholds automatically:

Binarize a 3D image:

Options  (3)

CornerNeighbors  (2)

Treats all 8 pixels surrounding a given pixel as adjacent:

Treats only the 4 pixels surrounding a given pixel along the coordinate axes as adjacent:

Method  (1)

Compute the upper threshold using Kapur's entropy method:

Applications  (1)

Edge detection typically involves hysteresis thresholding perfomed on the gradient magnitude:

Binarize using hysteresis thresholding:

Properties & Relations  (5)

With color images, the thresholding is performed on intensity values:

With ColorSpace->Automatic multi-channel images, the mean of channel values is used:

If both the upper threshold and a Method option are specified, the method is ignored:

MorphologicalBinarize operates on pixel values considering neighboring pixel values:

Binarize operates on a pixel value regardless of neighboring pixels:

MorphologicalBinarize[image,{t1,t2}] is effectively the geodesic dilation of two binary images:

The marker image is binarized using t2 and the mask image is binarized using t1:

Introduced in 2010
 (8.0)
 |
Updated in 2012
 (9.0)