             ext->orientation = th;
 
             nangles++;
+#ifdef LOWE_ORIENTATION_MAX
+            // Lowe wants at most 3 orientations at every extremum
             if (nangles > 2) break;
+#else // LOWE_ORIENTATION_MAX
+            // OpenCV and VLFeat allow 4 orientations at every extremum
+            if (nangles > 3) break;
+#endif // LOWE_ORIENTATION_MAX
         }
     }
 }

    float xcoord[ORI_NBINS];
    float yval[ORI_NBINS];

    int   maxbin[3];
    float y_max[3];

    #pragma unroll
    for( int i=0; i<3; i++ ) {
        maxbin[i] = 0;
        y_max[i] = -INFINITY;
    }

    for(int bin = 0; bin < ORI_NBINS; bin++) {
        int prev = bin - 1;
        if( prev < 0 ) prev = ORI_NBINS - 1;
        int next = bin + 1;
        if( next == ORI_NBINS ) next = 0;

        if( hist[bin] > max( hist[prev], hist[next] ) ) {
            const float num = 3.0f * hist[prev] - 4.0f * hist[bin] + hist[next];

                xcoord[bin] = prev + newbin;
                yval[bin]   = -(num*num) / (4.0f * denB) + hist[prev];

#ifdef LOWE_ORIENTATION_MAX
                if( yval[bin] > y_max[0] ) {
                    y_max[2]  = y_max[1];
                    y_max[1]  = y_max[0];
