gives a binary image in which white pixels correspond to constant extended maxima in image.


finds extended maxima where the range of values is not greater than h.


applies maxima detection to an array of data.

Details and Options

  • MaxDetect[image] finds regional maxima.
  • An extended maximum is a connected set of pixels with values greater than their surroundings.
  • MaxDetect[image,h] effectively chops maxima of height h or less and returns all remaining constant regional maxima.
  • MaxDetect[image] is equivalent to MaxDetect[image,0].
  • MaxDetect works with binary, grayscale, and other images.
  • MaxDetect works with 3D as well as 2D images, and also with data arrays of any rank.
  • The following options can be given:
  • CornerNeighborsTruewhether to include corner neighbors
    PaddingAutomaticpadding method to use
  • By default, for images black padding is used, and for data arrays, the minimum possible number is used so that the maxima at the boundary is always detected regardless of the range of data values.


open allclose all

Basic Examples  (3)

Local maxima of a list:

Find areas in an elevation map that rise above their surroundings by at least 0.2:

Detect maxima of a 3D image:

Scope  (1)

Local maxima of a matrix:

Applications  (6)

Find the stars and stripes in the US flag:

Use MaxDetect and MinDetect to find salt-and-pepper noise:

Detect corners in an image:

Detect bright stars and use them as a mask for inpainting:

Compute the ultimate erosion of objects in an image:

Detect frequency peaks of a signal:

Wolfram Research (2010), MaxDetect, Wolfram Language function, (updated 2014).


Wolfram Research (2010), MaxDetect, Wolfram Language function, (updated 2014).


Wolfram Language. 2010. "MaxDetect." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014.


Wolfram Language. (2010). MaxDetect. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_maxdetect, author="Wolfram Research", title="{MaxDetect}", year="2014", howpublished="\url{}", note=[Accessed: 24-July-2024 ]}


@online{reference.wolfram_2024_maxdetect, organization={Wolfram Research}, title={MaxDetect}, year={2014}, url={}, note=[Accessed: 24-July-2024 ]}