net.sourceforge.jiu.geometry

Class Shear


public class Shear
extends ImageToImageOperation

Shears an image by a given angle. The angle must be larger than -90 and smaller than 90 degrees. Shearing works with all image types that implement IntegerImage.

Usage example

 Shear shear = new Shear();
 shear.setInputImage(image); // some IntegerImage
 shear.setAngle(5.0);
 shear.process();
 PixelImage shearedImage = shear.getOutputImage();
 

This is an adjusted version of Jef Poskanzer's shearing code from his ACME package; see the API documentation page of ACME's Shear class.

Authors:
Jef Poskanzer
Marco Schmidt

Field Summary

private double
angle

Fields inherited from class net.sourceforge.jiu.ops.ImageToImageOperation

canInAndOutBeEqual, inputImage, outputImage

Fields inherited from class net.sourceforge.jiu.ops.Operation

abort, progressListeners

Method Summary

static int
computeNewImageWidth(int oldImageWidth, int height, double angle)
For a given image width and shearing angle this method computes the width of the resulting image.
double
getAngle()
Returns the angle associated with this shearing operation object.
void
process()
private void
process(IntegerImage in, IntegerImage out)
void
setAngle(double newAngle)
Sets the angle to be used in the shearing operation to the argument value.

Methods inherited from class net.sourceforge.jiu.ops.ImageToImageOperation

canInputAndOutputBeEqual, ensureImagesHaveSameResolution, ensureInputImageIsAvailable, ensureOutputImageResolution, getInputImage, getOutputImage, setCanInputAndOutputBeEqual, setInputImage, setOutputImage

Methods inherited from class net.sourceforge.jiu.ops.Operation

addProgressListener, addProgressListeners, getAbort, process, removeProgressListener, setAbort, setProgress, setProgress

Field Details

angle

private double angle

Method Details

computeNewImageWidth

public static int computeNewImageWidth(int oldImageWidth,
                                       int height,
                                       double angle)
For a given image width and shearing angle this method computes the width of the resulting image. This method is static so that it can be called easily from a GUI dialog or other objects that want to present the width of a sheared image.
Parameters:
oldImageWidth - horizontal resolution of the image to be sheared
height - height of the image to be sheared
angle - the angle to be used in the shearing operation
Returns:
width of the sheared image

getAngle

public double getAngle()
Returns the angle associated with this shearing operation object.
Returns:
shearing angle, between -90 and 90

process

public void process()
            throws MissingParameterException,
                   WrongParameterException
Overrides:
process in interface Operation

process

private void process(IntegerImage in,
                     IntegerImage out)

setAngle

public void setAngle(double newAngle)
Sets the angle to be used in the shearing operation to the argument value. The angle must be larger than -90.0 and smaller than 90.0.
Parameters:
newAngle - the angle to be used in this operation