Class ImageHelper

java.lang.Object
net.sourceforge.tess4j.util.ImageHelper

public class ImageHelper extends Object
  • Constructor Details

    • ImageHelper

      public ImageHelper()
  • Method Details

    • getScaledInstance

      public static BufferedImage getScaledInstance(BufferedImage image, int targetWidth, int targetHeight)
      Convenience method that returns a scaled instance of the provided BufferedImage.
      Parameters:
      image - the original image to be scaled
      targetWidth - the desired width of the scaled instance, in pixels
      targetHeight - the desired height of the scaled instance, in pixels
      Returns:
      a scaled version of the original BufferedImage
    • getScaledInstance

      public static IIOImage getScaledInstance(IIOImage iioSource, float scale)
      Convenience method that returns a scaled instance of the provided IIOImage.
      Parameters:
      iioSource - the original image to be scaled
      scale - the desired scale
      Returns:
      a scaled version of the original IIOImage
    • getSubImage

      public static BufferedImage getSubImage(BufferedImage image, int x, int y, int width, int height)
      A replacement for the standard BufferedImage.getSubimage method.
      Parameters:
      image -
      x - the X coordinate of the upper-left corner of the specified rectangular region
      y - the Y coordinate of the upper-left corner of the specified rectangular region
      width - the width of the specified rectangular region
      height - the height of the specified rectangular region
      Returns:
      a BufferedImage that is the subimage of image.
    • convertImageToBinary

      public static BufferedImage convertImageToBinary(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 BufferedImage convertImage2Binary(BufferedImage image)
      Deprecated.
      As of release 1.1, renamed to convertImageToBinary(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 BufferedImage convertImageToGrayscale(BufferedImage image)
      A simple method to convert an image to gray scale.
      Parameters:
      image - input image
      Returns:
      a monochrome image
    • invertImageColor

      public static BufferedImage invertImageColor(BufferedImage image)
      Inverts image color.
      Parameters:
      image - input image
      Returns:
      an inverted-color image
    • rotateImage

      public static BufferedImage rotateImage(BufferedImage image, double angle)
      Rotates an image.
      Parameters:
      image - the original image
      angle - the degree of rotation
      Returns:
      a rotated image
    • getClipboardImage

      public static Image getClipboardImage()
      Gets an image from Clipboard.
      Returns:
      image
    • cloneImage

      public static BufferedImage cloneImage(BufferedImage bi)
      Clones an image. http://stackoverflow.com/questions/3514158/how-do-you-clone-a-bufferedimage
      Parameters:
      bi -
      Returns: