Package net.sourceforge.lept4j.util
Class LeptUtils
java.lang.Object
net.sourceforge.lept4j.util.LeptUtils
Various utility methods for Leptonica.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PixconvertImageToPix(BufferedImage image)ConvertsBufferedImageto LeptonicaPix.static BufferedImageconvertPixToImage(Pix pix)Converts LeptonicaPixtoBufferedImage.static PixReduces speckle noise in image.static voiddispose(com.sun.jna.Structure resource)Disposes of Leptonica native resource.static voiddisposePix(Pix pix)Disposes of Pix resource.static StringremoveLines(String imageFile)Remove lines from image file.static PixremoveLines(Pix pixs)Removes horizontal lines from a grayscale image.
-
Field Details
-
SEL_STR2
HMT (with just misses) for speckle up to 2x2"oooo" "oC o" "o o" "oooo"
- See Also:
- Constant Field Values
-
SEL_STR3
HMT (with just misses) for speckle up to 3x3"ooooo" "oC o" "o o" "o o" "ooooo"
- See Also:
- Constant Field Values
-
-
Constructor Details
-
LeptUtils
public LeptUtils()
-
-
Method Details
-
convertPixToImage
Converts LeptonicaPixtoBufferedImage.- Parameters:
pix- source pix- Returns:
- BufferedImage output image
- Throws:
IOException
-
convertImageToPix
ConvertsBufferedImageto LeptonicaPix.- Parameters:
image- source image- Returns:
- Pix output pix
- Throws:
IOException
-
removeLines
Removes horizontal lines from a grayscale image. The algorithm is based on Leptonicalineremoval.cexample.
To remove vertical lines, rotate the image 90 degrees first, remove the horizontal lines, and rotate it back.- Parameters:
pixs- input pix- Returns:
- pix with lines removed
- See Also:
- line-removal
-
removeLines
Remove lines from image file.- Parameters:
imageFile- input image- Returns:
- temporary multi-page TIFF image file
- Throws:
IOException
-
despeckle
Reduces speckle noise in image. The algorithm is based on Leptonicaspeckle_reg.cexample demonstrating morphological method of removing speckle.- Parameters:
pixs- input pixselStr- hit-miss sels in 2D layout; SEL_STR2 and SEL_STR3 are predefined valuesselSize- 2 for 2x2, 3 for 3x3- Returns:
- pix with speckle removed
-
disposePix
Disposes of Pix resource.- Parameters:
pix-
-
dispose
public static void dispose(com.sun.jna.Structure resource)Disposes of Leptonica native resource.- Parameters:
resource- A Leptonica object, such asPix,Pixa,Box,Boxa,PixColormap, etc.
-