-void DeScratchMain::get_extrems_plane(int comp, int thresh)
-{
- uint8_t **rows = blurry->get_rows();
- int d = config.max_width, d1 = d+1, wd = src_w - d1;
- int bpp = 3, dsz = d * bpp;
- int asym = config.asymmetry;
- if( thresh > 0 ) { // black (low value) scratches
- for( int y=0; y<src_h; ++y ) {
- uint8_t *ip = inf + y*src_w;
- int x = 0;
- for( ; x<d1; ++x ) *ip++ = SD_NULL;
- uint8_t *dp = rows[y] + x*bpp + comp;
- for( ; x<wd; ++x,dp+=bpp ) {
- uint8_t *lp = dp-dsz, *rp = dp+dsz;
- *ip++ = (lp[0]-*dp) > thresh && (rp[0]-*dp) > thresh &&
- (abs(lp[-bpp]-rp[+bpp]) <= asym) &&
- ((lp[0]-lp[+bpp]) + (rp[0]-rp[-bpp]) >
- (lp[-bpp]-lp[0]) + (rp[bpp]-rp[0])) ?
- SD_EXTREM : SD_NULL; // sharp extremum found
- }
- for( ; x<src_w; ++x ) *ip++ = SD_NULL;
- }
- }
- else { // white (high value) scratches
- for( int y=0; y<src_h; ++y ) {
- uint8_t *ip = inf + y*src_w;
- int x = 0;
- for( ; x<d1; ++x ) *ip++ = SD_NULL;
- uint8_t *dp = rows[y] + x*bpp + comp;
- for( ; x<wd; ++x,dp+=bpp ) {
- uint8_t *lp = dp-dsz, *rp = dp+dsz;
- *ip++ = (lp[0]-*dp) < thresh && (rp[0]-*dp) < thresh &&
- (abs(lp[-bpp]-rp[+bpp]) <= asym) &&
- ((lp[0]-lp[+bpp]) + (rp[0]-rp[-bpp]) <
- (lp[-bpp]-lp[0]) + (rp[bpp]-rp[0])) ?
- SD_EXTREM : SD_NULL; // sharp extremum found
- }
- for( ; x<src_w; ++x ) *ip++ = SD_NULL;
- }
- }
-}
-
-//
-void DeScratchMain::remove_min_extrems_plane(int comp, int thresh)