JIU 0.12.0 Homepage

net.sourceforge.jiu.geometry
Class Crop

java.lang.Object
  extended bynet.sourceforge.jiu.ops.Operation
      extended bynet.sourceforge.jiu.ops.ImageToImageOperation
          extended bynet.sourceforge.jiu.geometry.Crop

public class Crop
extends ImageToImageOperation

Copies a rectangular area of one image to another image that is exactly as large as that rectangular area. Works with all image data classes implementing IntegerImage. Make sure to use zero-based parameters when defining the bounds with setBounds(int, int, int, int)!

Usage example

In this example we assume that the input image is larger than 20 pixels in both directions. Ten pixels will be removed from any of its four borders.
 PixelImage image = ...; // something implementing IntegerImage
 Crop crop = new Crop();
 crop.setInputImage(image);
 crop.setBounds(10, 10, image.getWidth() - 9, image.getHeight() - 9);
 crop.process();
 PixelImage croppedImage = crop.getOutputImage();
 

Author:
Marco Schmidt

Constructor Summary
Crop()
           
 
Method Summary
 void process()
          This method does the actual work of the operation.
 void setBounds(int x1, int y1, int x2, int y2)
          Specify the rectangular section of the original image that is to be copied to the output image by this operation.
 
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, removeProgressListener, setAbort, setProgress, setProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Crop

public Crop()
Method Detail

process

public void process()
             throws MissingParameterException,
                    WrongParameterException
Description copied from class: Operation
This method does the actual work of the operation. It must be called after all parameters have been given to the operation object.

Overrides:
process in class Operation
Throws:
MissingParameterException - if any mandatory parameter was not given to the operation
WrongParameterException - if at least one of the input parameters was not initialized appropriately (values out of the valid interval, etc.)

setBounds

public void setBounds(int x1,
                      int y1,
                      int x2,
                      int y2)
               throws IllegalArgumentException
Specify the rectangular section of the original image that is to be copied to the output image by this operation. Note that the arguments are not checked directly against any input image that may have been provided to this Crop object, that checking is done later in process(). If any of the arguments provided here are outside of the input image's resolution (e.g. x1 == 100 although the input image's width is only 60), a WrongParameterException will be thrown from within process().

Note that the arguments to this method are zero-based, so the first column and row are 0, the second 1, the third 2, and so on. If you have a image that is 200 pixels wide and 100 pixels high, values from 0 to 199 are valid for the x arguments, and values from 0 to 99 are valid for the vertical direction.

Parameters:
x1 - horizontal position of upper left corner of the rectangle
y1 - vertical position of upper left corner of the rectangle
x2 - horizontal position of lower right corner of the rectangle
y2 - vertical position of lower right corner of the rectangle
Throws:
IllegalArgumentException - if any of the arguments is negative or x1 larger than x2 or y1 larger than y2

JIU 0.12.0 Homepage

Copyright © 2000, 2001, 2002, 2003, 2004 Marco Schmidt