({{, (RefLink[MaxDetect, paclet:ref/MaxDetect])[image] 
gives a binary image in which white pixels correspond to constant extended maxima in image.}, {, (RefLink[MaxDetect, paclet:ref/MaxDetect])[image,h]
finds extended maxima where the range of values is not greater than h.}, {, (RefLink[MaxDetect, paclet:ref/MaxDetect])[data,…]
applies maxima detection to an array of data.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[MaxDetect, paclet:ref/MaxDetect])[image] finds regional maxima.

An extended maximum is a connected set of pixels with values greater than their surroundings.

(RefLink[MaxDetect, paclet:ref/MaxDetect])[image,h] effectively chops maxima of height h or less and returns all remaining constant regional maxima.

(RefLink[MaxDetect, paclet:ref/MaxDetect])[image] is equivalent to (RefLink[MaxDetect, paclet:ref/MaxDetect])[image,0].

(RefLink[MaxDetect, paclet:ref/MaxDetect]) works with binary, grayscale, and other images.

(RefLink[MaxDetect, paclet:ref/MaxDetect]) works with 3D as well as 2D images, and also with data arrays of any rank.

The following options can be given:

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.

OpenersPrimaryExamplesSection(Spacer1)Examples  (10)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Local maxima of a list:

MaxDetect[{1,2,1,2,3,2}]

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

MaxDetect[,0.2]

Detect maxima of a 3D image:

MaxDetect[]

OpenersExampleSection1(Spacer1)Scope  (1)

Local maxima of a matrix:

MaxDetect[(({{7, 8, 2, 2}, {8, 4, 7, 4}, {7, 1, 3, 3}, {1, 1, 9, 3}}))]//MatrixForm

OpenersExampleSection3(Spacer1)Applications  (6)

Find the stars and stripes in the US flag:

MaxDetect[,.5]

Use (RefLink[MaxDetect, paclet:ref/MaxDetect]) and (RefLink[MinDetect, paclet:ref/MinDetect]) to find salt-and-pepper noise:

removeSP[img_] :=Inpaint[img, ImageAdd[MaxDetect[img],MinDetect[img]]];
removeSP[]

Detect corners in an image:

CornerFilter[,6]//MaxDetect

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

i=;
Inpaint[i,Fold[ImageAdd,MaxDetect[i],MaxDetect[i,#]&/@Range[0,.7,.05]]]

Compute the ultimate erosion of objects in an image:

MaxDetect[DistanceTransform[,Padding->0]]

Detect frequency peaks of a signal:

data=Table[0.7 Sin[0.2 π n + 1.]+Sin[0.3 π n+2.1]+RandomReal[{-1,1}],{n,0,127}];

ListLinePlot[p=PeriodogramArray[data],PlotRange->All]

ListPlot[MaxDetect[p,5]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[MinDetect, paclet:ref/MinDetect])  ▪  (RefLink[FillingTransform, paclet:ref/FillingTransform])  ▪  (RefLink[Max, paclet:ref/Max])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Feature Detection, paclet:guide/FeatureDetection])}, {▪(RefLinkPlain[Mathematical Morphology, paclet:guide/MathematicalMorphology])}, {▪(RefLinkPlain[3D Images, paclet:guide/3DImages])}})}})