Login  Register

Find a max position

Posted by Tomm on Feb 25, 2015; 1:37pm
URL: http://imagej.273.s1.nabble.com/Find-a-max-position-tp5011762.html

Hello,

I'm trying to find a position and make a rectangle in a maximum mean position in a image.
But i don't know how the position is found and how i handle them.
Here is a portion of macro I wrote to measure "Mean" and "Centroid(X,Y)" in the rectangle.

--
run("Blobs (25K)");//an example
run("Set Measurements...", "mean centroid display redirect=None decimal=3");
imagewidth = getWidth();
imageheight = getHeight();
x_pixel = imagewidth;//size of the image
y_pixel = imageheight;//size of the image

length = 200;//size of rectangle
for (x=0; x < x_pixel-length; x++){
for (y=0; y < y_pixel-length; y++){
makeRectangle(x, y, length, length);
run("Measure");
}}
--

Then, I wanna get X and Y value showing maximum mean. In this case, row# 3012 is the maximum mean. So, X(maximum_mean) = 155; Y(maximum_mean) = 141.
Finally, I gonna add a following code and draw a rectangle.
--
makeRectangle(X(maximum_mean), Y(maximum_mean), length, length);
--

Does anyone know how I have to?
Thanks in advance.

Tom