This routine draws a line, gets the profile and returns the pixel values. How do I get the pixel coordinates of the minimum value?
//setTool("line"); makeLine(746, 344, 534, 582); run("Clear Results"); profile = getProfile(); for (i=0; i<profile.length; i++) setResult("Value", i, profile[i]); updateResults;
Tom Lowe
Chemical Technician Eastman Kodak |
use
getPixel(x,y) this returns the intensity at the designated location - you have the start and end positions of the line, so write a loop that incrementally steps along the line, compares this intensity with the lowest found so far and if the new intensity is lower saves the x,y values. -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of TLowe Sent: den 27 augusti 2014 02:44 To: [hidden email] Subject: How do I get the pixel coordinates of the minimum value? This routine draws a line, gets the profile and returns the pixel values. How do I get the pixel coordinates of the minimum value? //setTool("line"); makeLine(746, 344, 534, 582); run("Clear Results"); profile = getProfile(); for (i=0; i<profile.length; i++) setResult("Value", i, profile[i]); updateResults; ----- Tom Lowe Chemical Technician Eastman Kodak -- View this message in context: http://imagej.1557.x6.nabble.com/How-do-I-get-the-pixel-coordinates-of-the-minimum-value-tp5009363.html Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Like I said, I'm new to ImageJ, if I do the following, I just get an error. How do I use getPixel(x,y) to get at the address with the lowest pixel value?
//setTool("line"); makeLine(746, 344, 534, 582); run("Clear Results"); profile = getProfile(); for (i=0; i<profile.length; i++) setResult("Value", i, profile[i]); getPixel(x,y); updateResults;
Tom Lowe
Chemical Technician Eastman Kodak |
In reply to this post by TLowe
On Aug 26, 2014, at 8:43 PM, TLowe wrote:
> This routine draws a line, gets the profile and returns the pixel values. How > do I get the pixel coordinates of the minimum value? The macro below demonstrates how to get the pixel coordinates of the minimum value along a line selection. It opens the "Cell Colony" sample image, creates a line selection, uses Edit>Selection>Interpolate to resample the line at 1 pixel intervals, gets the coordinates of the points along the line, finds the coordinates of the point with the smallest value, uses Image>Zoom>To Selection to zoom in on the line, adds the line (in red) to an overlay, adds the point found (in yellow) to the overlay, and prints the coordinates and value to the "Log" window. The image at http://wsr.imagej.net/images/MinValueAlongLine.png shows what the output of the macro looks like. The 'adjust' option of the "Interpolate" command ("Adjust interval to match") adjusts the sampling interval so that it divides evenly into the length of the line and the end of the last interval is an the end of the original line. This feature, added in ImageJ 1.49e, was contributed by Norbert Vischer. The yellow min value point will not be exactly on the red line unless you upgrade to the latest ImageJ daily build (1.49h6), which fixes a bug that caused the makePoint() macro function to not work correctly with non-integer coordinates. -wayne run("Cell Colony (31K)"); makeLine(36, 142, 89, 98); run("Interpolate", "interval=1 adjust"); getSelectionCoordinates(x, y); min = 99999; minx=0; miny=0; for (i=0; i<x.length; i++) { value = getPixel(x[i],y[i]); if (value<min) { min = value; minx=x[i]; miny=y[i]; } } run("To Selection"); Overlay.addSelection("red"); makePoint(minx, miny); Overlay.addSelection("yellow"); print("x="+minx+", y="+miny," value="+min); > //setTool("line"); > makeLine(746, 344, 534, 582); > run("Clear Results"); > profile = getProfile(); > for (i=0; i<profile.length; i++) > setResult("Value", i, profile[i]); > updateResults; > -- > View this message in context: http://imagej.1557.x6.nabble.com/How-do-I-get-the-pixel-coordinates-of-the-minimum-value-tp5009363.html > Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |