Package de.hsh.graja.util
Class ImageUtils
java.lang.Object
de.hsh.graja.util.ImageUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.
-
Constructor Details
-
ImageUtils
public ImageUtils()
-
-
Method Details
-
createBufferedImage
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
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.
-