src/skew.c
l_int32
pixFindSkewSweepAndSearchScore(PIX        *pixs,
                               l_float32  *pangle,
                               l_float32  *pconf,
                               l_float32  *pendscore,
                               l_int32     redsweep,
                               l_int32     redsearch,
                               l_float32   sweepcenter,
                               l_float32   sweeprange,
                               l_float32   sweepdelta,
                               l_float32   minbsdelta)
{
    return pixFindSkewSweepAndSearchScorePivot(pixs, pangle, pconf, pendscore,
                                               redsweep, redsearch, 0.0,
                                               sweeprange, sweepdelta,
                                               minbsdelta,
                                               L_SHEAR_ABOUT_CORNER);
}
/*!
 *  pixFindSkewSweepAndSearchScore()
 *
 *      Input:  pixs  (1 bpp)
 *              &angle   (<return> angle required to deskew; in degrees)
 *              &conf    (<return> confidence given by ratio of max/min score)
 *              &endscore (<optional return> max score; use NULL to ignore)
 *              redsweep  (sweep reduction factor = 1, 2, 4 or 8)
 *              redsearch  (binary search reduction factor = 1, 2, 4 or 8;
 *                          and must not exceed redsweep)
 *              sweepcenter  (angle about which sweep is performed; in degrees)
 *              sweeprange   (half the full range, taken about sweepcenter;
 *                            in degrees)
 *              sweepdelta   (angle increment of sweep; in degrees)
 *              minbsdelta   (min binary search increment angle; in degrees)
 *      Return: 0 if OK, 1 on error or if angle measurment not valid
 *
 *  Notes:
 *      (1) This finds the skew angle, doing first a sweep through a set
 *          of equal angles, and then doing a binary search until convergence.
 *      (2) There are two built-in constants that determine if the 
 *          returned confidence is nonzero:
 *            - MIN_VALID_MAXSCORE (minimum allowed maxscore)
 *            - MINSCORE_THRESHOLD_CONSTANT (determines minimum allowed
 *                 minscore, by multiplying by (height * width^2)
 *          If either of these conditions is not satisfied, the returned
 *          confidence value will be zero.  The maxscore is optionally
 *          returned in this function to allow evaluation of the
 *          resulting angle by a method that is independent of the
 *          returned confidence value.
 *      (3) The larger the confidence value, the greater the probability
 *          that the proper alignment is given by the angle that maximizes
 *          variance.  It should be compared to a threshold, which depends
 *          on the application.  Values between 3.0 and 6.0 are common.
 *      (4) By default, the shear is about the UL corner.
 */


(1) This finds the skew angle, doing first a sweep through a set
of equal angles, and then doing a binary search until convergence.
(2) There are two built-in constants that determine if the
returned confidence is nonzero:
- MIN_VALID_MAXSCORE (minimum allowed maxscore)
- MINSCORE_THRESHOLD_CONSTANT (determines minimum allowed
minscore, by multiplying by (height * width^2)
If either of these conditions is not satisfied, the returned
confidence value will be zero.  The maxscore is optionally
returned in this function to allow evaluation of the
resulting angle by a method that is independent of the
returned confidence value.
(3) The larger the confidence value, the greater the probability
that the proper alignment is given by the angle that maximizes
variance.  It should be compared to a threshold, which depends
on the application.
( 1 ) This finds the skew angle doing first a sweep through a set of equal angles and then doing a binary search until convergence . ( 2 ) There are two built - in constants that determine if the returned confidence is nonzero : - MIN_VALID_MAXSCORE ( minimum allowed maxscore ) - MINSCORE_THRESHOLD_CONSTANT ( determines minimum allowed minscore by multiplying by ( height * width^2 ) If either of these conditions is not satisfied the returned confidence value will be zero . The maxscore is optionally returned in this function to allow evaluation of the resulting angle by a method that is independent of the returned confidence value . ( 3 ) The larger the confidence value the greater the probability that the proper alignment is given by the angle that maximizes variance . It should be compared to a threshold which depends on the application .
l_int32
pixFindSkewSweepAndSearchScore(PIX        *pixs,
                               l_float32  *pangle,
                               l_float32  *pconf,
                               l_float32  *pendscore,
                               l_int32     redsweep,
                               l_int32     redsearch,
                               l_float32   sweepcenter,
                               l_float32   sweeprange,
                               l_float32   sweepdelta,
                               l_float32   minbsdelta)
{
    return pixFindSkewSweepAndSearchScorePivot(pixs, pangle, pconf, pendscore,
                                               redsweep, redsearch, 0.0,
                                               sweeprange, sweepdelta,
                                               minbsdelta,
                                               L_SHEAR_ABOUT_CORNER);
}
l_int32 pixFindSkewSweepAndSearchScore ( PIX * pixs , l_float32 * pangle , l_float32 * pconf , l_float32 * pendscore , l_int32 redsweep , l_int32 redsearch , l_float32 sweepcenter , l_float32 sweeprange , l_float32 sweepdelta , l_float32 minbsdelta ) { return pixFindSkewSweepAndSearchScorePivot ( pixs , pangle , pconf , pendscore , redsweep , redsearch , 0.0 , sweeprange , sweepdelta , minbsdelta , L_SHEAR_ABOUT_CORNER ) ; }
pixFindSkewSweepAndSearchScore()
      Input:  pixs  (1 bpp)
              &angle   (<return> angle required to deskew; in degrees)
              &conf    (<return> confidence given by ratio of max/min score)
              &endscore (<optional return> max score; use NULL to ignore)
              redsweep  (sweep reduction factor = 1, 2, 4 or 8)
              redsearch  (binary search reduction factor = 1, 2, 4 or 8;
                          and must not exceed redsweep)
              sweepcenter  (angle about which sweep is performed; in degrees)
              sweeprange   (half the full range, taken about sweepcenter;
                            in degrees)
              sweepdelta   (angle increment of sweep; in degrees)
              minbsdelta   (min binary search increment angle; in degrees)
      Return: 0 if OK, 1 on error or if angle measurment not valid
pixFindSkewSweepAndSearchScore () Input : pixs ( 1 bpp ) &angle ( <return > angle required to deskew ; in degrees ) &conf ( <return > confidence given by ratio of max / min score ) &endscore ( <optional return > max score ; use NULL to ignore ) redsweep ( sweep reduction factor = 1 2 4 or 8 ) redsearch ( binary search reduction factor = 1 2 4 or 8 ; and must not exceed redsweep ) sweepcenter ( angle about which sweep is performed ; in degrees ) sweeprange ( half the full range taken about sweepcenter ; in degrees ) sweepdelta ( angle increment of sweep ; in degrees ) minbsdelta ( min binary search increment angle ; in degrees ) Return : 0 if OK 1 on error or if angle measurment not valid