Class ImageUtils

java.lang.Object
de.hsh.graja.util.ImageUtils

public class ImageUtils extends Object
  • Constructor Details

    • ImageUtils

      public ImageUtils()
  • Method Details

    • createBufferedImage

      public static BufferedImage createBufferedImage(int width, int height, Color background)
      Creates a memory buffer for a buffered image. In order to write pixels to the image you will have to do:
            int[] pixels = ((DataBufferInt) diff.getRaster().getDataBuffer()).getData();
            pixels[x+width*y]= new Color(r,g,b).getRGB();
       
      Parameters:
      width -
      height -
      background -
    • createBufferedImage

      public static BufferedImage createBufferedImage(String base64Data, int width, int height, int imageType) throws IOException
      Creates a buffered image from base64 encoded bytes.
      Parameters:
      width -
      height -
      imageType -
      Throws:
      IOException
    • countDiffPixels

      public static int countDiffPixels(BufferedImage image1, BufferedImage image2)
      Counts number of pixels that differ between the two images.
      Parameters:
      image1 -
      image2 -
    • calcDiffImage

      public static BufferedImage calcDiffImage(BufferedImage img1, BufferedImage img2) throws IllegalArgumentException
      calculate an image with differences in gray scales. Both images must have equal sizes. The difference is calculate as a gray scale of the DeltaE (CIE76) metric, applied directly in the RGB space.
      Parameters:
      img1 -
      img2 -
      Throws:
      IllegalArgumentException - thrown, when the images' sizes do not match.