org.neuroph.imgrec
Class ImageUtilities
- java.lang.Object
-
- org.neuroph.imgrec.ImageUtilities
-
public class ImageUtilities extends java.lang.ObjectContains various utility methods used for OCR.
-
-
Constructor Summary
Constructors Constructor and Description ImageUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.awt.image.BufferedImageblackAndGrayCleaning(java.awt.image.BufferedImage image)This method cleans input image by replacing all pixels with RGB values from -4473925 (gray) to -1 (white) with white pixels and from -4473925 (gray) to -16777216 (black) with black pixelsstatic java.awt.image.BufferedImageblackAndLightGrayCleaning(java.awt.image.BufferedImage image)This method cleans input image by replacing all pixels with RGB values from -3092272 (light gray) to -1 (white) with white pixels and from -3092272 (light gray) to -16777216 (black) with black pixelsstatic java.awt.image.BufferedImageblackAndWhiteCleaning(java.awt.image.BufferedImage image)This method cleans input image by replacing all non black pixels with white pixels TODO: some should be used herestatic java.awt.image.BufferedImagecolorCleaning(java.awt.image.BufferedImage image, int RGBcolor)This method cleans input image by replacing all pixels with RGB values from RGBcolor input (the input color) to -1 (white) with white pixels and from RGBcolor input (the input color) to -16777216 (black) with black pixelsstatic intcolorToRGB(int alpha, int red, int green, int blue)static java.awt.image.BufferedImagecropImage(java.awt.image.BufferedImage image, int x1, int y1, int x2, int y2)Crops (returns subimage) of specified input image at specified points.static java.util.Map<java.lang.String,FractionRgbData>getFractionRgbDataForImages(java.util.HashMap<java.lang.String,java.awt.image.BufferedImage> imagesData)Returns RGB data for all input imagesstatic java.awt.image.BufferedImageloadAndCleanImage(java.io.File file)This method loads the input Image and returns the cleaned versionstatic java.awt.image.BufferedImageloadImage(java.io.File file)Loads image from the file.static java.awt.image.BufferedImageresizeImage(java.awt.image.BufferedImage image, int width, int height)Resize image to specified dimensionsstatic ImageresizeImage(Image image, int width, int height)static voidsave(java.awt.image.BufferedImage image, java.lang.String filename, java.lang.String type)static java.awt.image.BufferedImagetrimImage(java.awt.image.BufferedImage imageToTrim)This method trims the input image and returns it as a BufferedImage
-
-
-
Method Detail
-
blackAndWhiteCleaning
public static java.awt.image.BufferedImage blackAndWhiteCleaning(java.awt.image.BufferedImage image)
This method cleans input image by replacing all non black pixels with white pixels TODO: some should be used here- Parameters:
image- - input image that will be cleaned- Returns:
- - cleaned input image as BufferedImage
-
blackAndGrayCleaning
public static java.awt.image.BufferedImage blackAndGrayCleaning(java.awt.image.BufferedImage image)
This method cleans input image by replacing all pixels with RGB values from -4473925 (gray) to -1 (white) with white pixels and from -4473925 (gray) to -16777216 (black) with black pixels- Parameters:
image- - input image that will be cleaned- Returns:
- - cleaned input image as BufferedImage
-
blackAndLightGrayCleaning
public static java.awt.image.BufferedImage blackAndLightGrayCleaning(java.awt.image.BufferedImage image)
This method cleans input image by replacing all pixels with RGB values from -3092272 (light gray) to -1 (white) with white pixels and from -3092272 (light gray) to -16777216 (black) with black pixels- Parameters:
image- - input image that will be cleaned- Returns:
- - cleaned input image as BufferedImage
-
colorCleaning
public static java.awt.image.BufferedImage colorCleaning(java.awt.image.BufferedImage image, int RGBcolor)This method cleans input image by replacing all pixels with RGB values from RGBcolor input (the input color) to -1 (white) with white pixels and from RGBcolor input (the input color) to -16777216 (black) with black pixels- Parameters:
image- - input image that will be cleanedRGBcolor- - input RGB value of wanted color as reference for celaning- Returns:
- - cleaned input image as BufferedImage
-
loadAndCleanImage
public static java.awt.image.BufferedImage loadAndCleanImage(java.io.File file)
This method loads the input Image and returns the cleaned version- Parameters:
file- - input file that will be loaded as image- Returns:
- - return cleaned loaded image as BufferedImage
-
loadImage
public static java.awt.image.BufferedImage loadImage(java.io.File file)
Loads image from the file.- Parameters:
file- image file- Returns:
- loaded image
-
save
public static void save(java.awt.image.BufferedImage image, java.lang.String filename, java.lang.String type)
-
trimImage
public static java.awt.image.BufferedImage trimImage(java.awt.image.BufferedImage imageToTrim)
This method trims the input image and returns it as a BufferedImage- Parameters:
imageToTrim- input image that will be trimed- Returns:
- return trimed input image as BufferedImage
-
resizeImage
public static java.awt.image.BufferedImage resizeImage(java.awt.image.BufferedImage image, int width, int height)Resize image to specified dimensions- Parameters:
image- image to resizewidth- new image widthheight- new image height- Returns:
- resized image
-
cropImage
public static java.awt.image.BufferedImage cropImage(java.awt.image.BufferedImage image, int x1, int y1, int x2, int y2)Crops (returns subimage) of specified input image at specified points.- Parameters:
image- image to cropx1- top left x coordinatey1- top left y coordinatex2- bottom right x coordinatey2- bottom right y coordinate- Returns:
- image croped at specified points
-
getFractionRgbDataForImages
public static java.util.Map<java.lang.String,FractionRgbData> getFractionRgbDataForImages(java.util.HashMap<java.lang.String,java.awt.image.BufferedImage> imagesData)
Returns RGB data for all input images- Parameters:
imagesData- data map with characters as keys and charcter images as values- Returns:
- data map with characters as keys and image rgb data as values
-
colorToRGB
public static int colorToRGB(int alpha, int red, int green, int blue)
-
-
DMelt 3.0 © DataMelt by jWork.ORG