feature_extraction
Class ImageScaling

java.lang.Object
  extended by feature_extraction.ImageScaling

public class ImageScaling
extends java.lang.Object

This class performs image scaling

Author:
Eleftherios Spyromitros-Xioufis

Field Summary
private  boolean higherQuality
          If true, this class will use a multi-step scaling technique that provides higher quality than the usual one-step technique (only useful in downscaling cases and generally only when the BILINEAR hint is specified)
private  java.lang.Object hint
          One of the rendering hints that corresponds to RenderingHints.KEY_INTERPOLATION (e.g.
private  int targetSize
          Depending on the method that will be called for scaling the image, the targetSize corresponds to:
a.
 
Constructor Summary
ImageScaling()
          Constructor with no arguments, all fields take the default values
ImageScaling(int targetSize)
           
ImageScaling(int targetSize, boolean highQuality, java.lang.Object hint)
           
ImageScaling(java.lang.String scalingTypeParameter, java.lang.String scalingSizeParameter)
           
 
Method Summary
static void advancedUse()
           
static void main(java.lang.String[] args)
           
 java.awt.image.BufferedImage maxPixelsScaling(java.awt.image.BufferedImage img)
          This method returns a scaled instance of the provided BufferedImage.
 java.awt.image.BufferedImage rectScaling(java.awt.image.BufferedImage img)
          This method returns a scaled instance of the provided BufferedImage.
 java.awt.image.BufferedImage rectScaling(java.lang.String imageFilename)
          Same as rectScaling(BufferedImage) but takes the imageFileName instead of a BufferedImage.
 java.awt.image.BufferedImage squareScaling(java.awt.image.BufferedImage img)
          This method returns a scaled instance of the provided BufferedImage.
 java.awt.image.BufferedImage squareScaling(java.lang.String imageFilename)
          Same as squareScaling(BufferedImage) but takes the imageFileName instead of a BufferedImage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

targetSize

private int targetSize
Depending on the method that will be called for scaling the image, the targetSize corresponds to:
 a. The total number of pixels.
 b. The dimension of a square thumbnail in pixels.
 c. The larger dimension of a rectangular thumbnail in pixels.
 


higherQuality

private boolean higherQuality
If true, this class will use a multi-step scaling technique that provides higher quality than the usual one-step technique (only useful in downscaling cases and generally only when the BILINEAR hint is specified)


hint

private java.lang.Object hint
One of the rendering hints that corresponds to RenderingHints.KEY_INTERPOLATION (e.g. RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR, RenderingHints.VALUE_INTERPOLATION_BILINEAR, RenderingHints.VALUE_INTERPOLATION_BICUBIC)

Constructor Detail

ImageScaling

public ImageScaling()
Constructor with no arguments, all fields take the default values


ImageScaling

public ImageScaling(int targetSize)

ImageScaling

public ImageScaling(int targetSize,
                    boolean highQuality,
                    java.lang.Object hint)

ImageScaling

public ImageScaling(java.lang.String scalingTypeParameter,
                    java.lang.String scalingSizeParameter)
Method Detail

maxPixelsScaling

public java.awt.image.BufferedImage maxPixelsScaling(java.awt.image.BufferedImage img)
This method returns a scaled instance of the provided BufferedImage. The image is scaled to a maximum of targetSize pixels in total by keeping the aspect ratio.

Parameters:
img - the original image to be scaled
Returns:
a scaled version of the original BufferedImage or the original image if no scaling was applied

squareScaling

public java.awt.image.BufferedImage squareScaling(java.awt.image.BufferedImage img)
This method returns a scaled instance of the provided BufferedImage. The image is scaled so that its minimum dimension becomes targetSize pixels and then the larger dimension is cropped, again to targetSize pixels to create a square thumbnail.

Parameters:
img - the original image to be scaled
Returns:
a scaled version of the original BufferedImage or the original image if no scaling was applied

squareScaling

public java.awt.image.BufferedImage squareScaling(java.lang.String imageFilename)
                                           throws java.io.IOException
Same as squareScaling(BufferedImage) but takes the imageFileName instead of a BufferedImage.

Parameters:
imageFilename -
Returns:
Throws:
java.io.IOException

rectScaling

public java.awt.image.BufferedImage rectScaling(java.awt.image.BufferedImage img)
This method returns a scaled instance of the provided BufferedImage. The image is scaled so that its maximum dimension becomes targetSize pixels.

Parameters:
img - the original image to be scaled
Returns:
a scaled version of the original BufferedImage or the original image if no scaling was applied

rectScaling

public java.awt.image.BufferedImage rectScaling(java.lang.String imageFilename)
                                         throws java.io.IOException
Same as rectScaling(BufferedImage) but takes the imageFileName instead of a BufferedImage.

Parameters:
imageFilename -
Returns:
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException

advancedUse

public static void advancedUse()
                        throws java.io.IOException
Throws:
java.io.IOException