zscale
Francisco Valdes wrote on Dec 05, 2005
From: Jeremy Brewer <jeremy.d.brewer@gmail.com ([email]jeremy.d.brewer@gmail.com[/email])>
Date: December 2, 2005 1:48:52 PM MST
To: valdes@noao.edu ([email]valdes@noao.edu[/email])
Subject: zscale
I can't find a description of the 'zscale' scaling algorithm anywhere.
 Do you have a reference for how it determines the proper scaling of
the pixels?
Jeremy Brewer
University of Pittsburgh
From: Frank Valdes <valdes@noao.edu ([email]valdes@noao.edu[/email])>
Date: December 5, 2005 3:36:45 PM MST
To: Jeremy Brewer <jeremy.d.brewer@gmail.com ([email]jeremy.d.brewer@gmail.com[/email])>
Subject: Re: zscale
Hello Jeremy,
The algorithm is described in the IRAF help for the DISPLAY task in a section on the algorithm. I include the section below for your convenience. In summary, the algorithm consists of selecting a subset of pixels (using masks if defined to exclude data), sorting the values, chopping off the ends, and fitting a linear function.
Yours,
Frank Valdes
From the DISPLAY help page:
ZSCALE ALGORITHM
  The zscale algorithm is designed to display the image values near
  the median image value without the time consuming process of
  computing a full image histogram. This is particularly useful for
  astronomical images which generally have a very peaked histogram
  corresponding to the background sky in direct imaging or the
  continuum in a two dimensional spectrum.
  The sample of pixels, specified by values greater than zero in the
  sample mask zmask or by an image section, is selected up to a
  maximum of nsample pixels. If a bad pixel mask is specified by the
  bpmask parameter then any pixels with mask values which are greater
  than zero are not counted in the sample. Only the first pixels up
  to the limit are selected where the order is by line beginning from
  the first line. If no mask is specified then a grid of pixels with
  even spacing along lines and columns that make up a number less
  than or equal to the maximum sample size is used.
  If a contrast of zero is specified (or the zrange flag is used and
  the image does not have a valid minimum/maximum value) then the
  minimum and maximum of the sample is used for the intensity mapping
  range.
  If the contrast is not zero the sample pixels are ranked in
  brightness to form the function I(i) where i is the rank of the
  pixel and I is its value. Generally the midpoint of this function
  (the median) is very near the peak of the image histogram and there
  is a well defined slope about the midpoint which is related to the
  width of the histogram. At the ends of the I(i) function there are
  a few very bright and dark pixels due to objects and defects in the
  field.  To determine the slope a linear function is fit with
  iterative rejection;
      I(i) = intercept + slope * (i - midpoint)
  If more than half of the points are rejected then there is no well
  defined slope and the full range of the sample defines z1 and z2.
  Otherwise the endpoints of the linear function are used (provided
  they are within the original range of the sample):
      z1 = I(midpoint) + (slope / contrast) * (1 - midpoint)
      z2 = I(midpoint) + (slope / contrast) * (npoints - midpoint)
  As can be seen, the parameter contrast may be used to adjust the
  contrast produced by this algorithm.
Post generated using Mail2Forum (http://www.mail2forum.com)
Date: December 2, 2005 1:48:52 PM MST
To: valdes@noao.edu ([email]valdes@noao.edu[/email])
Subject: zscale
I can't find a description of the 'zscale' scaling algorithm anywhere.
 Do you have a reference for how it determines the proper scaling of
the pixels?
Jeremy Brewer
University of Pittsburgh
From: Frank Valdes <valdes@noao.edu ([email]valdes@noao.edu[/email])>
Date: December 5, 2005 3:36:45 PM MST
To: Jeremy Brewer <jeremy.d.brewer@gmail.com ([email]jeremy.d.brewer@gmail.com[/email])>
Subject: Re: zscale
Hello Jeremy,
The algorithm is described in the IRAF help for the DISPLAY task in a section on the algorithm. I include the section below for your convenience. In summary, the algorithm consists of selecting a subset of pixels (using masks if defined to exclude data), sorting the values, chopping off the ends, and fitting a linear function.
Yours,
Frank Valdes
From the DISPLAY help page:
ZSCALE ALGORITHM
  The zscale algorithm is designed to display the image values near
  the median image value without the time consuming process of
  computing a full image histogram. This is particularly useful for
  astronomical images which generally have a very peaked histogram
  corresponding to the background sky in direct imaging or the
  continuum in a two dimensional spectrum.
  The sample of pixels, specified by values greater than zero in the
  sample mask zmask or by an image section, is selected up to a
  maximum of nsample pixels. If a bad pixel mask is specified by the
  bpmask parameter then any pixels with mask values which are greater
  than zero are not counted in the sample. Only the first pixels up
  to the limit are selected where the order is by line beginning from
  the first line. If no mask is specified then a grid of pixels with
  even spacing along lines and columns that make up a number less
  than or equal to the maximum sample size is used.
  If a contrast of zero is specified (or the zrange flag is used and
  the image does not have a valid minimum/maximum value) then the
  minimum and maximum of the sample is used for the intensity mapping
  range.
  If the contrast is not zero the sample pixels are ranked in
  brightness to form the function I(i) where i is the rank of the
  pixel and I is its value. Generally the midpoint of this function
  (the median) is very near the peak of the image histogram and there
  is a well defined slope about the midpoint which is related to the
  width of the histogram. At the ends of the I(i) function there are
  a few very bright and dark pixels due to objects and defects in the
  field.  To determine the slope a linear function is fit with
  iterative rejection;
      I(i) = intercept + slope * (i - midpoint)
  If more than half of the points are rejected then there is no well
  defined slope and the full range of the sample defines z1 and z2.
  Otherwise the endpoints of the linear function are used (provided
  they are within the original range of the sample):
      z1 = I(midpoint) + (slope / contrast) * (1 - midpoint)
      z2 = I(midpoint) + (slope / contrast) * (npoints - midpoint)
  As can be seen, the parameter contrast may be used to adjust the
  contrast produced by this algorithm.
Post generated using Mail2Forum (http://www.mail2forum.com)
Last post on Dec 05, 2005