com.jhlabs.image

Class DisplaceFilter

Implemented Interfaces:
BufferedImageOp, Cloneable

public class DisplaceFilter
extends TransformFilter

A filter which simulates the appearance of looking through glass. A separate grayscale displacement image is provided and pixels in the source image are displaced according to the gradient of the displacement map.

Field Summary

Fields inherited from class com.jhlabs.image.TransformFilter

BILINEAR, CLAMP, NEAREST_NEIGHBOUR, RGB_CLAMP, WRAP, ZERO, edgeAction, interpolation, originalSpace, transformedSpace

Constructor Summary

DisplaceFilter()

Method Summary

BufferedImage
filter(BufferedImage src, BufferedImage dst)
float
getAmount()
Get the amount of distortion.
BufferedImage
getDisplacementMap()
Get the displacement map.
void
setAmount(float amount)
Set the amount of distortion.
void
setDisplacementMap(BufferedImage displacementMap)
Set the displacement map.
String
toString()
protected void
transformInverse(int x, int y, float[] out)
Inverse transform a point.

Methods inherited from class com.jhlabs.image.TransformFilter

filter, filterPixelsNN, getEdgeAction, getInterpolation, setEdgeAction, setInterpolation, transformInverse, transformSpace

Methods inherited from class com.jhlabs.image.AbstractBufferedImageOp

clone, createCompatibleDestImage, getBounds2D, getPoint2D, getRGB, getRenderingHints, setRGB

Constructor Details

DisplaceFilter

public DisplaceFilter()

Method Details

filter

public BufferedImage filter(BufferedImage src,
                            BufferedImage dst)
Overrides:
filter in interface TransformFilter

getAmount

public float getAmount()
Get the amount of distortion.
Returns:
the amount

getDisplacementMap

public BufferedImage getDisplacementMap()
Get the displacement map.
Returns:
an image representing the displacment at each point

setAmount

public void setAmount(float amount)
Set the amount of distortion.
Parameters:
amount - the amount

setDisplacementMap

public void setDisplacementMap(BufferedImage displacementMap)
Set the displacement map.
Parameters:
displacementMap - an image representing the displacment at each point

toString

public String toString()

transformInverse

protected void transformInverse(int x,
                                int y,
                                float[] out)
Inverse transform a point. This method needs to be overriden by all subclasses.
Overrides:
transformInverse in interface TransformFilter
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