From f947c2eb969515f00e81352662df4c783214db1f Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Sun, 9 Oct 2011 18:15:13 +0000 Subject: [PATCH] new, much simpler and SSE2-optimized implementation of FAST --- modules/features2d/src/fast.cpp | 6252 ++----------------------------- 1 file changed, 286 insertions(+), 5966 deletions(-) diff --git a/modules/features2d/src/fast.cpp b/modules/features2d/src/fast.cpp index a9e5d0ad6..ac163845e 100644 --- a/modules/features2d/src/fast.cpp +++ b/modules/features2d/src/fast.cpp @@ -46,2936 +46,6 @@ The references are: namespace cv { -static int fast9CornerScore(const unsigned char* p, const int pixel[], int bstart) -{ - int bmin = bstart; - int bmax = 255; - int b = (bmax + bmin)/2; - - /*Compute the score using binary search*/ - for(;;) - { - int cb = *p + b; - int c_b= *p - b; - - if( p[pixel[0]] > cb) - if( p[pixel[1]] > cb) - if( p[pixel[2]] > cb) - if( p[pixel[3]] > cb) - if( p[pixel[4]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - goto is_a_corner; - else - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[7]] < c_b) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[14]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[6]] < c_b) - if( p[pixel[15]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[13]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[14]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[13]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[5]] < c_b) - if( p[pixel[14]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[12]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[13]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[14]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[6]] < c_b) - goto is_a_corner; - else - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[12]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[6]] < c_b) - goto is_a_corner; - else - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[4]] < c_b) - if( p[pixel[13]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[11]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[12]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[13]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[5]] < c_b) - goto is_a_corner; - else - if( p[pixel[14]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[11]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[5]] < c_b) - goto is_a_corner; - else - if( p[pixel[14]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[3]] < c_b) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[4]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[10]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[4]] < c_b) - goto is_a_corner; - else - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[4]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[10]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[4]] < c_b) - goto is_a_corner; - else - if( p[pixel[13]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[2]] < c_b) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[4]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[3]] > cb) - if( p[pixel[4]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[9]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[4]] < c_b) - if( p[pixel[3]] < c_b) - goto is_a_corner; - else - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[4]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[3]] > cb) - if( p[pixel[4]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[9]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[4]] < c_b) - if( p[pixel[3]] < c_b) - goto is_a_corner; - else - if( p[pixel[12]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[1]] < c_b) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[4]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[3]] > cb) - if( p[pixel[4]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[2]] > cb) - if( p[pixel[3]] > cb) - if( p[pixel[4]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[8]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[4]] < c_b) - if( p[pixel[3]] < c_b) - if( p[pixel[2]] < c_b) - goto is_a_corner; - else - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[4]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[3]] > cb) - if( p[pixel[4]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[2]] > cb) - if( p[pixel[3]] > cb) - if( p[pixel[4]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[8]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[4]] < c_b) - if( p[pixel[3]] < c_b) - if( p[pixel[2]] < c_b) - goto is_a_corner; - else - if( p[pixel[11]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[0]] < c_b) - if( p[pixel[1]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[4]] > cb) - if( p[pixel[3]] > cb) - if( p[pixel[2]] > cb) - goto is_a_corner; - else - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[4]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[3]] < c_b) - if( p[pixel[4]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[2]] < c_b) - if( p[pixel[3]] < c_b) - if( p[pixel[4]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[1]] < c_b) - if( p[pixel[2]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[4]] > cb) - if( p[pixel[3]] > cb) - goto is_a_corner; - else - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[4]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[3]] < c_b) - if( p[pixel[4]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[2]] < c_b) - if( p[pixel[3]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[4]] > cb) - goto is_a_corner; - else - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[4]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[3]] < c_b) - if( p[pixel[4]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[5]] > cb) - goto is_a_corner; - else - if( p[pixel[14]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[13]] < c_b) - if( p[pixel[11]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[12]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[4]] < c_b) - if( p[pixel[5]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[6]] > cb) - goto is_a_corner; - else - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[14]] < c_b) - if( p[pixel[12]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[13]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[6]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[5]] < c_b) - if( p[pixel[6]] > cb) - if( p[pixel[15]] < c_b) - if( p[pixel[13]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[14]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[6]] < c_b) - if( p[pixel[7]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - goto is_a_corner; - else - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[13]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[12]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[6]] > cb) - goto is_a_corner; - else - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[5]] > cb) - goto is_a_corner; - else - if( p[pixel[14]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[4]] > cb) - goto is_a_corner; - else - if( p[pixel[13]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[4]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[9]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[4]] > cb) - if( p[pixel[3]] > cb) - goto is_a_corner; - else - if( p[pixel[12]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[4]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[3]] < c_b) - if( p[pixel[4]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[8]] > cb) - if( p[pixel[7]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[10]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[4]] > cb) - if( p[pixel[3]] > cb) - if( p[pixel[2]] > cb) - goto is_a_corner; - else - if( p[pixel[11]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[4]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[3]] < c_b) - if( p[pixel[4]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[2]] < c_b) - if( p[pixel[3]] < c_b) - if( p[pixel[4]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[7]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[7]] > cb) - if( p[pixel[8]] > cb) - if( p[pixel[9]] > cb) - if( p[pixel[6]] > cb) - if( p[pixel[5]] > cb) - if( p[pixel[4]] > cb) - if( p[pixel[3]] > cb) - if( p[pixel[2]] > cb) - if( p[pixel[1]] > cb) - goto is_a_corner; - else - if( p[pixel[10]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] > cb) - if( p[pixel[11]] > cb) - if( p[pixel[12]] > cb) - if( p[pixel[13]] > cb) - if( p[pixel[14]] > cb) - if( p[pixel[15]] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if( p[pixel[7]] < c_b) - if( p[pixel[8]] < c_b) - if( p[pixel[9]] < c_b) - if( p[pixel[6]] < c_b) - if( p[pixel[5]] < c_b) - if( p[pixel[4]] < c_b) - if( p[pixel[3]] < c_b) - if( p[pixel[2]] < c_b) - if( p[pixel[1]] < c_b) - goto is_a_corner; - else - if( p[pixel[10]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if( p[pixel[10]] < c_b) - if( p[pixel[11]] < c_b) - if( p[pixel[12]] < c_b) - if( p[pixel[13]] < c_b) - if( p[pixel[14]] < c_b) - if( p[pixel[15]] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - - is_a_corner: - bmin=b; - goto end_if; - - is_not_a_corner: - bmax=b; - goto end_if; - - end_if: - - if(bmin == bmax - 1 || bmin == bmax) - return bmin; - b = (bmin + bmax) / 2; - } -} - static void makeOffsets(int pixel[], int row_stride) { pixel[0] = 0 + row_stride * 3; @@ -2994,3064 +64,314 @@ static void makeOffsets(int pixel[], int row_stride) pixel[13] = -3 + row_stride * 1; pixel[14] = -2 + row_stride * 2; pixel[15] = -1 + row_stride * 3; -} +} - -static void fast9ComputeScores(const Mat& img, vector& corners, vector& scores, int b) -{ - int pixel[16]; - makeOffsets(pixel, (int)img.step); - size_t n, num_corners = corners.size(); - - scores.resize(num_corners); - for(n=0; n < num_corners; n++) - scores[n] = fast9CornerScore(&img.at(corners[n]), pixel, b); -} - - -static void fast9Detect(const Mat& img, vector& ret_corners, int b) +static int cornerScore(const uchar* ptr, const int pixel[], int threshold) { - int xsize = img.cols, ysize = img.rows; - int pixel[16]; - makeOffsets(pixel, (int)img.step); - - ret_corners.reserve(512); - - for(int y=3; y < ysize - 3; y++) - for(int x=3; x < xsize - 3; x++) - { - const uchar* p = &img.at(y,x); + const int K = 8, N = 16 + K + 1; + int k, v = ptr[0]; + short d[N]; + for( k = 0; k < N; k++ ) + d[k] = (short)(v - ptr[pixel[k]]); + +#if CV_SSE2 + __m128i q0 = _mm_set1_epi16(-1000), q1 = _mm_set1_epi16(1000); + for( k = 0; k < 16; k += 8 ) + { + __m128i v0 = _mm_loadu_si128((__m128i*)(d+k+1)); + __m128i v1 = _mm_loadu_si128((__m128i*)(d+k+2)); + __m128i a = _mm_min_epi16(v0, v1); + __m128i b = _mm_max_epi16(v0, v1); + v0 = _mm_loadu_si128((__m128i*)(d+k+3)); + a = _mm_min_epi16(a, v0); + b = _mm_max_epi16(b, v0); + v0 = _mm_loadu_si128((__m128i*)(d+k+4)); + a = _mm_min_epi16(a, v0); + b = _mm_max_epi16(b, v0); + v0 = _mm_loadu_si128((__m128i*)(d+k+5)); + a = _mm_min_epi16(a, v0); + b = _mm_max_epi16(b, v0); + v0 = _mm_loadu_si128((__m128i*)(d+k+6)); + a = _mm_min_epi16(a, v0); + b = _mm_max_epi16(b, v0); + v0 = _mm_loadu_si128((__m128i*)(d+k+7)); + a = _mm_min_epi16(a, v0); + b = _mm_max_epi16(b, v0); + v0 = _mm_loadu_si128((__m128i*)(d+k+8)); + a = _mm_min_epi16(a, v0); + b = _mm_max_epi16(b, v0); + v0 = _mm_loadu_si128((__m128i*)(d+k)); + q0 = _mm_max_epi16(q0, _mm_min_epi16(a, v0)); + q1 = _mm_min_epi16(q1, _mm_max_epi16(b, v0)); + v0 = _mm_loadu_si128((__m128i*)(d+k+9)); + q0 = _mm_max_epi16(q0, _mm_min_epi16(a, v0)); + q1 = _mm_min_epi16(q1, _mm_max_epi16(b, v0)); + } + q0 = _mm_max_epi16(q0, _mm_sub_epi16(_mm_setzero_si128(), q1)); + q0 = _mm_max_epi16(q0, _mm_unpackhi_epi64(q0, q0)); + q0 = _mm_max_epi16(q0, _mm_srli_si128(q0, 4)); + q0 = _mm_max_epi16(q0, _mm_srli_si128(q0, 2)); + threshold = (short)_mm_cvtsi128_si32(q0) - 1; +#else + int a0 = threshold; + for( k = 0; k < 16; k += 2 ) + { + int a = std::min((int)d[k+1], (int)d[k+2]); + a = std::min(a, (int)d[k+3]); + if( a <= a0 ) + continue; + a = std::min(a, (int)d[k+4]); + a = std::min(a, (int)d[k+5]); + a = std::min(a, (int)d[k+6]); + a = std::min(a, (int)d[k+7]); + a = std::min(a, (int)d[k+8]); + a0 = std::max(a0, std::min(a, (int)d[k])); + a0 = std::max(a0, std::min(a, (int)d[k+9])); + } + + int b0 = -a0; + for( k = 0; k < 16; k += 2 ) + { + int b = std::max((int)d[k+1], (int)d[k+2]); + b = std::max(b, (int)d[k+3]); + b = std::max(b, (int)d[k+4]); + b = std::max(b, (int)d[k+5]); + if( b >= b0 ) + continue; + b = std::max(b, (int)d[k+6]); + b = std::max(b, (int)d[k+7]); + b = std::max(b, (int)d[k+8]); - int cb = *p + b; - int c_b= *p - b; - if(p[pixel[0]] > cb) - if(p[pixel[1]] > cb) - if(p[pixel[2]] > cb) - if(p[pixel[3]] > cb) - if(p[pixel[4]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - {} - else - if(p[pixel[15]] > cb) - {} - else - continue; - else if(p[pixel[7]] < c_b) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else if(p[pixel[14]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else if(p[pixel[6]] < c_b) - if(p[pixel[15]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - {} - else - continue; - else if(p[pixel[13]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[14]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else if(p[pixel[13]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[5]] < c_b) - if(p[pixel[14]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[15]] > cb) - {} - else - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[12]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[13]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[14]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[6]] < c_b) - {} - else - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[12]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[6]] < c_b) - {} - else - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[4]] < c_b) - if(p[pixel[13]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[11]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[12]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[13]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[5]] < c_b) - {} - else - if(p[pixel[14]] < c_b) - {} - else - continue; - else - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; + b0 = std::min(b0, std::max(b, (int)d[k])); + b0 = std::min(b0, std::max(b, (int)d[k+9])); + } + + threshold = -b0-1; +#endif + +#if 0 + // check that with the computed "threshold" the pixel is still a corner + // and that with the increased-by-1 "threshold" the pixel is not a corner anymore + for( int delta = 0; delta <= 1; delta++ ) + { + int v0 = std::min(ptr[0] + threshold + delta, 255); + int v1 = std::max(ptr[0] - threshold - delta, 0); + int c0 = 0, c1 = 0; + + for( int k = 0; k < N; k++ ) + { + int x = ptr[pixel[k]]; + if(x > v0) + { + if( ++c0 > K ) + break; + c1 = 0; + } + else if( x < v1 ) + { + if( ++c1 > K ) + break; + c0 = 0; + } else - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[11]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[5]] < c_b) - {} - else - if(p[pixel[14]] < c_b) - {} - else - continue; - else - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[3]] < c_b) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[4]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[10]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[4]] < c_b) - {} - else - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - {} - else - continue; - else - continue; - else - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[4]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[10]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[4]] < c_b) - {} - else - if(p[pixel[13]] < c_b) - {} - else - continue; - else - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - {} - else - continue; - else - continue; - else - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[2]] < c_b) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[4]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[3]] > cb) - if(p[pixel[4]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[9]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[4]] < c_b) - if(p[pixel[3]] < c_b) - {} - else - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - {} - else - continue; - else - continue; - else - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[4]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[3]] > cb) - if(p[pixel[4]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[9]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[4]] < c_b) - if(p[pixel[3]] < c_b) - {} - else - if(p[pixel[12]] < c_b) - {} - else - continue; - else - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - {} - else - continue; - else - continue; - else - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[1]] < c_b) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - {} - else - continue; - else - continue; - else - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[4]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[3]] > cb) - if(p[pixel[4]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[2]] > cb) - if(p[pixel[3]] > cb) - if(p[pixel[4]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[8]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[4]] < c_b) - if(p[pixel[3]] < c_b) - if(p[pixel[2]] < c_b) - {} - else - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - {} - else - continue; - else - continue; - else - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - {} - else - continue; - else - continue; - else - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[4]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[3]] > cb) - if(p[pixel[4]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[2]] > cb) - if(p[pixel[3]] > cb) - if(p[pixel[4]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[8]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[4]] < c_b) - if(p[pixel[3]] < c_b) - if(p[pixel[2]] < c_b) - {} - else - if(p[pixel[11]] < c_b) - {} - else - continue; - else - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - {} - else - continue; - else - continue; - else - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[0]] < c_b) - if(p[pixel[1]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[4]] > cb) - if(p[pixel[3]] > cb) - if(p[pixel[2]] > cb) - {} - else - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - {} - else - continue; - else - continue; - else - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - {} - else - continue; - else - continue; - else - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[4]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[3]] < c_b) - if(p[pixel[4]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[2]] < c_b) - if(p[pixel[3]] < c_b) - if(p[pixel[4]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[1]] < c_b) - if(p[pixel[2]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[4]] > cb) - if(p[pixel[3]] > cb) - {} - else - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - {} - else - continue; - else - continue; - else - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[4]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[3]] < c_b) - if(p[pixel[4]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[2]] < c_b) - if(p[pixel[3]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[4]] > cb) - {} - else - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - {} - else - continue; - else - continue; - else - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[4]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[3]] < c_b) - if(p[pixel[4]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[5]] > cb) - {} - else - if(p[pixel[14]] > cb) - {} - else - continue; - else - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[13]] < c_b) - if(p[pixel[11]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[12]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[4]] < c_b) - if(p[pixel[5]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[6]] > cb) - {} - else - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[14]] < c_b) - if(p[pixel[12]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[13]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[6]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[5]] < c_b) - if(p[pixel[6]] > cb) - if(p[pixel[15]] < c_b) - if(p[pixel[13]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[14]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - {} - else - continue; - else - continue; - else - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[6]] < c_b) - if(p[pixel[7]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - {} - else - if(p[pixel[15]] < c_b) - {} - else - continue; - else - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - if(p[pixel[13]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[12]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[6]] > cb) - {} - else - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[11]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[5]] > cb) - {} - else - if(p[pixel[14]] > cb) - {} - else - continue; - else - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[4]] > cb) - {} - else - if(p[pixel[13]] > cb) - {} - else - continue; - else - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - {} - else - continue; - else - continue; - else - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[4]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[9]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[4]] > cb) - if(p[pixel[3]] > cb) - {} - else - if(p[pixel[12]] > cb) - {} - else - continue; - else - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - {} - else - continue; - else - continue; - else - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[4]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[3]] < c_b) - if(p[pixel[4]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[8]] > cb) - if(p[pixel[7]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[10]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[4]] > cb) - if(p[pixel[3]] > cb) - if(p[pixel[2]] > cb) - {} - else - if(p[pixel[11]] > cb) - {} - else - continue; - else - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - {} - else - continue; - else - continue; - else - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - {} - else - continue; - else - continue; - else - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[4]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[3]] < c_b) - if(p[pixel[4]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[2]] < c_b) - if(p[pixel[3]] < c_b) - if(p[pixel[4]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[7]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[7]] > cb) - if(p[pixel[8]] > cb) - if(p[pixel[9]] > cb) - if(p[pixel[6]] > cb) - if(p[pixel[5]] > cb) - if(p[pixel[4]] > cb) - if(p[pixel[3]] > cb) - if(p[pixel[2]] > cb) - if(p[pixel[1]] > cb) - {} - else - if(p[pixel[10]] > cb) - {} - else - continue; - else - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - {} - else - continue; - else - continue; - else - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] > cb) - if(p[pixel[11]] > cb) - if(p[pixel[12]] > cb) - if(p[pixel[13]] > cb) - if(p[pixel[14]] > cb) - if(p[pixel[15]] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(p[pixel[7]] < c_b) - if(p[pixel[8]] < c_b) - if(p[pixel[9]] < c_b) - if(p[pixel[6]] < c_b) - if(p[pixel[5]] < c_b) - if(p[pixel[4]] < c_b) - if(p[pixel[3]] < c_b) - if(p[pixel[2]] < c_b) - if(p[pixel[1]] < c_b) - {} - else - if(p[pixel[10]] < c_b) - {} - else - continue; - else - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - {} - else - continue; - else - continue; - else - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(p[pixel[10]] < c_b) - if(p[pixel[11]] < c_b) - if(p[pixel[12]] < c_b) - if(p[pixel[13]] < c_b) - if(p[pixel[14]] < c_b) - if(p[pixel[15]] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - ret_corners.push_back(Point(x,y)); + { + c0 = c1 = 0; + } } + CV_Assert( (delta == 0 && std::max(c0, c1) > K) || + (delta == 1 && std::max(c0, c1) <= K) ); + } +#endif + return threshold; +} + } -/* This defines non-strict maxima */ -#define Compare(X, Y) ((X)>=(Y)) - -/* This is a fast, integer only, sparse nonmaximal suppression. */ -/* probably only useful for FAST corner detection */ -static void fastNonmaxSuppression(const vector& corners, - const vector& scores, - vector& ret_nonmax) + +void cv::FAST(const Mat& img, std::vector& keypoints, int threshold, bool nonmax_suppression) { - int i, j, num_corners = (int)corners.size(); + const int K = 8, N = 16 + K + 1; + int i, j, k, pixel[N]; + makeOffsets(pixel, img.step); + for(k = 16; k < N; k++) + pixel[k] = pixel[k - 16]; - // Point above points (roughly) to the pixel above the one of interest, if there is a feature there. - int point_above = 0; - int point_below = 0; + keypoints.clear(); - ret_nonmax.clear(); - if(num_corners < 1) - return; + threshold = std::min(std::max(threshold, 0), 255); - /* Find where each row begins - (the corners are output in raster scan order). A beginning of -1 signifies - that there are no corners on that row. */ - int last_row = corners[num_corners-1].y; - vector row_start(last_row+1); +#if CV_SSE2 + __m128i delta = _mm_set1_epi8(128), t = _mm_set1_epi8(threshold), K16 = _mm_set1_epi8(K); +#endif + uchar threshold_tab[512]; + for( i = -255; i <= 255; i++ ) + threshold_tab[i+255] = (uchar)(i < -threshold ? 1 : i > threshold ? 2 : 0); - for(i=0; i < last_row+1; i++) - row_start[i] = -1; - - int prev_row = -1; - for(i=0; i< num_corners; i++) - if(corners[i].y != prev_row) - { - row_start[corners[i].y] = i; - prev_row = corners[i].y; - } - - ret_nonmax.reserve(num_corners); - for(i = 0; i < num_corners; i++) + AutoBuffer _buf((img.cols+16)*3*(sizeof(int) + sizeof(uchar)) + 128); + uchar* buf[3]; + buf[0] = _buf; buf[1] = buf[0] + img.cols; buf[2] = buf[1] + img.cols; + int* cpbuf[3]; + cpbuf[0] = (int*)alignPtr(buf[2] + img.cols, sizeof(int)) + 1; + cpbuf[1] = cpbuf[0] + img.cols + 1; + cpbuf[2] = cpbuf[1] + img.cols + 1; + memset(buf[0], 0, img.cols*3); + + for(i = 3; i < img.rows-2; i++) { - int score = scores[i]; - Point pos = corners[i]; - - // Check left - if(i > 0 && corners[i-1].x == pos.x-1 && corners[i-1].y == pos.y && Compare(scores[i-1], score)) - continue; - - // Check right - if(i < num_corners-1 && corners[i+1].x == pos.x+1 && corners[i+1].y == pos.y && Compare(scores[i+1], score)) - continue; - - bool suppressed = false; - // Check above (if there is a valid row above) - if(pos.y != 0 && row_start[pos.y - 1] != -1) + const uchar* ptr = img.ptr(i) + 3; + uchar* curr = buf[(i - 3)%3]; + int* cornerpos = cpbuf[(i - 3)%3]; + memset(curr, 0, img.cols); + int ncorners = 0; + + if( i < img.rows - 3 ) { - // Make sure that current point_above is one row above. - if(corners[point_above].y < pos.y - 1) - point_above = row_start[pos.y-1]; - - // Make point_above point to the first of the pixels above the current point, if it exists. - for(; corners[point_above].y < pos.y && corners[point_above].x < pos.x - 1; point_above++) - ; - - for(j=point_above; corners[j].y < pos.y && corners[j].x <= pos.x + 1; j++) + j = 3; + #if CV_SSE2 + for(; j < img.cols - 16 - 3; j += 16, ptr += 16) { - int x = corners[j].x; - if( (x == pos.x - 1 || x ==pos.x || x == pos.x+1) && Compare(scores[j], score)) + __m128i m0, m1; + __m128i v0 = _mm_loadu_si128((const __m128i*)ptr); + __m128i v1 = _mm_xor_si128(_mm_subs_epu8(v0, t), delta); + v0 = _mm_xor_si128(_mm_adds_epu8(v0, t), delta); + + __m128i x0 = _mm_sub_epi8(_mm_loadu_si128((const __m128i*)(ptr + pixel[0])), delta); + __m128i x1 = _mm_sub_epi8(_mm_loadu_si128((const __m128i*)(ptr + pixel[4])), delta); + __m128i x2 = _mm_sub_epi8(_mm_loadu_si128((const __m128i*)(ptr + pixel[8])), delta); + __m128i x3 = _mm_sub_epi8(_mm_loadu_si128((const __m128i*)(ptr + pixel[12])), delta); + m0 = _mm_and_si128(_mm_cmpgt_epi8(x0, v0), _mm_cmpgt_epi8(x1, v0)); + m1 = _mm_and_si128(_mm_cmpgt_epi8(v1, x0), _mm_cmpgt_epi8(v1, x1)); + m0 = _mm_or_si128(m0, _mm_and_si128(_mm_cmpgt_epi8(x1, v0), _mm_cmpgt_epi8(x2, v0))); + m1 = _mm_or_si128(m1, _mm_and_si128(_mm_cmpgt_epi8(v1, x1), _mm_cmpgt_epi8(v1, x2))); + m0 = _mm_or_si128(m0, _mm_and_si128(_mm_cmpgt_epi8(x2, v0), _mm_cmpgt_epi8(x3, v0))); + m1 = _mm_or_si128(m1, _mm_and_si128(_mm_cmpgt_epi8(v1, x2), _mm_cmpgt_epi8(v1, x3))); + m0 = _mm_or_si128(m0, _mm_and_si128(_mm_cmpgt_epi8(x3, v0), _mm_cmpgt_epi8(x0, v0))); + m1 = _mm_or_si128(m1, _mm_and_si128(_mm_cmpgt_epi8(v1, x3), _mm_cmpgt_epi8(v1, x0))); + m0 = _mm_or_si128(m0, m1); + int mask = _mm_movemask_epi8(m0); + if( mask == 0 ) + continue; + if( (mask & 255) == 0 ) { - suppressed = true; - break; + j -= 8; + ptr -= 8; + continue; + } + + __m128i c0 = _mm_setzero_si128(), c1 = c0, max0 = c0, max1 = c0; + for( k = 0; k < N; k++ ) + { + __m128i x = _mm_xor_si128(_mm_loadu_si128((const __m128i*)(ptr + pixel[k])), delta); + m0 = _mm_cmpgt_epi8(x, v0); + m1 = _mm_cmpgt_epi8(v1, x); + + c0 = _mm_and_si128(_mm_sub_epi8(c0, m0), m0); + c1 = _mm_and_si128(_mm_sub_epi8(c1, m1), m1); + + max0 = _mm_max_epu8(max0, c0); + max1 = _mm_max_epu8(max1, c1); + } + + max0 = _mm_max_epu8(max0, max1); + int m = _mm_movemask_epi8(_mm_cmpgt_epi8(max0, K16)); + + for( k = 0; m > 0 && k < 16; k++, m >>= 1 ) + if(m & 1) + { + cornerpos[ncorners++] = j+k; + if(nonmax_suppression) + curr[j+k] = cornerScore(ptr+k, pixel, threshold); + } + } + #endif + for( ; j < img.cols - 3; j++, ptr++ ) + { + int v = ptr[0]; + const uchar* tab = &threshold_tab[0] - v + 255; + int d = tab[ptr[pixel[0]]] | tab[ptr[pixel[8]]]; + + if( d == 0 ) + continue; + + d &= tab[ptr[pixel[2]]] | tab[ptr[pixel[10]]]; + d &= tab[ptr[pixel[4]]] | tab[ptr[pixel[12]]]; + d &= tab[ptr[pixel[6]]] | tab[ptr[pixel[14]]]; + + if( d == 0 ) + continue; + + d &= tab[ptr[pixel[1]]] | tab[ptr[pixel[9]]]; + d &= tab[ptr[pixel[3]]] | tab[ptr[pixel[11]]]; + d &= tab[ptr[pixel[5]]] | tab[ptr[pixel[13]]]; + d &= tab[ptr[pixel[7]]] | tab[ptr[pixel[15]]]; + + if( d & 1 ) + { + int vt = v - threshold, count = 0; + + for( k = 0; k < N; k++ ) + { + int x = ptr[pixel[k]]; + if(x < vt) + { + if( ++count > K ) + { + cornerpos[ncorners++] = j; + if(nonmax_suppression) + curr[j] = cornerScore(ptr, pixel, threshold); + break; + } + } + else + count = 0; + } + } + + if( d & 2 ) + { + int vt = v + threshold, count = 0; + + for( k = 0; k < N; k++ ) + { + int x = ptr[pixel[k]]; + if(x > vt) + { + if( ++count > K ) + { + cornerpos[ncorners++] = j; + if(nonmax_suppression) + curr[j] = cornerScore(ptr, pixel, threshold); + break; + } + } + else + count = 0; + } } } - if( suppressed ) - continue; } - - // Check below (if there is anything below) - if(pos.y != last_row && row_start[pos.y + 1] != -1 && point_below < num_corners) // Nothing below + + cornerpos[-1] = ncorners; + + if( i == 3 ) + continue; + + const uchar* prev = buf[(i - 4 + 3)%3]; + const uchar* pprev = buf[(i - 5 + 3)%3]; + cornerpos = cpbuf[(i - 4 + 3)%3]; + ncorners = cornerpos[-1]; + + for( k = 0; k < ncorners; k++ ) { - if(corners[point_below].y < pos.y + 1) - point_below = row_start[pos.y+1]; - - // Make point below point to one of the pixels belowthe current point, if it exists. - for(; point_below < num_corners && corners[point_below].y == pos.y+1 - && corners[point_below].x < pos.x - 1; point_below++) - ; - - for(j=point_below; j < num_corners && corners[j].y == pos.y+1 && corners[j].x <= pos.x + 1; j++) + j = cornerpos[k]; + int score = prev[j]; + if( !nonmax_suppression || + (score > prev[j+1] && score > prev[j-1] && + score > pprev[j-1] && score > pprev[j] && score > pprev[j+1] && + score > curr[j-1] && score > curr[j] && score > curr[j+1]) ) { - int x = corners[j].x; - if( (x == pos.x - 1 || x ==pos.x || x == pos.x+1) && Compare(scores[j],score)) - { - suppressed = true; - break; - } + keypoints.push_back(KeyPoint((float)j, (float)(i-1), 6.f, -1, (float)score)); } - if( suppressed ) - continue; } - - ret_nonmax.push_back(KeyPoint(corners[i], 6.f, -1.f, (float)score)); - } -} - -} - -void cv::FAST( const Mat& image, vector& keypoints, int threshold, bool nonmax_suppression ) -{ - CV_Assert(image.data && image.type() == CV_8U); - - vector corners; - fast9Detect(image, corners, threshold); - - if(nonmax_suppression) - { - vector scores; - fast9ComputeScores(image, corners, scores, threshold); - fastNonmaxSuppression(corners, scores, keypoints); - } - else - { - size_t i, n = corners.size(); - keypoints.resize(n); - for( i = 0; i < n; i++ ) - keypoints[i] = KeyPoint(corners[i], 6.f); } }