orc.camera
Class ImageUtil

java.lang.Object
  extended by orc.camera.ImageUtil

public class ImageUtil
extends java.lang.Object

Useful image utilities.


Constructor Summary
ImageUtil()
           
 
Method Summary
static java.awt.image.BufferedImage channelSelect(java.awt.image.BufferedImage image, int channel)
           
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)
          Ensure an image is of the right format, converting it to the format if necessary.
static java.awt.image.BufferedImage ditherImageFloydSteinberg(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 ditherImageRandom(java.awt.image.BufferedImage in)
          Convert an arbitrary input image into a black and white dithered image (using random diffusion.) This produces relatively awful results compared to Floyd-Steinberg.
static java.awt.image.BufferedImage rgbToHsv(java.awt.image.BufferedImage image)
           
static java.awt.image.BufferedImage scaleImage(java.awt.image.BufferedImage in, int newwidth, int newheight)
          Scale an image.
 
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)
Ensure an image is of the right format, converting it to the format if necessary.

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.

ditherImageFloydSteinberg

public static java.awt.image.BufferedImage ditherImageFloydSteinberg(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.

ditherImageRandom

public static java.awt.image.BufferedImage ditherImageRandom(java.awt.image.BufferedImage in)
Convert an arbitrary input image into a black and white dithered image (using random diffusion.) This produces relatively awful results compared to Floyd-Steinberg.

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

scaleImage

public static java.awt.image.BufferedImage scaleImage(java.awt.image.BufferedImage in,
                                                      int newwidth,
                                                      int newheight)
Scale an image. The image is rerendered at a different scale, typically resulting in fairly good results at the expense of runtime performance.

Parameters:
in - The input image
newwidth - The width of the new iamge
newheight - The height of the new 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.

rgbToHsv

public static java.awt.image.BufferedImage rgbToHsv(java.awt.image.BufferedImage image)

channelSelect

public static java.awt.image.BufferedImage channelSelect(java.awt.image.BufferedImage image,
                                                         int channel)