 
     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;

    /* reject condition: tr(H)^2/det(H) < (r+1)^2/r */
    if( edgeval >= (d_edge_limit+1.0f)*(d_edge_limit+1.0f)/d_edge_limit ) {
#ifdef PRINT_EXTREMA_DEBUG_INFO
        printf("Found an extremum at %d %d (o=%d) - edge tresh failed\n", x+1, y+1, debug_octave );
#endif // PRINT_EXTREMA_DEBUG_INFO
        return false;
    }

{
    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 );

