Package net.sourceforge.lept4j.util
Class LeptUtils
java.lang.Object
net.sourceforge.lept4j.util.LeptUtils
public class LeptUtils
extends java.lang.Object
Various utility methods for Leptonica.
- 
Field Summary
- 
Constructor SummaryConstructors Constructor Description LeptUtils()
- 
Method SummaryModifier and Type Method Description static PixconvertImageToPix(java.awt.image.BufferedImage image)ConvertsBufferedImageto LeptonicaPix.static java.awt.image.BufferedImageconvertPixToImage(Pix pix)Converts LeptonicaPixtoBufferedImage.static Pixdespeckle(Pix pixs, java.lang.String selStr, int selSize)Reduces 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 PixremoveLines(Pix pixs)Removes horizontal lines from a grayscale image.
- 
Field Details- 
SEL_STR2public static final java.lang.String SEL_STR2HMT (with just misses) for speckle up to 2x2"oooo" "oC o" "o o" "oooo" - See Also:
- Constant Field Values
 
- 
SEL_STR3public static final java.lang.String SEL_STR3HMT (with just misses) for speckle up to 3x3"ooooo" "oC o" "o o" "o o" "ooooo" - See Also:
- Constant Field Values
 
 
- 
- 
Constructor Details- 
LeptUtilspublic LeptUtils()
 
- 
- 
Method Details- 
convertPixToImageConverts LeptonicaPixtoBufferedImage.- Parameters:
- pix- source pix
- Returns:
- BufferedImage output image
- Throws:
- java.io.IOException
 
- 
convertImageToPixConvertsBufferedImageto LeptonicaPix.- Parameters:
- image- source image
- Returns:
- Pix output pix
- Throws:
- java.io.IOException
 
- 
removeLinesRemoves 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
 
- 
despeckleReduces speckle noise in image. The algorithm is based on Leptonicaspeckle_reg.cexample demonstrating morphological method of removing speckle.- Parameters:
- pixs- input pix
- selStr- hit-miss sels in 2D layout; SEL_STR2 and SEL_STR3 are predefined values
- selSize- 2 for 2x2, 3 for 3x3
- Returns:
- pix with speckle removed
 
- 
disposePixDisposes of Pix resource.- Parameters:
- pix-
 
- 
disposepublic static void dispose(com.sun.jna.Structure resource)Disposes of Leptonica native resource.- Parameters:
- resource- A Leptonica object, such as- Pix,- Pixa,- Box,- Boxa,- PixColormap, etc.
 
 
-