Class Quantize


  • public class Quantize
    extends java.lang.Object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void computeMedianOfValuesEachRow​(int nrows, int nrows2, double[] diffs2, double[] diffs3, double[] diffs5)  
      protected int findNextValidPixelWithNullCheck​(int nx, nom.tam.fits.compression.algorithm.quant.Quantize.DoubleArrayPointer rowpix, int ii)  
      protected double getNoise2()  
      protected double getNoise3()  
      protected double getNoise5()  
      protected boolean isNull​(double d)  
      boolean quantize​(double[] fdata, int nxpix, int nypix)
      arguments: long row i: tile number = row number in the binary table double fdata[] i: tiledImageOperation of image pixels to be compressed long nxpix i: number of pixels in each row of fdata long nypix i: number of rows in fdata nullcheck i: check for nullvalues in fdata? double in_null_value i: value used to represent undefined pixels in fdata float qlevel i: quantization level int dither_method i; which dithering method to use int idata[] o: values of fdata after applying bzero and bscale double bscale o: scale factor double bzero o: zero offset int iminval o: minimum quantized value that is returned int imaxval o: maximum quantized value that is returned The function value will be one if the input fdata were copied to idata; in this case the parameters bscale and bzero can be used to convert back to nearly the original floating point values: fdata ~= idata * bscale + bzero.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • computeMedianOfValuesEachRow

        protected void computeMedianOfValuesEachRow​(int nrows,
                                                    int nrows2,
                                                    double[] diffs2,
                                                    double[] diffs3,
                                                    double[] diffs5)
      • findNextValidPixelWithNullCheck

        protected int findNextValidPixelWithNullCheck​(int nx,
                                                      nom.tam.fits.compression.algorithm.quant.Quantize.DoubleArrayPointer rowpix,
                                                      int ii)
      • getNoise2

        protected double getNoise2()
      • getNoise3

        protected double getNoise3()
      • getNoise5

        protected double getNoise5()
      • isNull

        protected boolean isNull​(double d)
      • quantize

        public boolean quantize​(double[] fdata,
                                int nxpix,
                                int nypix)
        arguments: long row i: tile number = row number in the binary table double fdata[] i: tiledImageOperation of image pixels to be compressed long nxpix i: number of pixels in each row of fdata long nypix i: number of rows in fdata nullcheck i: check for nullvalues in fdata? double in_null_value i: value used to represent undefined pixels in fdata float qlevel i: quantization level int dither_method i; which dithering method to use int idata[] o: values of fdata after applying bzero and bscale double bscale o: scale factor double bzero o: zero offset int iminval o: minimum quantized value that is returned int imaxval o: maximum quantized value that is returned The function value will be one if the input fdata were copied to idata; in this case the parameters bscale and bzero can be used to convert back to nearly the original floating point values: fdata ~= idata * bscale + bzero. If the function value is zero, the data were not copied to idata.

        In earlier implementations of the compression code, we only used the noise3 value as the most reliable estimate of the background noise in an image. If it is not possible to compute a noise3 value, then this serves as a red flag to indicate that quantizing the image could cause a loss of significant information in the image.

        At some later date, we decided to take the more conservative approach of using the minimum of all three of the noise values (while still requiring that noise3 has a defined value) as the best estimate of the noise. Note that if an image contains pure Gaussian distributed noise, then noise2, noise3, and noise5 will have exactly the same value (within statistical measurement errors).

        Parameters:
        fdata - the data to quantinize
        nxpix - the image width
        nypix - the image hight
        Returns:
        true if the quantification was possible