-
public class SkewImage rotation and skew detection methods.
-
-
Field Summary
Fields Modifier and Type Field Description public final static floatSWEEP_RANGEpublic final static floatSWEEP_DELTApublic final static intSWEEP_REDUCTIONpublic final static intSEARCH_REDUCTIONpublic final static floatSEARCH_MIN_DELTA
-
Method Summary
Modifier and Type Method Description static floatfindSkew(Pix pixs)Finds and returns the skew angle using default parameters. static floatfindSkew(Pix pixs, float sweepRange, float sweepDelta, int sweepReduction, int searchReduction, float searchMinDelta)Finds and returns the skew angle, doing first a sweep through a set ofequal angles, and then doing a binary search until convergence. static Pixdeskew(Pix pixs, Array<float> result)Finds the skew angle and deskews the image using default parameters. static Pixdeskew(Pix pixs, int sweepReduction, float sweepRange, float sweepDelta, int searchReduction, int threshold, Array<float> result)Finds the skew angle and deskews the image. -
-
Method Detail
-
findSkew
static float findSkew(Pix pixs)
Finds and returns the skew angle using default parameters.
- Parameters:
pixs- Input pix (1 bpp).
-
findSkew
static float findSkew(Pix pixs, float sweepRange, float sweepDelta, int sweepReduction, int searchReduction, float searchMinDelta)
Finds and returns the skew angle, doing first a sweep through a set ofequal angles, and then doing a binary search until convergence.
Notes:
- In computing the differential line sum variance score, we sum theresult over scanlines, but we always skip:
- at least one scanline
- not more than 10% of the image height
- not more than 5% of the image width
- Parameters:
pixs- Input pix (1 bpp).sweepRange- Half the full search range, assumed about 0; indegrees.sweepDelta- Angle increment of sweep; in degrees.sweepReduction- Sweep reduction factor = 1, 2, 4 or 8.searchReduction- Binary search reduction factor = 1, 2, 4 or 8; andmust not exceed sweepReduction.searchMinDelta- Minimum binary search increment angle; in degrees.
- In computing the differential line sum variance score, we sum theresult over scanlines, but we always skip:
-
deskew
static Pix deskew(Pix pixs, Array<float> result)
Finds the skew angle and deskews the image using default parameters.
Notes:
- If the angle is large enough and there is sufficient confidence,it returns a deskewed image; otherwise, it returns a clone.
- Parameters:
pixs- Input pix (any depth).result- (Optional) A float array with at least two elements.At [0] will be angle required to deskew, in degrees;At [1] will be confidence as a ratio of max/min scores.
-
deskew
static Pix deskew(Pix pixs, int sweepReduction, float sweepRange, float sweepDelta, int searchReduction, int threshold, Array<float> result)
Finds the skew angle and deskews the image. Optionally gets the used angle and confidence.
Notes:
- This binarizes if necessary and finds the skew angle. If theangle is large enough and there is sufficient confidence,it returns a deskewed image; otherwise, it returns a clone.
- Typical values at 300 ppi for redSearch are 2 and 4.At 75 ppi, one should use redSearch = 1.
- Parameters:
pixs- Input pix (any depth).sweepReduction- For linear search: reduction factor = 1, 2 or 4;use 0 for default.sweepRange- In degrees in each direction from 0;use 0.0 for default.sweepDelta- In degrees; use 0.0 for default.searchReduction- For binary search: reduction factor = 1, 2 or 4;use 0 for default.threshold- For binarizing the image; use 0 for default.result- (Optional) A float array with at least two elements.At [0] will be angle required to deskew, in degrees;At [1] will be confidence as a ratio of max/min scores.
-
-
-
-