how to get the maximum value in determined range of a line profile by DM script

Viewed 27

By the following DM script, I can get the maximum value of the line profile with whole range

no sure to get the maximum value in the partial range? for example, the whole range is 0 to 20, but I only want the maximum value between X coordinates from 6 to 8; how to reach this?

any suggestions, thanks a lot!

number x0,y0,x,y, halfMax, max, i, val, delta, deltaMin, xmin, xmax

number d0, d1

// find the maximum Y coordinate and half maximum coordinate

image spc:=getFrontImage()

string xUnit = spc.ImageGetDimensionUnitString(0)

spc.getSize(d0,d1)

max=spc.max(x0,y0)

OKDialog("max is " +max +" "+ xUnit)

1 Answers

You simply apply the command to the sub-image of interest only. The result will be the relative position within this subsection. You can you any of the methods to adress a subsection, i.e. the brackets notation or the Slice() commands.

image img := RealImage("Test",4,512)
img = sin(icol/iwidth*5*pi())*icol
img.ShowImage()
number maxV,maxX,maxY
number l = 200
number r = 300
maxV = img[0,l,1,r].max(maxX,maxY)
ClearResults()
maxX += l   // The returned maximum position is relative to the section
Result("Maximum value between channel " + l + " and " + r + " is at channel " + maxX)
Related