net.sourceforge.jiu.color.reduction
Class ReduceShadesOfGray
public class ReduceShadesOfGray
Reduces the number of shades of gray of a grayscale image.
This class uses the most simple possible algorithm.
Only the most significant N bits are kept (where N is the
number specified with
setBits(int)
), the others are dropped
and the result is scaled back to either 8 or 16 bits to fit
into the two grayscale image types.
Supported image classes
This class works with
Gray8Image
and
Gray16Image
.
Usage example
Reduce a grayscale image to 3 bit (2
3 = 8 shades of gray):
ReduceShadesOfGray reduce = new ReduceShadesOfGray();
reduce.setBits(3);
reduce.setInputImage(image); // some Gray8Image or Gray16Image
reduce.process();
PixelImage reducedImage = reduce.getOutputImage();
private Integer | destBits - Number of significant bits in the destination grayscale image.
|
private int[] | lut - Lookup table, for each possible input sample stores the
corresponding output sample.
|
destBits
private Integer destBits
Number of significant bits in the destination grayscale image.
lut
private int[] lut
Lookup table, for each possible input sample stores the
corresponding output sample.
createLut
private void createLut(int inDepth)
setBits
public void setBits(int bits)
Specifies the number of bits the output image is supposed to have.
bits
- number of bits in output image, from 1 to 15