Re: Enhance Contrast Question

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

Re: Enhance Contrast Question

Michael Schmid
Hi Fatima,

if you have the lowest and highest pixel value of the range to display between black and white (c and d in your case, I call them 'min' and 'max' here:
In a Macro use
  setMinAndMax(min, max);
and in Java
  ip.setMinAndMax(min, max);
where ip is the ImageProcessor. You can get it for the current image via
  ImagePlus imp = WindowManager.getCurrentImage();
  ImageProcessor ip = imp.getProcessor();

Michael
________________________________________________________________
On Jan 13, 2015, at 21:54, fmerchant wrote:

> Using the site below the description for Contrast Stretching in the Enhance
> Contrast menu item is as follows
>
> http://homepages.inf.ed.ac.uk/rbf/HIPR2/stretch.htm
>
> For example for 8-bit graylevel images the lower and upper limits might be 0
> and 255. Call the lower and the upper limits a and b respectively.
>
> The simplest sort of normalization then scans the image to find the lowest
> and highest pixel values currently present in the image. Call these c and d.
> Then each pixel P is scaled using the following function:
>
>    Pout = (Pin - c) (b-a/d-c) + a
>
> Values below 0 are set to 0 and values about 255 are set to 255.
>
> How do I call Enhance Contrast, with user-defined values for c and d in the
> formula above?
>
> Thanks,
> Fatima
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Enhance-Contrast-Question-tp5011207.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
Reply | Threaded
Open this post in threaded view
|

Re: Enhance Contrast Question

Avital Steinberg
Thanks, Michael - I asked the same question about a day ago and solved it
in the way you described. Getting the min and max values in java works like
this:

double min=ip.getMin();
double max=ip.getMax();

or if it's a macro, use this:

*getMinAndMax(min, max)*
Returns the minimum and maximum displayed pixel values (display range). See
the DisplayRangeMacros
<http://rsb.info.nih.gov/ij/macros/DisplayRangeMacros.txt> for examples.

Avital

On Tue, Jan 13, 2015 at 11:53 PM, Michael Schmid <[hidden email]>
wrote:

> Hi Fatima,
>
> if you have the lowest and highest pixel value of the range to display
> between black and white (c and d in your case, I call them 'min' and 'max'
> here:
> In a Macro use
>   setMinAndMax(min, max);
> and in Java
>   ip.setMinAndMax(min, max);
> where ip is the ImageProcessor. You can get it for the current image via
>   ImagePlus imp = WindowManager.getCurrentImage();
>   ImageProcessor ip = imp.getProcessor();
>
> Michael
> ________________________________________________________________
> On Jan 13, 2015, at 21:54, fmerchant wrote:
>
> > Using the site below the description for Contrast Stretching in the
> Enhance
> > Contrast menu item is as follows
> >
> > http://homepages.inf.ed.ac.uk/rbf/HIPR2/stretch.htm
> >
> > For example for 8-bit graylevel images the lower and upper limits might
> be 0
> > and 255. Call the lower and the upper limits a and b respectively.
> >
> > The simplest sort of normalization then scans the image to find the
> lowest
> > and highest pixel values currently present in the image. Call these c
> and d.
> > Then each pixel P is scaled using the following function:
> >
> >    Pout = (Pin - c) (b-a/d-c) + a
> >
> > Values below 0 are set to 0 and values about 255 are set to 255.
> >
> > How do I call Enhance Contrast, with user-defined values for c and d in
> the
> > formula above?
> >
> > Thanks,
> > Fatima
> >
> >
> >
> >
> > --
> > View this message in context:
> http://imagej.1557.x6.nabble.com/Enhance-Contrast-Question-tp5011207.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
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html