br.usp.ime.klava.segmentit.util
Class ImageUtils

java.lang.Object
  extended by br.usp.ime.klava.segmentit.util.ImageUtils

public class ImageUtils
extends java.lang.Object

Auxiliary class for image transformations.

Author:
Bruno Klava

Constructor Summary
ImageUtils()
           
 
Method Summary
static java.awt.image.BufferedImage getBoundaryImage(java.awt.image.BufferedImage input, java.awt.Color borderColor)
          Returns an image containing the boundary of the given input image.
static java.awt.Color getColor(int x, int y, java.awt.image.BufferedImage image)
          Returns the Color of the pixel of at (x, y) in the image.
static java.awt.image.BufferedImage getFrame(int width, int height, java.awt.Color color)
          Returns an image with a frame (first and last line and columns of pixels) painted
static java.awt.image.BufferedImage getImageWithoutColor(java.awt.image.BufferedImage input, java.awt.Color color)
          Returns a new BufferedImage, removing color from input.
static java.awt.image.BufferedImage getNormalizedPotency(java.awt.image.BufferedImage image, double alpha)
          Return an image where the gray level of each output pixel is given by the equation: output = round(input^alpha * 255^(1-alpha)), where round(x) returns the integer most close to x and input is the gray level of the corresponding pixel in the input image.
static java.awt.image.BufferedImage getOuterBoundaryImage(java.awt.image.BufferedImage input, java.awt.Color color)
          Returns an image containing the outer boundary of the given input image.
static java.awt.image.BufferedImage getScaledInstance(java.awt.image.BufferedImage input, double scale)
          Returns an scaled version of the input image.
static java.awt.Color infersPartitionLinesColor(java.awt.image.BufferedImage image)
          Infers the partition lines color of image.
static java.awt.image.BufferedImage threshold(java.awt.image.BufferedImage image, int level, java.awt.Color color, java.awt.Color backgroundColor)
          Returns the threshold of image.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageUtils

public ImageUtils()
Method Detail

threshold

public static java.awt.image.BufferedImage threshold(java.awt.image.BufferedImage image,
                                                     int level,
                                                     java.awt.Color color,
                                                     java.awt.Color backgroundColor)
                                              throws ColorImageException
Returns the threshold of image.

Parameters:
image - the input image
level - the gray level used as threshold level
color - the color to paint the pixels that have gray level less than or equal to level
backgroundColor - the color to paint the pixels that have gray level greater than level, if null they will be transparent
Returns:
the threshold of image
Throws:
ColorImageException - if image if not a gray level image

getFrame

public static java.awt.image.BufferedImage getFrame(int width,
                                                    int height,
                                                    java.awt.Color color)
Returns an image with a frame (first and last line and columns of pixels) painted

Parameters:
width - the width of the frame
height - the height of the frame
color - the Color of the frame
Returns:
a frame of width x height pixels colored in color

getScaledInstance

public static java.awt.image.BufferedImage getScaledInstance(java.awt.image.BufferedImage input,
                                                             double scale)
Returns an scaled version of the input image.

Parameters:
input - a BufferedImage
scale - a scale factor for the desired output image
Returns:
an scaled version of the input image (with its width and height multiplied by scale)

getOuterBoundaryImage

public static java.awt.image.BufferedImage getOuterBoundaryImage(java.awt.image.BufferedImage input,
                                                                 java.awt.Color color)
Returns an image containing the outer boundary of the given input image. Consider as foreground any pixels painted (with any color) and as background any transparent pixels.

Parameters:
input - the image whose outer boundary is wanted
color - the color used to paint the outer boundary
Returns:
and image containing the outer boundary of input painted in color

getBoundaryImage

public static java.awt.image.BufferedImage getBoundaryImage(java.awt.image.BufferedImage input,
                                                            java.awt.Color borderColor)
Returns an image containing the boundary of the given input image. The boundary pixels are the ones that have any neighbor of another color.

Parameters:
input - the image whose outer boundary is wanted
borderColor - the Color to paint the border pixels
Returns:
and image containing the outer boundary of input

getNormalizedPotency

public static java.awt.image.BufferedImage getNormalizedPotency(java.awt.image.BufferedImage image,
                                                                double alpha)
                                                         throws ColorImageException
Return an image where the gray level of each output pixel is given by the equation:

output = round(input^alpha * 255^(1-alpha)),

where round(x) returns the integer most close to x and input is the gray level of the corresponding pixel in the input image.

The parameter alpha controls the brightness of the output image:

The gray levels of the output image are always in the interval [0;255], for input images whose gray levels are in the same interval.

Parameters:
image - the gray level input image
alpha - controls the brightness of the output image
Returns:
a brighter or darker image, depending on the value of alpha
Throws:
ColorImageException - if image is not a gray level image

getColor

public static java.awt.Color getColor(int x,
                                      int y,
                                      java.awt.image.BufferedImage image)
Returns the Color of the pixel of at (x, y) in the image.

Parameters:
x - the x-coordinate of a pixel
y - the y-coordinate of a pixel
image -
Returns:
the Color of the pixel of at (x, y), null if it is a transparent pixel

infersPartitionLinesColor

public static java.awt.Color infersPartitionLinesColor(java.awt.image.BufferedImage image)
Infers the partition lines color of image. If image is binary, returns the less used Color in image. Otherwise, returns null.

Parameters:
image - a BufferedImage
Returns:
the partition lines color of image

getImageWithoutColor

public static java.awt.image.BufferedImage getImageWithoutColor(java.awt.image.BufferedImage input,
                                                                java.awt.Color color)
Returns a new BufferedImage, removing color from input.

Parameters:
input - a BufferedImage
color - a Color
Returns:
a new BufferedImage, removing color from input