Package net.sourceforge.tess4j.util
Class ImageHelper
- java.lang.Object
-
- net.sourceforge.tess4j.util.ImageHelper
-
public class ImageHelper extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ImageHelper()
-
Method Summary
Modifier and Type Method Description static java.awt.image.BufferedImage
cloneImage(java.awt.image.BufferedImage bi)
Clones an image.static java.awt.image.BufferedImage
convertImage2Binary(java.awt.image.BufferedImage image)
Deprecated.As of release 1.1, renamed toconvertImageToBinary(BufferedImage image)
static java.awt.image.BufferedImage
convertImageToBinary(java.awt.image.BufferedImage image)
A simple method to convert an image to binary or B/W image.static java.awt.image.BufferedImage
convertImageToGrayscale(java.awt.image.BufferedImage image)
A simple method to convert an image to gray scale.static java.awt.Image
getClipboardImage()
Gets an image from Clipboard.static java.awt.image.BufferedImage
getScaledInstance(java.awt.image.BufferedImage image, int targetWidth, int targetHeight)
Convenience method that returns a scaled instance of the providedBufferedImage
.static javax.imageio.IIOImage
getScaledInstance(javax.imageio.IIOImage iioSource, float scale)
Convenience method that returns a scaled instance of the providedIIOImage
.static java.awt.image.BufferedImage
getSubImage(java.awt.image.BufferedImage image, int x, int y, int width, int height)
A replacement for the standardBufferedImage.getSubimage
method.static java.awt.image.BufferedImage
invertImageColor(java.awt.image.BufferedImage image)
Inverts image color.static java.awt.image.BufferedImage
rotateImage(java.awt.image.BufferedImage image, double angle)
Rotates an image.
-
-
-
Method Detail
-
getScaledInstance
public static java.awt.image.BufferedImage getScaledInstance(java.awt.image.BufferedImage image, int targetWidth, int targetHeight)
Convenience method that returns a scaled instance of the providedBufferedImage
.- Parameters:
image
- the original image to be scaledtargetWidth
- the desired width of the scaled instance, in pixelstargetHeight
- the desired height of the scaled instance, in pixels- Returns:
- a scaled version of the original
BufferedImage
-
getScaledInstance
public static javax.imageio.IIOImage getScaledInstance(javax.imageio.IIOImage iioSource, float scale)
Convenience method that returns a scaled instance of the providedIIOImage
.- Parameters:
iioSource
- the original image to be scaledscale
- the desired scale- Returns:
- a scaled version of the original
IIOImage
-
getSubImage
public static java.awt.image.BufferedImage getSubImage(java.awt.image.BufferedImage image, int x, int y, int width, int height)
A replacement for the standardBufferedImage.getSubimage
method.- Parameters:
image
-x
- the X coordinate of the upper-left corner of the specified rectangular regiony
- the Y coordinate of the upper-left corner of the specified rectangular regionwidth
- the width of the specified rectangular regionheight
- the height of the specified rectangular region- Returns:
- a BufferedImage that is the subimage of
image
.
-
convertImageToBinary
public static java.awt.image.BufferedImage convertImageToBinary(java.awt.image.BufferedImage image)
A simple method to convert an image to binary or B/W image.- Parameters:
image
- input image- Returns:
- a monochrome image
-
convertImage2Binary
@Deprecated public static java.awt.image.BufferedImage convertImage2Binary(java.awt.image.BufferedImage image)
Deprecated.As of release 1.1, renamed toconvertImageToBinary(BufferedImage image)
A simple method to convert an image to binary or B/W image.- Parameters:
image
- input image- Returns:
- a monochrome image
-
convertImageToGrayscale
public static java.awt.image.BufferedImage convertImageToGrayscale(java.awt.image.BufferedImage image)
A simple method to convert an image to gray scale.- Parameters:
image
- input image- Returns:
- a monochrome image
-
invertImageColor
public static java.awt.image.BufferedImage invertImageColor(java.awt.image.BufferedImage image)
Inverts image color.- Parameters:
image
- input image- Returns:
- an inverted-color image
-
rotateImage
public static java.awt.image.BufferedImage rotateImage(java.awt.image.BufferedImage image, double angle)
Rotates an image.- Parameters:
image
- the original imageangle
- the degree of rotation- Returns:
- a rotated image
-
getClipboardImage
public static java.awt.Image getClipboardImage()
Gets an image from Clipboard.- Returns:
- image
-
cloneImage
public static java.awt.image.BufferedImage cloneImage(java.awt.image.BufferedImage bi)
Clones an image. http://stackoverflow.com/questions/3514158/how-do-you-clone-a-bufferedimage- Parameters:
bi
-- Returns:
-
-