 
     const float val = tex2DLayered<float>( dog, x+1, y+1, level );
 
-#ifdef VLFEAT_LIKE_THRESHOLD
-    if( fabs( val ) < 0.8 * 2.0 * d_threshold ) return false;
-#else // VLFEAT_LIKE_THRESHOLD
-    if( fabs( val ) < d_threshold ) return false;
-#endif // VLFEAT_LIKE_THRESHOLD
+    ModeFunctions<sift_mode> f;
+    if( not f.first_contrast_ok( val ) ) return false;
 
     if( not is_extremum( dog, x, y, level-1 ) ) {
         return false;

        /* If the translation of the keypoint is big, move the keypoint
         * and re-iterate the computation. Otherwise we are all set.
         */
        if( fabs(d.z) < 0.5f && fabs(d.y) < 0.5f && fabs(d.x) < 0.5f) break;

        float3 t;

        t.x = ((d.x >= 0.5f && n.x < width-2) ?  1 : 0 )
             + ((d.x <= -0.5f && n.x > 1)? -1 : 0 );

        t.y = ((d.y >= 0.5f && n.y < height-2)  ?  1 : 0 )
             + ((d.y <= -0.5f && n.y > 1) ? -1 : 0 );

        t.z = ((d.z >= 0.5f && n.z < maxlevel-1)  ?  1 : 0 )
             + ((d.z <= -0.5f && n.z > 1) ? -1 : 0 );

        n.x += t.x;
        n.y += t.y;
        n.z += t.z;
    } /* go to next iter */

    /* ensure convergence of interpolation */
    if (iter >= MAX_ITERATIONS) {
#ifdef PRINT_EXTREMA_DEBUG_INFO
        printf("Found an extremum at %d %d (o=%d) - rejected in refinement, was moved to l:%d (%d,%d)\n", x+1, y+1, debug_octave, n.z, n.x, n.y );
#endif // PRINT_EXTREMA_DEBUG_INFO
        return false;
    }

    // float contr   = v + 0.5f * (D.x * d.x + D.y * d.y + D.z * d.z);
    float contr   = v + scalbnf( D.x * d.x + D.y * d.y + D.z * d.z , -1 );

{
    Extremum ec;

    bool indicator = find_extrema_in_dog_v6_sub<vlfeat_mode>( dog, debug_octave, level, width, height, maxlevel, ec );

    uint32_t write_index = extrema_count<HEIGHT>( indicator, extrema_counter );

