at.tuwien.ifs.somtoolbox.util
Class ImageUtils

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.util.ImageUtils

public class ImageUtils
extends java.lang.Object

This class provides methods to manipulate images.

Version:
$Id: ImageUtils.java 4156 2011-02-11 15:56:51Z mayer $
Author:
Rudolf Mayer

Nested Class Summary
(package private) static class ImageUtils.Origin
           
 
Constructor Summary
ImageUtils()
           
 
Method Summary
static java.awt.image.BufferedImage autoCrop(java.awt.image.BufferedImage bi)
          Automatically crops an image, by continously removing full rows or columns from all sides, as long as all the pixels in them are all white
static java.awt.image.BufferedImage createEmptyImage(int width, int height)
          Creates a BufferedImage with a white, empty background.
static java.awt.image.BufferedImage createImage(int width, int height, int bkcolor)
          Creates a BufferedImage with the given colour as background
static boolean equalPixelContent(java.awt.image.BufferedImage i1, java.awt.image.BufferedImage i2)
          Compares if two images contain the same pixel content
private static int findNumberOfColumnsToCrop(java.awt.image.BufferedImage bi, ImageUtils.Origin origin)
          Computes how many cols of pixels can be cropped from the specified ImageUtils.Origin; only ImageUtils.Origin.LEFT and ImageUtils.Origin.RIGHT are valid
private static int findNumberOfRowsToCrop(java.awt.image.BufferedImage bi, ImageUtils.Origin origin)
          Computes how many rows of pixels can be cropped from the specified ImageUtils.Origin; only ImageUtils.Origin.TOP and ImageUtils.Origin.BOTTOM are valid
static long getSizeOfImage(java.awt.image.BufferedImage bufferedImage)
          Get the size of an image in bits
static double getSizeOfImageInMBit(java.awt.image.BufferedImage bufferedImage)
          Get the size of an image in MBit, using getSizeOfImage(BufferedImage) and NumberUtils.KBit2MBit
static java.awt.image.BufferedImage scaleImage(java.awt.image.BufferedImage buim, int width)
           
static java.awt.image.BufferedImage scaleImageByHeight(java.awt.image.BufferedImage buim, int height)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageUtils

public ImageUtils()
Method Detail

autoCrop

public static java.awt.image.BufferedImage autoCrop(java.awt.image.BufferedImage bi)
Automatically crops an image, by continously removing full rows or columns from all sides, as long as all the pixels in them are all white


findNumberOfRowsToCrop

private static int findNumberOfRowsToCrop(java.awt.image.BufferedImage bi,
                                          ImageUtils.Origin origin)
Computes how many rows of pixels can be cropped from the specified ImageUtils.Origin; only ImageUtils.Origin.TOP and ImageUtils.Origin.BOTTOM are valid


findNumberOfColumnsToCrop

private static int findNumberOfColumnsToCrop(java.awt.image.BufferedImage bi,
                                             ImageUtils.Origin origin)
Computes how many cols of pixels can be cropped from the specified ImageUtils.Origin; only ImageUtils.Origin.LEFT and ImageUtils.Origin.RIGHT are valid


equalPixelContent

public static boolean equalPixelContent(java.awt.image.BufferedImage i1,
                                        java.awt.image.BufferedImage i2)
Compares if two images contain the same pixel content


scaleImage

public static java.awt.image.BufferedImage scaleImage(java.awt.image.BufferedImage buim,
                                                      int width)

scaleImageByHeight

public static java.awt.image.BufferedImage scaleImageByHeight(java.awt.image.BufferedImage buim,
                                                              int height)

createEmptyImage

public static java.awt.image.BufferedImage createEmptyImage(int width,
                                                            int height)
Creates a BufferedImage with a white, empty background.


createImage

public static java.awt.image.BufferedImage createImage(int width,
                                                       int height,
                                                       int bkcolor)
Creates a BufferedImage with the given colour as background


getSizeOfImage

public static long getSizeOfImage(java.awt.image.BufferedImage bufferedImage)
Get the size of an image in bits


getSizeOfImageInMBit

public static double getSizeOfImageInMBit(java.awt.image.BufferedImage bufferedImage)
Get the size of an image in MBit, using getSizeOfImage(BufferedImage) and NumberUtils.KBit2MBit