Class TransformFilter

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BILINEAR
      Use bilinear interpolation.
      static int CLAMP
      Clamp pixels to the image edges.
      protected int edgeAction
      The action to take for pixels off the image edge.
      protected int interpolation
      The type of interpolation to use.
      static int NEAREST_NEIGHBOUR
      Use nearest-neighbout interpolation.
      protected java.awt.Rectangle originalSpace
      The input image rectangle.
      static int RGB_CLAMP
      Clamp pixels RGB to the image edges, but zero the alpha.
      protected java.awt.Rectangle transformedSpace
      The output image rectangle.
      static int WRAP
      Wrap pixels off the edge onto the oppsoite edge.
      static int ZERO
      Treat pixels off the edge as zero.
    • Constructor Summary

      Constructors 
      Constructor Description
      TransformFilter()  
    • Field Detail

      • WRAP

        public static final int WRAP
        Wrap pixels off the edge onto the oppsoite edge.
        See Also:
        Constant Field Values
      • RGB_CLAMP

        public static final int RGB_CLAMP
        Clamp pixels RGB to the image edges, but zero the alpha. This prevents gray borders on your image.
        See Also:
        Constant Field Values
      • NEAREST_NEIGHBOUR

        public static final int NEAREST_NEIGHBOUR
        Use nearest-neighbout interpolation.
        See Also:
        Constant Field Values
      • edgeAction

        protected int edgeAction
        The action to take for pixels off the image edge.
      • interpolation

        protected int interpolation
        The type of interpolation to use.
      • transformedSpace

        protected java.awt.Rectangle transformedSpace
        The output image rectangle.
      • originalSpace

        protected java.awt.Rectangle originalSpace
        The input image rectangle.
    • Constructor Detail

      • TransformFilter

        public TransformFilter()
    • Method Detail

      • setEdgeAction

        public void setEdgeAction​(int edgeAction)
        Set the action to perform for pixels off the edge of the image.
        Parameters:
        edgeAction - one of ZERO, CLAMP or WRAP
        See Also:
        getEdgeAction()
      • getEdgeAction

        public int getEdgeAction()
        Get the action to perform for pixels off the edge of the image.
        Returns:
        one of ZERO, CLAMP or WRAP
        See Also:
        setEdgeAction(int)
      • setInterpolation

        public void setInterpolation​(int interpolation)
        Set the type of interpolation to perform.
        Parameters:
        interpolation - one of NEAREST_NEIGHBOUR or BILINEAR
        See Also:
        getInterpolation()
      • getInterpolation

        public int getInterpolation()
        Get the type of interpolation to perform.
        Returns:
        one of NEAREST_NEIGHBOUR or BILINEAR
        See Also:
        setInterpolation(int)
      • transformInverse

        protected abstract void transformInverse​(int x,
                                                 int y,
                                                 float[] out)
        Inverse transform a point. This method needs to be overriden by all subclasses.
        Parameters:
        x - the X position of the pixel in the output image
        y - the Y position of the pixel in the output image
        out - the position of the pixel in the input image
      • transformSpace

        protected void transformSpace​(java.awt.Rectangle rect)
        Forward transform a rectangle. Used to determine the size of the output image.
        Parameters:
        rect - the rectangle to transform
      • filter

        public java.awt.image.BufferedImage filter​(java.awt.image.BufferedImage src,
                                                   java.awt.image.BufferedImage dst)
      • filterPixelsNN

        protected java.awt.image.BufferedImage filterPixelsNN​(java.awt.image.BufferedImage dst,
                                                              int width,
                                                              int height,
                                                              int[] inPixels,
                                                              java.awt.Rectangle transformedSpace)