Class ChannelFunctionFilter

  • All Implemented Interfaces:
    java.awt.image.BufferedImageOp

    public class ChannelFunctionFilter
    extends AbstractPixelwiseFilter
    A image filter that applies a function to each channel. The function takes a value between 0 and 1 for a pixel's channel value, and returns a value between 0 and 1 for the output value. The returned value is clamped to lie in the allowed range, if necessary. That is, if the function returns a value less than 0, it is clamped to 0. Likewise, if it returns a value greater than 1, it is clamped to 1.

    In-place filtering: This class supports in-place filtering (the source and destination images may be the same).

    Author:
    Chris Jennings
    • Constructor Detail

      • ChannelFunctionFilter

        public ChannelFunctionFilter()
        Creates a new function filter with all channel functions set to an identity function.
        See Also:
        Fn.IDENTITY
      • ChannelFunctionFilter

        public ChannelFunctionFilter​(Fn alpha,
                                     Fn red,
                                     Fn green,
                                     Fn blue)
        Creates a new function filter with the specified channel functions.
        Parameters:
        alpha - the function applied to the alpha channel
        red - the function applied to the red channel
        green - the function applied to the green channel
        blue - the function applied to the blue channel
    • Method Detail

      • getAlphaFunction

        public Fn getAlphaFunction()
      • setAlphaFunction

        public void setAlphaFunction​(Fn alphaFunction)
      • getRedFunction

        public Fn getRedFunction()
      • setRedFunction

        public void setRedFunction​(Fn redFunction)
      • getGreenFunction

        public Fn getGreenFunction()
      • setGreenFunction

        public void setGreenFunction​(Fn greenFunction)
      • getBlueFunction

        public Fn getBlueFunction()
      • setBlueFunction

        public void setBlueFunction​(Fn blueFunction)
      • filter

        public java.awt.image.BufferedImage filter​(java.awt.image.BufferedImage src,
                                                   java.awt.image.BufferedImage dest)
        Specified by:
        filter in interface java.awt.image.BufferedImageOp
        Overrides:
        filter in class AbstractPixelwiseFilter
      • 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