Login  Register

Re: finding the location of the brightest pixel(s)

Posted by Peter Haub on Mar 15, 2016; 6:45am
URL: http://imagej.273.s1.nabble.com/finding-the-location-of-the-brightest-pixel-s-tp5015879p5015904.html

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