Have I failed to spot a simple command that finds the most intense pixel(s) and reports its location ?
Process/Find maxima provides a list of all the maxima which probably but not necessarily includes the pixel(s) with the peak intensity- and the results could be searched for the brightest. Perhaps the Histogram command could be extended to produce a pair of arrays that hold the coordinates - it already provides the intensity of the most intense pixel(s). I appreciate that it is easy to create a macro to find the most intense pixel and its location but, I suspect that an easily applicable command would be of general use. Jeremy -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Jeremy,
***** macro code ****** noise=20; run("Find Maxima...", "noise=" + noise + " output=[Point Selection]"); run("Set Measurements...", "mean min centroid redirect=None decimal=6"); run("Measure"); ********************** Increase the noise value until you get only the brightest spot. Regards, Peter On 14.03.2016 11:56, Jeremy Adler wrote: > Have I failed to spot a simple command that finds the most intense pixel(s) and reports its location ? > > Process/Find maxima provides a list of all the maxima which probably but not necessarily includes the pixel(s) with the peak intensity- and the results could be searched for the brightest. > > Perhaps the Histogram command could be extended to produce a pair of arrays that hold the coordinates - it already provides the intensity of the most intense pixel(s). > > I appreciate that it is easy to create a macro to find the most intense pixel and its location but, I suspect that an easily applicable command would be of general use. > > > > Jeremy > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Jeremy Adler
On Monday 14 Mar 2016 10:56:48 Jeremy Adler wrote:
> Have I failed to spot a simple command that finds the most intense pixel(s) > and reports its location ? > Process/Find maxima provides a list of all the maxima which probably but not > necessarily includes the pixel(s) with the peak intensity- and the results > could be searched for the brightest. > Perhaps the Histogram command could be extended to produce a pair of arrays > that hold the coordinates - it already provides the intensity of the most > intense pixel(s). > I appreciate that it is easy to create a macro to find the most intense > pixel and its location but, I suspect that an easily applicable command > would be of general use. Hi Jeremy, Show the point preview with the Find Maxima, then you transfer the point set to the ROI manager, and press "Measure". That should show a table with the coordinates of points. Something like: run("Find Maxima...", "noise=10 output=[Point Selection]"); roiManager("Add"); roiManager("Measure"); Maybe you have to play with the "noise" parameter of the Find Maxima. Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Jeremy Adler
Jeremy,
you've received a more or less interactive solution from Gabriel and Peter. Searching the absolute maximum requires extensive search, a priori knowledge, or one has to accept an approximate solution. For the exact solution and big images, a macro may be too slow. Consequently, this task should be handle by a plugin. Good luck Herbie :::::::::::::::::::::::::::::::::::::::::: Am 14.03.16 um 11:56 schrieb Jeremy Adler: > Have I failed to spot a simple command that finds the most intense > pixel(s) and reports its location ? > > Process/Find maxima provides a list of all the maxima which probably > but not necessarily includes the pixel(s) with the peak intensity- > and the results could be searched for the brightest. > > Perhaps the Histogram command could be extended to produce a pair of > arrays that hold the coordinates - it already provides the intensity > of the most intense pixel(s). > > I appreciate that it is easy to create a macro to find the most > intense pixel and its location but, I suspect that an easily > applicable command would be of general use. > > Jeremy > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Jeremy Adler
Hi Jeremy,
this little macro should go in the right direction: getMinAndMax(min,max); setThreshold(max, max); run("Convert to Mask"); run("Create Selection"); roiManager("Add"); Best, Christian On 14.03.2016 11:56, Jeremy Adler wrote: > Have I failed to spot a simple command that finds the most intense pixel(s) and reports its location ? > > Process/Find maxima provides a list of all the maxima which probably but not necessarily includes the pixel(s) with the peak intensity- and the results could be searched for the brightest. > > Perhaps the Histogram command could be extended to produce a pair of arrays that hold the coordinates - it already provides the intensity of the most intense pixel(s). > > I appreciate that it is easy to create a macro to find the most intense pixel and its location but, I suspect that an easily applicable command would be of general use. > > > > Jeremy > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- Christian Liebig, PhD Light Microscopy Facility Max-Planck-Institute for Developmental Biology Spemannstrasse 35 D-72076 Tuebingen Germany Phone: +49 7071 601 443 e-mail: [hidden email] -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Gabriel, Christian and Herbie,
Thanks, I appreciate that you can use Find Maxima to obtain the most intense of the maxima (say by checking the coordinates produced with the 'list' option) but the list of maxima does not necessarily include the most intense pixel because a maxima is defined with respect to the surrounding intensities, so a low frequency peak may not register as a local maxima even if it contains the most intense pixel in an image. I could also take the maximum from Histogram or getMinandMax, use it to set a threshold and then find the location of the resulting ROIs but this lacks elegance. I was very surprised that ImageJ does not have a command for finding the location of the brightest pixel - fairly basic operation, and was hoping that Histogram of getMinandMax could be tweaked in an update of ImageJ, since they already return the max & min intensity and presumably could be persuaded to report their coordinate(s) without appreciably increasing the processing time. -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Christian Liebig Sent: den 14 mars 2016 13:16 To: [hidden email] Subject: Re: finding the location of the brightest pixel(s) Hi Jeremy, this little macro should go in the right direction: getMinAndMax(min,max); setThreshold(max, max); run("Convert to Mask"); run("Create Selection"); roiManager("Add"); Best, Christian On 14.03.2016 11:56, Jeremy Adler wrote: > Have I failed to spot a simple command that finds the most intense pixel(s) and reports its location ? > > Process/Find maxima provides a list of all the maxima which probably but not necessarily includes the pixel(s) with the peak intensity- and the results could be searched for the brightest. > > Perhaps the Histogram command could be extended to produce a pair of arrays that hold the coordinates - it already provides the intensity of the most intense pixel(s). > > I appreciate that it is easy to create a macro to find the most intense pixel and its location but, I suspect that an easily applicable command would be of general use. > > > > Jeremy > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- Christian Liebig, PhD Light Microscopy Facility Max-Planck-Institute for Developmental Biology Spemannstrasse 35 D-72076 Tuebingen Germany Phone: +49 7071 601 443 e-mail: [hidden email] -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Jeremy,
'Find Maximum' finds the pixel with the highest value if you set the threshold to a value larger than the difference between the brightest and darkest pixel (e.g. a threshold of 1e50 will work for any image). You can write the coordinates to the Results Table (Output type='List'). If there are several pixels of equal brightness, the one closest to the centroid of these pixels will be used. Michael ________________________________________________________________ On Mar 14, 2016, at 13:34, Jeremy Adler wrote: > Hi Gabriel, Christian and Herbie, > > Thanks, > I appreciate that you can use Find Maxima to obtain the most intense of the maxima (say by checking the coordinates produced with the 'list' option) but the list of maxima does not necessarily include the most intense pixel because a maxima is defined with respect to the surrounding intensities, so a low frequency peak may not register as a local maxima even if it contains the most intense pixel in an image. > > I could also take the maximum from Histogram or getMinandMax, use it to set a threshold and then find the location of the resulting ROIs but this lacks elegance. > > I was very surprised that ImageJ does not have a command for finding the location of the brightest pixel - fairly basic operation, and was hoping that Histogram of getMinandMax could be tweaked in an update of ImageJ, since they already return the max & min intensity and presumably could be persuaded to report their coordinate(s) without appreciably increasing the processing time. > > > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Christian Liebig > Sent: den 14 mars 2016 13:16 > To: [hidden email] > Subject: Re: finding the location of the brightest pixel(s) > > Hi Jeremy, > > this little macro should go in the right direction: > > getMinAndMax(min,max); > setThreshold(max, max); > run("Convert to Mask"); > run("Create Selection"); > roiManager("Add"); > > Best, > Christian > > > On 14.03.2016 11:56, Jeremy Adler wrote: >> Have I failed to spot a simple command that finds the most intense pixel(s) and reports its location ? >> >> Process/Find maxima provides a list of all the maxima which probably but not necessarily includes the pixel(s) with the peak intensity- and the results could be searched for the brightest. >> >> Perhaps the Histogram command could be extended to produce a pair of arrays that hold the coordinates - it already provides the intensity of the most intense pixel(s). >> >> I appreciate that it is easy to create a macro to find the most intense pixel and its location but, I suspect that an easily applicable command would be of general use. >> >> >> >> Jeremy >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > Christian Liebig, PhD > > Light Microscopy Facility > Max-Planck-Institute for Developmental Biology Spemannstrasse 35 > D-72076 Tuebingen > Germany > > Phone: +49 7071 601 443 > e-mail: [hidden email] > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Michael,
This will work, but is still a very clunky and inelegant way of performing what should be a very simple one pass process. - check each pixel and retain the location of the most intense. -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Michael Schmid Sent: den 14 mars 2016 13:41 To: [hidden email] Subject: Re: finding the location of the brightest pixel(s) Hi Jeremy, 'Find Maximum' finds the pixel with the highest value if you set the threshold to a value larger than the difference between the brightest and darkest pixel (e.g. a threshold of 1e50 will work for any image). You can write the coordinates to the Results Table (Output type='List'). If there are several pixels of equal brightness, the one closest to the centroid of these pixels will be used. Michael ________________________________________________________________ On Mar 14, 2016, at 13:34, Jeremy Adler wrote: > Hi Gabriel, Christian and Herbie, > > Thanks, > I appreciate that you can use Find Maxima to obtain the most intense of the maxima (say by checking the coordinates produced with the 'list' option) but the list of maxima does not necessarily include the most intense pixel because a maxima is defined with respect to the surrounding intensities, so a low frequency peak may not register as a local maxima even if it contains the most intense pixel in an image. > > I could also take the maximum from Histogram or getMinandMax, use it to set a threshold and then find the location of the resulting ROIs but this lacks elegance. > > I was very surprised that ImageJ does not have a command for finding the location of the brightest pixel - fairly basic operation, and was hoping that Histogram of getMinandMax could be tweaked in an update of ImageJ, since they already return the max & min intensity and presumably could be persuaded to report their coordinate(s) without appreciably increasing the processing time. > > > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Christian Liebig > Sent: den 14 mars 2016 13:16 > To: [hidden email] > Subject: Re: finding the location of the brightest pixel(s) > > Hi Jeremy, > > this little macro should go in the right direction: > > getMinAndMax(min,max); > setThreshold(max, max); > run("Convert to Mask"); > run("Create Selection"); > roiManager("Add"); > > Best, > Christian > > > On 14.03.2016 11:56, Jeremy Adler wrote: >> Have I failed to spot a simple command that finds the most intense pixel(s) and reports its location ? >> >> Process/Find maxima provides a list of all the maxima which probably but not necessarily includes the pixel(s) with the peak intensity- and the results could be searched for the brightest. >> >> Perhaps the Histogram command could be extended to produce a pair of arrays that hold the coordinates - it already provides the intensity of the most intense pixel(s). >> >> I appreciate that it is easy to create a macro to find the most intense pixel and its location but, I suspect that an easily applicable command would be of general use. >> >> >> >> Jeremy >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > Christian Liebig, PhD > > Light Microscopy Facility > Max-Planck-Institute for Developmental Biology Spemannstrasse 35 > D-72076 Tuebingen > Germany > > Phone: +49 7071 601 443 > e-mail: [hidden email] > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Jeremy,
are we talking about the same 'Find Maxima .." function? The one I am talking about (and I think it is the same all others who thought about your problem are talking about) is - from my point of view - a very fast, accurate and handy function and it can do exactly what I thought you would need: "finds the most intense pixel(s) and reports its location" You can use it interactively or combined it with other commands in a macro e.g. to report the location AND the intensity of the brightest spot. And it necessarily includes the brightest spot even in all type of surroundings. I am very surprised that this ImageJ standard function - which is by far not fairly basic (have a look into the code) - creates so much confusion. Peter On 14.03.2016 13:50, Jeremy Adler wrote: > Hi Michael, > > This will work, but is still a very clunky and inelegant way of performing what should be a very simple one pass process. > > - check each pixel and retain the location of the most intense. > > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Michael Schmid > Sent: den 14 mars 2016 13:41 > To: [hidden email] > Subject: Re: finding the location of the brightest pixel(s) > > Hi Jeremy, > > 'Find Maximum' finds the pixel with the highest value if you set the threshold to a value larger than the difference between the brightest and darkest pixel (e.g. a threshold of 1e50 will work for any image). You can write the coordinates to the Results Table (Output type='List'). > > If there are several pixels of equal brightness, the one closest to the centroid of these pixels will be used. > > Michael > ________________________________________________________________ > On Mar 14, 2016, at 13:34, Jeremy Adler wrote: > >> Hi Gabriel, Christian and Herbie, >> >> Thanks, >> I appreciate that you can use Find Maxima to obtain the most intense of the maxima (say by checking the coordinates produced with the 'list' option) but the list of maxima does not necessarily include the most intense pixel because a maxima is defined with respect to the surrounding intensities, so a low frequency peak may not register as a local maxima even if it contains the most intense pixel in an image. >> >> I could also take the maximum from Histogram or getMinandMax, use it to set a threshold and then find the location of the resulting ROIs but this lacks elegance. >> >> I was very surprised that ImageJ does not have a command for finding the location of the brightest pixel - fairly basic operation, and was hoping that Histogram of getMinandMax could be tweaked in an update of ImageJ, since they already return the max & min intensity and presumably could be persuaded to report their coordinate(s) without appreciably increasing the processing time. >> >> >> -----Original Message----- >> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Christian Liebig >> Sent: den 14 mars 2016 13:16 >> To: [hidden email] >> Subject: Re: finding the location of the brightest pixel(s) >> >> Hi Jeremy, >> >> this little macro should go in the right direction: >> >> getMinAndMax(min,max); >> setThreshold(max, max); >> run("Convert to Mask"); >> run("Create Selection"); >> roiManager("Add"); >> >> Best, >> Christian >> >> >> On 14.03.2016 11:56, Jeremy Adler wrote: >>> Have I failed to spot a simple command that finds the most intense pixel(s) and reports its location ? >>> >>> Process/Find maxima provides a list of all the maxima which probably but not necessarily includes the pixel(s) with the peak intensity- and the results could be searched for the brightest. >>> >>> Perhaps the Histogram command could be extended to produce a pair of arrays that hold the coordinates - it already provides the intensity of the most intense pixel(s). >>> >>> I appreciate that it is easy to create a macro to find the most intense pixel and its location but, I suspect that an easily applicable command would be of general use. >>> >>> >>> >>> Jeremy >>> >>> -- >>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >> -- >> Christian Liebig, PhD >> >> Light Microscopy Facility >> Max-Planck-Institute for Developmental Biology Spemannstrasse 35 >> D-72076 Tuebingen >> Germany >> >> Phone: +49 7071 601 443 >> e-mail: [hidden email] >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Peter,
My last reply to Michael clearly accepts that Find Maxima can be made to work - as he suggests by setting the difference required for a maxima almost nothing ( 1e50). Additional calculation are still needed. Some confusion arises because Find Maxima does not as you assert "finds the most intense pixel(s) and reports its location" and the ImageJ documentation does not make this claim. 1) Find Maxima looks for a local maxima, a max relative to the surrounding intensities, I presume employing a comparison with the local average or similar, therefore unless the increment is set to almost nothing a low frequency (smooth) gradient can mean that the most intense pixel in the image may not register as a local maxima. At the very least the list of maxima includes many that are not the maximum - which is fine if this is what you need. Micheal suggests setting the noise level to the absolute minimum - which works but is inelegant - like taking the engine out of a car and then pushing it. As you say Find Maxima is complex. While to find the maximum need not be. 2) The inelegance of using Find Maxima is that it involves considerable unnecessary calculations - the local mean is not relevant to finding a global max and all the local maxima still have to be compared to find the true maximum. While all that is actually needed is to read each pixel once and if the this value is greater than the max already found, then update the max and save the location(s). This I can do with a very simple macro - but as a macro it is slow. 3) The Histogram and the getMinandMax macro command do all that is required to find the location of the most intense pixel(s), except to save the location(s) and I am suggesting that maybe one of them could be tweaked to also return the location- in two arrays holding the X and Y coordinates. A simple Find MaxLocations might be of sufficient utility include in ImageJ. Best wishes Jeremy -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Peter Haub Sent: den 14 mars 2016 15:14 To: [hidden email] Subject: Re: finding the location of the brightest pixel(s) Jeremy, are we talking about the same 'Find Maxima .." function? The one I am talking about (and I think it is the same all others who thought about your problem are talking about) is - from my point of view - a very fast, accurate and handy function and it can do exactly what I thought you would need: "finds the most intense pixel(s) and reports its location" You can use it interactively or combined it with other commands in a macro e.g. to report the location AND the intensity of the brightest spot. And it necessarily includes the brightest spot even in all type of surroundings. I am very surprised that this ImageJ standard function - which is by far not fairly basic (have a look into the code) - creates so much confusion. Peter On 14.03.2016 13:50, Jeremy Adler wrote: > Hi Michael, > > This will work, but is still a very clunky and inelegant way of performing what should be a very simple one pass process. > > - check each pixel and retain the location of the most intense. > > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of > Michael Schmid > Sent: den 14 mars 2016 13:41 > To: [hidden email] > Subject: Re: finding the location of the brightest pixel(s) > > Hi Jeremy, > > 'Find Maximum' finds the pixel with the highest value if you set the threshold to a value larger than the difference between the brightest and darkest pixel (e.g. a threshold of 1e50 will work for any image). You can write the coordinates to the Results Table (Output type='List'). > > If there are several pixels of equal brightness, the one closest to the centroid of these pixels will be used. > > Michael > ________________________________________________________________ > On Mar 14, 2016, at 13:34, Jeremy Adler wrote: > >> Hi Gabriel, Christian and Herbie, >> >> Thanks, >> I appreciate that you can use Find Maxima to obtain the most intense of the maxima (say by checking the coordinates produced with the 'list' option) but the list of maxima does not necessarily include the most intense pixel because a maxima is defined with respect to the surrounding intensities, so a low frequency peak may not register as a local maxima even if it contains the most intense pixel in an image. >> >> I could also take the maximum from Histogram or getMinandMax, use it to set a threshold and then find the location of the resulting ROIs but this lacks elegance. >> >> I was very surprised that ImageJ does not have a command for finding the location of the brightest pixel - fairly basic operation, and was hoping that Histogram of getMinandMax could be tweaked in an update of ImageJ, since they already return the max & min intensity and presumably could be persuaded to report their coordinate(s) without appreciably increasing the processing time. >> >> >> -----Original Message----- >> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of >> Christian Liebig >> Sent: den 14 mars 2016 13:16 >> To: [hidden email] >> Subject: Re: finding the location of the brightest pixel(s) >> >> Hi Jeremy, >> >> this little macro should go in the right direction: >> >> getMinAndMax(min,max); >> setThreshold(max, max); >> run("Convert to Mask"); >> run("Create Selection"); >> roiManager("Add"); >> >> Best, >> Christian >> >> >> On 14.03.2016 11:56, Jeremy Adler wrote: >>> Have I failed to spot a simple command that finds the most intense pixel(s) and reports its location ? >>> >>> Process/Find maxima provides a list of all the maxima which probably but not necessarily includes the pixel(s) with the peak intensity- and the results could be searched for the brightest. >>> >>> Perhaps the Histogram command could be extended to produce a pair of arrays that hold the coordinates - it already provides the intensity of the most intense pixel(s). >>> >>> I appreciate that it is easy to create a macro to find the most intense pixel and its location but, I suspect that an easily applicable command would be of general use. >>> >>> >>> >>> Jeremy >>> >>> -- >>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >> -- >> Christian Liebig, PhD >> >> Light Microscopy Facility >> Max-Planck-Institute for Developmental Biology Spemannstrasse 35 >> D-72076 Tuebingen >> Germany >> >> Phone: +49 7071 601 443 >> e-mail: [hidden email] >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On Monday 14 Mar 2016 15:38:38 Jeremy Adler wrote:
> 3) The Histogram and the getMinandMax macro command do all that is required > to find the location of the most intense pixel(s), except to save the > location(s) and I am suggesting that maybe one of them could be tweaked to > also return the location- in two arrays holding the X and Y coordinates. A > simple Find MaxLocations might be of sufficient utility include in ImageJ. Why restrict the procedure to the maximum? A better option is to create a plugin that scans the image and dumps the coordinates of a specified value to an array or the Results table. That way you can use it to also the specify the coordinates of pixels with minimum, mode, etc. Something like FindLocations(value) and returns two arrays. What I do not know, how to do is returning the arrays to the macro language. Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Gabriel,
good to hear that you are thinking about taking steps... One way to return array values is per file which is clumsy. (Save from PlugIn, pass address to Macro, read by Macro.) Another, perhaps a little less clumsy way is to write from the PlugIn to the results table and read from there by the Macro using "getResults()", "String.copyResults" etc. Best Herbie ::::::::::::::::::::::::::::::::::::::::::::: Am 14.03.16 um 17:43 schrieb Gabriel Landini: > On Monday 14 Mar 2016 15:38:38 Jeremy Adler wrote: >> 3) The Histogram and the getMinandMax macro command do all that is required >> to find the location of the most intense pixel(s), except to save the >> location(s) and I am suggesting that maybe one of them could be tweaked to >> also return the location- in two arrays holding the X and Y coordinates. A >> simple Find MaxLocations might be of sufficient utility include in ImageJ. > > Why restrict the procedure to the maximum? > A better option is to create a plugin that scans the image and dumps the > coordinates of a specified value to an array or the Results table. > > That way you can use it to also the specify the coordinates of pixels with > minimum, mode, etc. > > Something like FindLocations(value) and returns two arrays. > > What I do not know, how to do is returning the arrays to the macro language. > > Cheers > > Gabriel > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Gabriel Landini
Dear Jeremy,
This macro code might do the trick i = 0; // find the brightest pixel intensity getDimensions(width, height, channels, slices, frames); for (x=0; x<width; x++){ for (y=0; y<height; y++){ i2 = getPixel(x, y); if (i<i2){ i = i2; } } } // check if there is more than 1 pixel with the maximum brightness for (x=0; x<width; x++){ for (y=0; y<height; y++){ i2 = getPixel(x, y); if (i==i2){ setKeyDown("shift"); makePoint(x, y); print(i, x, y); } } } Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility Centre for Core Biotechnology Services University of Leicester http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Gabriel Landini Sent: 14 March 2016 16:44 To: [hidden email] Subject: Re: finding the location of the brightest pixel(s) On Monday 14 Mar 2016 15:38:38 Jeremy Adler wrote: > 3) The Histogram and the getMinandMax macro command do all that is > required to find the location of the most intense pixel(s), except to > save the > location(s) and I am suggesting that maybe one of them could be > tweaked to also return the location- in two arrays holding the X and > Y coordinates. A simple Find MaxLocations might be of sufficient utility include in ImageJ. Why restrict the procedure to the maximum? A better option is to create a plugin that scans the image and dumps the coordinates of a specified value to an array or the Results table. That way you can use it to also the specify the coordinates of pixels with minimum, mode, etc. Something like FindLocations(value) and returns two arrays. What I do not know, how to do is returning the arrays to the macro language. Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Jeremy Adler
Hi Jeremy,
please find some comments below. Hi Gabriel and Herbie, another way to deliver results - especially in a 2D array - would be to create an image with the result values (a hint coming from Built-in Macro Functions documentation: newArray ). The only alternative would be to add an additional build-in macro function, which can handle arrays in function parameter list. Regards, Peter On 14.03.2016 16:38, Jeremy Adler wrote: > Peter, > > My last reply to Michael clearly accepts that Find Maxima can be made to work - as he suggests by setting the difference required for a maxima almost nothing ( 1e50). Additional calculation are still needed. > Some confusion arises because Find Maxima does not as you assert "finds the most intense pixel(s) and reports its location" and the ImageJ documentation does not make this claim. Sure it does. If you use the correct settings. Yes, you are right, the IJ documentation is not always perfect like most of the documentations in the OS world but better then the average. > 1) Find Maxima looks for a local maxima, a max relative to the surrounding intensities, I presume employing a comparison with the local average or similar, therefore unless the increment is set to almost nothing a low frequency (smooth) gradient can mean that the most intense pixel in the image may not register as a local maxima. Take a dark image. Mark one pixel white. Smoothed it with a Gauss filter (filter width e.g. 50). Assuming this is an image with a smooth gradient, the noise tolerance can be set to an arbitrary value to find the maximum. => Find Maxima always find an existing single maximum, independent from the surrounding is! > At the very least the list of maxima includes many that are not the maximum - which is fine if this is what you need. A global maximum can be found by using a high noise tolerance. A high noise tolerance decreases the local characteristics, logically. This is an elegant way to get what you need. > Micheal suggests setting the noise level to the absolute minimum - which works but is inelegant - like taking the engine out of a car and then pushing it. If you need a car for 1 person once and you only have a car for 4 person do you really build a new car instead of using the one which is available? > As you say Find Maxima is complex. While to find the maximum need not be. > > 2) The inelegance of using Find Maxima is that it involves considerable unnecessary calculations - the local mean is not relevant to finding a global max and all the local maxima still have to be compared to find the true maximum. While all that is actually needed is to read each pixel once and if the this value is greater than the max already found, then update the max and save the location(s). This I can do with a very simple macro - but as a macro it is slow. > 3) The Histogram and the getMinandMax macro command do all that is required to find the location of the most intense pixel(s), except to save the location(s) and I am suggesting that maybe one of them could be tweaked to also return the location- in two arrays holding the X and Y coordinates. A simple Find MaxLocations might be of sufficient utility include in ImageJ. All N locations with the same (maximum) intensity can NOT be found with Find Maxima without additional effort. Find Maxima only delivers 1 pixel position per intensity islet. Therefor you are right. A plugin for this task would be fine and could be easily created ... but - as we currently see - dealing with macro functions add some additional aspects. Finding the N most intense pixels with different intensities is quite more computational expensive. But if the macro aspects are answered (delivering result arrays in a customized plugin) a solution for this task could be developed as well. > Best wishes > > Jeremy > > > > > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Peter Haub > Sent: den 14 mars 2016 15:14 > To:[hidden email] > Subject: Re: finding the location of the brightest pixel(s) > > Jeremy, > > are we talking about the same 'Find Maxima .." function? > > The one I am talking about (and I think it is the same all others who thought about your problem are talking about) is - from my point of view > - a very fast, accurate and handy function and it can do exactly what I thought you would need: > > "finds the most intense pixel(s) and reports its location" > > You can use it interactively or combined it with other commands in a macro e.g. to report the location AND the intensity of the brightest spot. And it necessarily includes the brightest spot even in all type of surroundings. > I am very surprised that this ImageJ standard function - which is by far not fairly basic (have a look into the code) - creates so much confusion. > > Peter > > > On 14.03.2016 13:50, Jeremy Adler wrote: >> Hi Michael, >> >> This will work, but is still a very clunky and inelegant way of performing what should be a very simple one pass process. >> >> - check each pixel and retain the location of the most intense. >> >> -----Original Message----- >> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of >> Michael Schmid >> Sent: den 14 mars 2016 13:41 >> To:[hidden email] >> Subject: Re: finding the location of the brightest pixel(s) >> >> Hi Jeremy, >> >> 'Find Maximum' finds the pixel with the highest value if you set the threshold to a value larger than the difference between the brightest and darkest pixel (e.g. a threshold of 1e50 will work for any image). You can write the coordinates to the Results Table (Output type='List'). >> >> If there are several pixels of equal brightness, the one closest to the centroid of these pixels will be used. >> >> Michael >> ________________________________________________________________ >> On Mar 14, 2016, at 13:34, Jeremy Adler wrote: >> >>> Hi Gabriel, Christian and Herbie, >>> >>> Thanks, >>> I appreciate that you can use Find Maxima to obtain the most intense of the maxima (say by checking the coordinates produced with the 'list' option) but the list of maxima does not necessarily include the most intense pixel because a maxima is defined with respect to the surrounding intensities, so a low frequency peak may not register as a local maxima even if it contains the most intense pixel in an image. >>> >>> I could also take the maximum from Histogram or getMinandMax, use it to set a threshold and then find the location of the resulting ROIs but this lacks elegance. >>> >>> I was very surprised that ImageJ does not have a command for finding the location of the brightest pixel - fairly basic operation, and was hoping that Histogram of getMinandMax could be tweaked in an update of ImageJ, since they already return the max & min intensity and presumably could be persuaded to report their coordinate(s) without appreciably increasing the processing time. >>> >>> >>> -----Original Message----- >>> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of >>> Christian Liebig >>> Sent: den 14 mars 2016 13:16 >>> To:[hidden email] >>> Subject: Re: finding the location of the brightest pixel(s) >>> >>> Hi Jeremy, >>> >>> this little macro should go in the right direction: >>> >>> getMinAndMax(min,max); >>> setThreshold(max, max); >>> run("Convert to Mask"); >>> run("Create Selection"); >>> roiManager("Add"); >>> >>> Best, >>> Christian >>> >>> >>> On 14.03.2016 11:56, Jeremy Adler wrote: >>>> Have I failed to spot a simple command that finds the most intense pixel(s) and reports its location ? >>>> >>>> Process/Find maxima provides a list of all the maxima which probably but not necessarily includes the pixel(s) with the peak intensity- and the results could be searched for the brightest. >>>> >>>> Perhaps the Histogram command could be extended to produce a pair of arrays that hold the coordinates - it already provides the intensity of the most intense pixel(s). >>>> >>>> I appreciate that it is easy to create a macro to find the most intense pixel and its location but, I suspect that an easily applicable command would be of general use. >>>> >>>> >>>> >>>> Jeremy >>>> >>>> -- >>>> ImageJ mailing list:http://imagej.nih.gov/ij/list.html >>> -- >>> Christian Liebig, PhD >>> >>> Light Microscopy Facility >>> Max-Planck-Institute for Developmental Biology Spemannstrasse 35 >>> D-72076 Tuebingen >>> Germany >>> >>> Phone: +49 7071 601 443 >>> e-mail:[hidden email] >>> >>> -- >>> ImageJ mailing list:http://imagej.nih.gov/ij/list.html >>> >>> -- >>> ImageJ mailing list:http://imagej.nih.gov/ij/list.html >> -- >> ImageJ mailing list:http://imagej.nih.gov/ij/list.html >> >> -- >> ImageJ mailing list:http://imagej.nih.gov/ij/list.html > -- > ImageJ mailing list:http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list:http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |