Class Quantize
java.lang.Object
nom.tam.fits.compression.algorithm.quant.Quantize
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final double
private static final double
private double
maximum non-null valueprivate static final int
private double
minimum non-null valueprivate static final long
number of reserved values, starting withprivate static final int
private static final int
private long
number of good, non-null pixels?private static final double
private static final double
private static final double
private double
returned 2nd order MAD of all non-null pixelsprivate double
returned 3rd order MAD of all non-null pixelsprivate double
private final QuantizeOption
private double
private double
private double
private double
private double
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
calculateNoise
(double[] arrayIn, int nx, int ny) Estimate the median and background noise in the input image using 2nd, 3rd and 5th order Median Absolute Differences.private boolean
calculateNoiseShortRow
(Quantize.DoubleArrayPointer array, int nx, int ny) protected void
computeMedianOfValuesEachRow
(int nrows, int nrows2, double[] diffs2, double[] diffs3, double[] diffs5) protected int
findNextValidPixelWithNullCheck
(int nx, Quantize.DoubleArrayPointer rowpix, int ii) private double
getNextPixelAndCheckMinMax
(Quantize.DoubleArrayPointer rowpix, int ii) protected double
protected double
protected double
private void
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.private double
quickSelect
(double[] arr, int n) private void
setNoiseResult
(long ngoodpix) private void
swapElements
(double[] array, int one, int second)
-
Field Details
-
DEFAULT_QUANT_LEVEL
private static final double DEFAULT_QUANT_LEVEL- See Also:
-
MAX_INT_AS_DOUBLE
private static final double MAX_INT_AS_DOUBLE- See Also:
-
MINIMUM_PIXEL_WIDTH
private static final int MINIMUM_PIXEL_WIDTH- See Also:
-
N_RESERVED_VALUES
private static final long N_RESERVED_VALUESnumber of reserved values, starting with- See Also:
-
N4
private static final int N4- See Also:
-
N6
private static final int N6- See Also:
-
NOISE_2_MULTIPLICATOR
private static final double NOISE_2_MULTIPLICATOR- See Also:
-
NOISE_3_MULTIPLICATOR
private static final double NOISE_3_MULTIPLICATOR- See Also:
-
NOISE_5_MULTIPLICATOR
private static final double NOISE_5_MULTIPLICATOR- See Also:
-
parameter
-
maxValue
private double maxValuemaximum non-null value -
minValue
private double minValueminimum non-null value -
ngood
private long ngoodnumber of good, non-null pixels? -
noise2
private double noise2returned 2nd order MAD of all non-null pixels -
noise3
private double noise3returned 3rd order MAD of all non-null pixels -
noise5
private double noise5 -
xmaxval
private double xmaxval -
xminval
private double xminval -
xnoise2
private double xnoise2 -
xnoise3
private double xnoise3 -
xnoise5
private double xnoise5
-
-
Constructor Details
-
Quantize
-
-
Method Details
-
calculateNoise
private void calculateNoise(double[] arrayIn, int nx, int ny) Estimate the median and background noise in the input image using 2nd, 3rd and 5th order Median Absolute Differences. The noise in the background of the image is calculated using the MAD algorithms developed for deriving the signal to noise ratio in spectra (see issue #42 of the ST-ECF newsletter, http://www.stecf.org/documents/newsletter/) 3rd order: noise = 1.482602 / sqrt(6) * median (abs(2*flux(i) - flux(i-2) - flux(i+2))) The returned estimates are the median of the values that are computed for each row of the image.- Parameters:
arrayIn
- 2 dimensional tiledImageOperation of image pixelsnx
- number of pixels in each row of the imageny
- number of rows in the imagenullcheck
- check for null values, if truenullvalue
- value of null pixels, if nullcheck is true
-
calculateNoiseShortRow
-
computeMedianOfValuesEachRow
protected void computeMedianOfValuesEachRow(int nrows, int nrows2, double[] diffs2, double[] diffs3, double[] diffs5) -
findNextValidPixelWithNullCheck
-
getNextPixelAndCheckMinMax
-
getNoise2
protected double getNoise2() -
getNoise3
protected double getNoise3() -
getNoise5
protected double getNoise5() -
initializeNoise
private void initializeNoise() -
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 quantinizenxpix
- the image widthnypix
- the image hight- Returns:
- true if the quantification was possible
-
quickSelect
private double quickSelect(double[] arr, int n) -
setNoiseResult
private void setNoiseResult(long ngoodpix) -
swapElements
private void swapElements(double[] array, int one, int second)
-