Class 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 Detail

      • GammaCorrectionFilter

        public GammaCorrectionFilter()
      • GammaCorrectionFilter

        public GammaCorrectionFilter​(double gamma)
      • GammaCorrectionFilter

        public GammaCorrectionFilter​(double rGamma,
                                     double gGamma,
                                     double bGamma)
    • 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 range argb[start] ... argb[end-1] with the filtered value.
        Specified by:
        filterPixels in class AbstractPixelwiseFilter
        Parameters:
        argb - an array of pixel data to filter
        start - the index of the first pixel to filter
        end - the index of the last pixel to filter, plus one