Login  Register

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

Posted by Krs5 on Mar 14, 2016; 5:54pm
URL: http://imagej.273.s1.nabble.com/finding-the-location-of-the-brightest-pixel-s-tp5015879p5015898.html

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