Package ca.cgjennings.graphics.filters
Class GammaCorrectionFilter
- java.lang.Object
-
- ca.cgjennings.graphics.filters.AbstractImageFilter
-
- ca.cgjennings.graphics.filters.AbstractPixelwiseFilter
-
- ca.cgjennings.graphics.filters.GammaCorrectionFilter
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp
public class GammaCorrectionFilter extends AbstractPixelwiseFilter
Applies a gamma correction function to the source image. The alpha channel is unaffected. Gamma correction adjusts images to account for the property of the human visual system that it is more sensitive to the shadows in an image than it is to the highlights.This filter can also be used to recolour an image by first converting it to greyscale and then applying a gamma correction in the direction of the desired colour. A gamma correction value of 1 results in no change to the affected channel; values greater than 1 increase the values in the channel and values less than 1 decrease the values in the channel and therefore also increase the relative amount of the channel's colour complement:
<1 1 >1 Red gamma More Cyan No Change More Red Green gamma More Magenta No Change More Green Blue gamma More Yellow No Change More Blue
For example, the following gamma correction values will approximate a sepia tone effect: R=1.5, G=1, B=0.5.
- Since:
- 2.1
- Author:
- Chris Jennings
-
-
Constructor Summary
Constructors Constructor Description GammaCorrectionFilter()
GammaCorrectionFilter(double gamma)
GammaCorrectionFilter(double rGamma, double gGamma, double bGamma)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int[]
createGammaLookupTable(double gamma, int levels)
void
filterPixels(int[] argb, int start, int end)
This method is called with a block of ARGB values to be filtered.double
getBlueGamma()
double
getGreenGamma()
double
getRedGamma()
void
setBlueGamma(double bGamma)
void
setGamma(double rGamma, double gGamma, double bGamma)
void
setGreenGamma(double gGamma)
void
setRedGamma(double rGamma)
-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractPixelwiseFilter
filter, filter, filterPixel, workFactor
-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractImageFilter
clamp, clamp, clamp, clampBoth, createCompatibleDestImage, fA, fB, fG, fR, getARGB, getARGB, getARGBSynch, getBounds2D, getPoint2D, getRenderingHints, iA, iB, iG, iR, setARGB, setARGB, setARGBSynch
-
-
-
-
Method Detail
-
setGamma
public void setGamma(double rGamma, double gGamma, double bGamma)
-
getRedGamma
public double getRedGamma()
-
setRedGamma
public void setRedGamma(double rGamma)
-
getGreenGamma
public double getGreenGamma()
-
setGreenGamma
public void setGreenGamma(double gGamma)
-
getBlueGamma
public double getBlueGamma()
-
setBlueGamma
public void setBlueGamma(double bGamma)
-
createGammaLookupTable
public static int[] createGammaLookupTable(double gamma, int levels)
-
filterPixels
public void filterPixels(int[] argb, int start, int end)
Description copied from class:AbstractPixelwiseFilter
This method is called with a block of ARGB values to be filtered. Subclasses must override this method to implement the actual filtering algorithm by replacing each pixel value in the rangeargb[start] ... argb[end-1]
with the filtered value.- Specified by:
filterPixels
in classAbstractPixelwiseFilter
- Parameters:
argb
- an array of pixel data to filterstart
- the index of the first pixel to filterend
- the index of the last pixel to filter, plus one
-
-