quick way to select the maximum pixel

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

quick way to select the maximum pixel

danibodor
does anyone know if there is a function to find the maximum pixel in an image?

I know that i can get a measurement of the maximum pixel and then run through the image pixel by pixel until i find it, but i was hoping that there is a faster way to do this.

thanks
Reply | Threaded
Open this post in threaded view
|

Re: quick way to select the maximum pixel

Wayne Rasband
 > does anyone know if there is a function to find the maximum
 > pixel in an image?

 > I know that i can get a measurement of the maximum pixel
 > and then run through the image pixel by pixel until i find
 > it, but i was hoping that there is a faster way to do this.

The Process>Binary>Find Maxima command seems to find the image maximum
if you use the maximum pixel value as the "Noise Tolerance". Here is a
macro the uses Find Maxima to display the location and value of the
image maximum.

    getRawStatistics(nPixels, mean, min, max);
    run("Find Maxima...", "noise="+max+" output=[Point Selection]");
    getSelectionBounds(x, y, w, h);
    print("coordinates=("+x+","+y+"), value="+getPixel(x,y));

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: quick way to select the maximum pixel

Jacqueline Ross
Hi All,

I have a related question to the previous email about finding the
maximum grayscale pixels.

We recently discovered a couple of dead pixels in our monochrome camera.
They only show up when people have very very low intensity labelling and
are using long exposure times so normally not a problem.

However, it was suggested to me that to eliminate them from the images,
I could "find" the dead pixels (since they are maximum intensity) and
then fill them with the average grayscale value of the background (I
guess the minimum?).

Can anyone offer me some suggestions on how to do this?

Kind regards,

Jacqui

Jacqueline Ross

Biomedical Imaging Microscopist
Biomedical Imaging Research Unit
School of Medical Sciences
Faculty of Medical & Health Sciences
The University of Auckland
Private Bag 92019
Auckland, NEW ZEALAND

Tel: 64 9 373 7599 Ext 87438
Fax: 64 9 373 7484

http://www.fmhs.auckland.ac.nz/sms/biru/


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Wayne Rasband
Sent: Thursday, 8 October 2009 5:20 a.m.
To: [hidden email]
Subject: Re: quick way to select the maximum pixel

 > does anyone know if there is a function to find the maximum
 > pixel in an image?

 > I know that i can get a measurement of the maximum pixel
 > and then run through the image pixel by pixel until i find
 > it, but i was hoping that there is a faster way to do this.

The Process>Binary>Find Maxima command seems to find the image maximum
if you use the maximum pixel value as the "Noise Tolerance". Here is a
macro the uses Find Maxima to display the location and value of the
image maximum.

    getRawStatistics(nPixels, mean, min, max);
    run("Find Maxima...", "noise="+max+" output=[Point Selection]");
    getSelectionBounds(x, y, w, h);
    print("coordinates=("+x+","+y+"), value="+getPixel(x,y));

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: quick way to select the maximum pixel

Aryeh Weiss
If you know where they are, and they are isolated pixels, you can use a
local median filter to replace the bad pixel with the median of the
surrounding pixels. That should  provide a pretty good estimate.

--aryeh

Jacqui Ross wrote:

> Hi All,
>
> I have a related question to the previous email about finding the
> maximum grayscale pixels.
>
> We recently discovered a couple of dead pixels in our monochrome camera.
> They only show up when people have very very low intensity labelling and
> are using long exposure times so normally not a problem.
>
> However, it was suggested to me that to eliminate them from the images,
> I could "find" the dead pixels (since they are maximum intensity) and
> then fill them with the average grayscale value of the background (I
> guess the minimum?).
>
> Can anyone offer me some suggestions on how to do this?
>
> Kind regards,
>
> Jacqui
>
> Jacqueline Ross
>
> Biomedical Imaging Microscopist
> Biomedical Imaging Research Unit
> School of Medical Sciences
> Faculty of Medical & Health Sciences
> The University of Auckland
> Private Bag 92019
> Auckland, NEW ZEALAND
>
> Tel: 64 9 373 7599 Ext 87438
> Fax: 64 9 373 7484
>
> http://www.fmhs.auckland.ac.nz/sms/biru/
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Wayne Rasband
> Sent: Thursday, 8 October 2009 5:20 a.m.
> To: [hidden email]
> Subject: Re: quick way to select the maximum pixel
>
>  > does anyone know if there is a function to find the maximum
>  > pixel in an image?
>
>  > I know that i can get a measurement of the maximum pixel
>  > and then run through the image pixel by pixel until i find
>  > it, but i was hoping that there is a faster way to do this.
>
> The Process>Binary>Find Maxima command seems to find the image maximum
> if you use the maximum pixel value as the "Noise Tolerance". Here is a
> macro the uses Find Maxima to display the location and value of the
> image maximum.
>
>     getRawStatistics(nPixels, mean, min, max);
>     run("Find Maxima...", "noise="+max+" output=[Point Selection]");
>     getSelectionBounds(x, y, w, h);
>     print("coordinates=("+x+","+y+"), value="+getPixel(x,y));
>
> -wayne
>


--
Aryeh Weiss
School of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384050
Reply | Threaded
Open this post in threaded view
|

Re: quick way to select the maximum pixel

Michael Schmid
In reply to this post by Jacqueline Ross
Hi Jacqueline,

it seems you are talking about hot pixels (pixels that appear as too bright).

You can try Ptocess>noise>Remove Outliers. It is a median filter with a
threshold; i.e., pixels that deviate by more than a given value from the
median of the neighborhood are set to the median.

Michael
__________________________________________________________________


On Wed, October 7, 2009 22:55, Jacqui Ross wrote:

> Hi All,
>
> I have a related question to the previous email about finding the
> maximum grayscale pixels.
>
> We recently discovered a couple of dead pixels in our monochrome camera.
> They only show up when people have very very low intensity labelling and
> are using long exposure times so normally not a problem.
>
> However, it was suggested to me that to eliminate them from the images,
> I could "find" the dead pixels (since they are maximum intensity) and
> then fill them with the average grayscale value of the background (I
> guess the minimum?).
>
> Can anyone offer me some suggestions on how to do this?
>
> Kind regards,
>
> Jacqui
>
> Jacqueline Ross
>
> Biomedical Imaging Microscopist
> Biomedical Imaging Research Unit
> School of Medical Sciences
> Faculty of Medical & Health Sciences
> The University of Auckland
> Private Bag 92019
> Auckland, NEW ZEALAND
>
> Tel: 64 9 373 7599 Ext 87438
> Fax: 64 9 373 7484
>
> http://www.fmhs.auckland.ac.nz/sms/biru/
>
Reply | Threaded
Open this post in threaded view
|

Re: quick way to select the maximum pixel

Gabriel Landini
> We recently discovered a couple of dead pixels in our monochrome camera.
> They only show up when people have very very low intensity labelling and
> are using long exposure times so normally not a problem.
>
> However, it was suggested to me that to eliminate them from the images,
> I could "find" the dead pixels (since they are maximum intensity) and
> then fill them with the average grayscale value of the background (I
> guess the minimum?).
>
> Can anyone offer me some suggestions on how to do this?

Have a look at the macro here. It will convert all the single pixels which
have a value of 255 to the mean of the neighbours (colour or greyscale image).

http://imagejdocu.tudor.lu/doku.php?id=howto:working:how_to_correct_background_illumination_in_brightfield_microscopy

I hope it helps

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: quick way to select the maximum pixel

jmutterer
Alternatively, the following macro median-filters pixels with a given value:

value=0;
w=getWidth; h=getHeight;
for (x=0; x<w;x++) {
  for (y=0; y<h;y++) {
    if (getPixel(x,y)==value) {
      makeRectangle(x,y,1,1);
      run("Median...","radius=1");
    }
  }
}
run("Select None");
// end

jerome.

On Thu, Oct 8, 2009 at 10:28 AM, Gabriel Landini <[hidden email]>wrote:

> > We recently discovered a couple of dead pixels in our monochrome camera.
> > They only show up when people have very very low intensity labelling and
> > are using long exposure times so normally not a problem.
> >
> > However, it was suggested to me that to eliminate them from the images,
> > I could "find" the dead pixels (since they are maximum intensity) and
> > then fill them with the average grayscale value of the background (I
> > guess the minimum?).
> >
> > Can anyone offer me some suggestions on how to do this?
>
> Have a look at the macro here. It will convert all the single pixels which
> have a value of 255 to the mean of the neighbours (colour or greyscale
> image).
>
>
> http://imagejdocu.tudor.lu/doku.php?id=howto:working:how_to_correct_background_illumination_in_brightfield_microscopy
>
> I hope it helps
>
> Gabriel
>
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: quick way to select the maximum pixel

Joachim Wesner
In reply to this post by Gabriel Landini
Hi guys,

however, as I understood the original poster, he

1) knows the coordinates of these few "hot pixels" from earlier
measurements

2) the pixels are "hot" at long exposures times relative to the
surroundings, but not necessarily at shorter exp times and their values
will not always be 255

I would also suggest, as has been done before, to use a median filter only
around those known coordinates

Sinceryl

Joachim Wesner



                                                                           
             Gabriel Landini                                              
             <[hidden email]                                            
             C.UK>                                                      An
             Gesendet von:              [hidden email]                
             ImageJ Interest                                         Kopie
             Group                                                        
             <[hidden email].                                       Thema
             GOV>                       Re: quick way to select the        
                                        maximum pixel                      
                                                                           
             08.10.2009 10:28                                              
                                                                           
                                                                           
              Bitte antworten                                              
                    an                                                    
              ImageJ Interest                                              
                   Group                                                  
             <[hidden email].                                            
                   GOV>                                                    
                                                                           
                                                                           




> We recently discovered a couple of dead pixels in our monochrome camera.
> They only show up when people have very very low intensity labelling and
> are using long exposure times so normally not a problem.
>
> However, it was suggested to me that to eliminate them from the images,
> I could "find" the dead pixels (since they are maximum intensity) and
> then fill them with the average grayscale value of the background (I
> guess the minimum?).
>
> Can anyone offer me some suggestions on how to do this?

Have a look at the macro here. It will convert all the single pixels which
have a value of 255 to the mean of the neighbours (colour or greyscale
image).

http://imagejdocu.tudor.lu/doku.php?id=howto:working:how_to_correct_background_illumination_in_brightfield_microscopy


I hope it helps

Gabriel



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: quick way to select the maximum pixel

Gabriel Landini
On Thursday 08 October 2009  13:35:11 Joachim Wesner wrote:
> however, as I understood the original poster, he
> 1) knows the coordinates of these few "hot pixels" from earlier
> measurements

Yes, the hot pixels will be always in the same place for a particular camera.
One can exploit that too.

> 2) the pixels are "hot" at long exposures times relative to the
> surroundings, but not necessarily at shorter exp times and their values
> will not always be 255

Yes, in which case they would be compensated by image ratio with the empty
background. I am considering brightfield images here...

I guess that one could have a precomputed binary mask with those hot pixels
set at 255 (and 0 elsewhere) and add it to the original. Of course if there is
already an area with white which does not require correction, one can convert
the image to 16bit first so the pixels to correct are those with values >255
after the addition of the mask.

> I would also suggest, as has been done before, to use a median filter only
> around those known coordinatesI would also suggest, as has been done before,
> to use a median filter only around those known coordinates

I now realise that one needs to build a custom median filter (ie, not use the
built-in one). Otherwise the central (biased) pixel would also be included in
the ranking. Since we now have an even number of pixels (4 or 8 neighbours)
the median here is defined as the average of the 2 median values.

Regards

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: quick way to select the maximum pixel

Jacqueline Ross
Dear All,

Thanks very much to all of you who have replied to my question and I
apologise for being slow in providing feedback about whether these
suggestions worked.

I realise that I forgot to mention that the images are in 16bit
grayscale not 8bit. This meant that the macro that Gabriel initially
provided didn't work. I tried converting the image to 8bit but it still
didn't seem to work for some reason? I think that when I did the
conversion for some reason the hot pixel didn't have a 255 grey value.

The built-in median filter did work but resulted in too much blurring of
the rest of the image even when I used a radius of 1.0 pixel.

One other suggestion I have been given by our camera agent is to create
a defect map, i.e. record the hot pixel locations by taking a very long
exposure image with no light on the camera. Then set these pixels to be
equal to the mean value of their neighbours. I guess this is along the
lines that Gabriel & Joachim have  mentioned. However, I wasn't quite
sure how to go about this although I can identify the x & y coordinates
from the images I already have.

The best result so far came with Michael's suggestion to use Process -
Noise - Remove Outliers. Using a radius of 1.0 pixel, threshold 1.0 and
Bright, this worked brilliantly. The hot pixels (there are 2!) were
removed without blurring the rest of the image. This is important
because the labelling is actually quite punctuate.

Thanks everyone for taking the time to think about this and reply! It is
much appreciated.

Kind regards,

Jacqui

Jacqueline Ross

Biomedical Imaging Microscopist
Biomedical Imaging Research Unit
School of Medical Sciences
Faculty of Medical & Health Sciences
The University of Auckland
Private Bag 92019
Auckland, NEW ZEALAND

Tel: 64 9 373 7599 Ext 87438
Fax: 64 9 373 7484

http://www.fmhs.auckland.ac.nz/sms/biru/


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Gabriel Landini
Sent: Friday, 9 October 2009 2:02 a.m.
To: [hidden email]
Subject: Re: Antwort: Re: quick way to select the maximum pixel

On Thursday 08 October 2009  13:35:11 Joachim Wesner wrote:
> however, as I understood the original poster, he
> 1) knows the coordinates of these few "hot pixels" from earlier
> measurements

Yes, the hot pixels will be always in the same place for a particular
camera.
One can exploit that too.

> 2) the pixels are "hot" at long exposures times relative to the
> surroundings, but not necessarily at shorter exp times and their
values
> will not always be 255

Yes, in which case they would be compensated by image ratio with the
empty
background. I am considering brightfield images here...

I guess that one could have a precomputed binary mask with those hot
pixels
set at 255 (and 0 elsewhere) and add it to the original. Of course if
there is
already an area with white which does not require correction, one can
convert
the image to 16bit first so the pixels to correct are those with values
>255
after the addition of the mask.

> I would also suggest, as has been done before, to use a median filter
only
> around those known coordinatesI would also suggest, as has been done
before,
> to use a median filter only around those known coordinates

I now realise that one needs to build a custom median filter (ie, not
use the
built-in one). Otherwise the central (biased) pixel would also be
included in
the ranking. Since we now have an even number of pixels (4 or 8
neighbours)
the median here is defined as the average of the 2 median values.

Regards

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: quick way to select the maximum pixel

Gabriel Landini
On Tuesday 13 October 2009  15:22:42 Jacqui Ross wrote:
> I realise that I forgot to mention that the images are in 16bit
> grayscale not 8bit. This meant that the macro that Gabriel initially
> provided didn't work. I tried converting the image to 8bit but it still
> didn't seem to work for some reason? I think that when I did the
> conversion for some reason the hot pixel didn't have a 255 grey value.

Duplicate the image, threshold it (so dead pixels are 255 and the rest is 0)
and add it back to the original. That would saturate them. Then run the macro.

> One other suggestion I have been given by our camera agent is to create
> a defect map, i.e. record the hot pixel locations by taking a very long
> exposure image with no light on the camera. Then set these pixels to be
> equal to the mean value of their neighbours.  I guess this is along the
> lines that Gabriel & Joachim have  mentioned. However, I wasn't quite
> sure how to go about this although I can identify the x & y coordinates
> from the images I already have.

The macro I sent does it for you, just make sure the pixels are saturated. You
can then modify to 16 bit too.

> The best result so far came with Michael's suggestion to use Process -
> Noise - Remove Outliers. Using a radius of 1.0 pixel, threshold 1.0 and
> Bright, this worked brilliantly. The hot pixels (there are 2!) were
> removed without blurring the rest of the image.

The problem with that is that you are removing without knowing other outlier
pixels as well, not only the hot ones. Just compare the result and the
original with the "Difference" operation in the ImageCalculator and set  the
result as 32 bit, then load some colorful lut and you will understand what I
mean.

Cheers
G.