Package de.hsh.graja.util
Class ImageUtils
- java.lang.Object
-
- de.hsh.graja.util.ImageUtils
-
public class ImageUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description ImageUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BufferedImage
calcDiffImage(BufferedImage img1, BufferedImage img2)
calculate an image with differences in gray scales.static int
countDiffPixels(BufferedImage image1, BufferedImage image2)
Counts number of pixels that differ between the two images.static BufferedImage
createBufferedImage(int width, int height, Color background)
Creates a memory buffer for a buffered image.static BufferedImage
createBufferedImage(String base64Data, int width, int height, int imageType)
Creates a buffered image from base64 encoded bytes.
-
-
-
Method Detail
-
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.
-
-