Class ImageComparisonUtil
- java.lang.Object
-
- com.github.romankh3.image.comparison.ImageComparisonUtil
-
public final class ImageComparisonUtil extends java.lang.ObjectTools for theImageComparisonobject.
-
-
Constructor Summary
Constructors Constructor Description ImageComparisonUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static floatgetDifferencePercent(java.awt.image.BufferedImage img1, java.awt.image.BufferedImage img2)Return the difference in percent between two buffered images.static intpixelDiff(int rgb1, int rgb2)Compare two pixelsstatic java.awt.image.BufferedImagereadImageFromResources(java.lang.String path)Read image from the provided path.static java.awt.image.BufferedImageresize(java.awt.image.BufferedImage img, int newW, int newH)Resize image to new dimensions and return new image.static voidsaveImage(java.io.File pathFile, java.awt.image.BufferedImage image)Save image to the provided path.static java.awt.image.BufferedImagetoBufferedImage(java.awt.Image img)Convert image to buffered image.
-
-
-
Method Detail
-
readImageFromResources
public static java.awt.image.BufferedImage readImageFromResources(java.lang.String path) throws ImageComparisonExceptionRead image from the provided path.- Parameters:
path- the path where contains image.- Returns:
- the
BufferedImageobject of this specific image. - Throws:
ImageComparisonException- due to read the image from resources.
-
saveImage
public static void saveImage(java.io.File pathFile, java.awt.image.BufferedImage image) throws ImageComparisonExceptionSave image to the provided path.- Parameters:
pathFile- the path to the saving image.image- theBufferedImageobject of this specific image.- Throws:
ImageComparisonException- due to save image.
-
resize
public static java.awt.image.BufferedImage resize(java.awt.image.BufferedImage img, int newW, int newH)Resize image to new dimensions and return new image.- Parameters:
img- the object of the image to be resized.newW- the new width.newH- the new height.- Returns:
- resized
BufferedImageobject.
-
toBufferedImage
public static java.awt.image.BufferedImage toBufferedImage(java.awt.Image img)
Convert image to buffered image.- Parameters:
img- the object of the image to be converted to buffered image.- Returns:
- the converted buffered image.
-
getDifferencePercent
public static float getDifferencePercent(java.awt.image.BufferedImage img1, java.awt.image.BufferedImage img2)Return the difference in percent between two buffered images.- Parameters:
img1- the first image.img2- the second image.- Returns:
- difference percent.
-
pixelDiff
public static int pixelDiff(int rgb1, int rgb2)Compare two pixels- Parameters:
rgb1- the first rgbrgb2- the second rgn- Returns:
- the difference.
-
-