maslab.util
Class ImageUtil

java.lang.Object
  extended by maslab.util.ImageUtil

public class ImageUtil
extends java.lang.Object

Useful image utilities.


Constructor Summary
ImageUtil()
           
 
Method Summary
static java.awt.image.BufferedImage cloneImage(java.awt.image.BufferedImage in)
          Clone an image.
static java.awt.image.BufferedImage convertImage(java.awt.image.BufferedImage in, int type)
          Convert an image to a specified type.
static java.awt.image.BufferedImage ditherImage(java.awt.image.BufferedImage in)
          Convert an arbitrary input image into a black and white dithered image (using the Floyd-Steinberg dithering algorithm with auto thresholding) suitable for display on the lcd panel.
static java.awt.image.BufferedImage downSample(java.awt.image.BufferedImage in, int interval)
          Downsample an image (obsolete; do not use)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageUtil

public ImageUtil()
Method Detail

convertImage

public static java.awt.image.BufferedImage convertImage(java.awt.image.BufferedImage in,
                                                        int type)
Convert an image to a specified type.

Parameters:
in - The input image, in any format.
type - The desired type, e.g. BufferedImage.TYPE_3BYTE_BGR
Returns:
An image with analagous content as in, but of the requested type. Or, if the input image was already in the requested format, the input image is returned.

ditherImage

public static java.awt.image.BufferedImage ditherImage(java.awt.image.BufferedImage in)
Convert an arbitrary input image into a black and white dithered image (using the Floyd-Steinberg dithering algorithm with auto thresholding) suitable for display on the lcd panel. You should perform scaling operations before calling this function.

Parameters:
in - The image to convert.
Returns:
The dithered black and white image.

downSample

public static java.awt.image.BufferedImage downSample(java.awt.image.BufferedImage in,
                                                      int interval)
Downsample an image (obsolete; do not use)

Parameters:
in - The image to downsample. It will not be modified.
interval - The sampling interval. If internval=n,The output image will contain every nth pixel from the original image, both vertically and horizontally. So the number of pixels is reduced by n^2.
Returns:
The downsampled image.

cloneImage

public static java.awt.image.BufferedImage cloneImage(java.awt.image.BufferedImage in)
Clone an image. Not particularly fast.

Parameters:
in - The image to be cloned.
Returns:
An identical image.