Forráskód Böngészése

ConvolutionFeature: added scaling ability

Sven Sickert 10 éve
szülő
commit
38d5791e0a

+ 39 - 20
features/fpfeatures/ConvolutionFeature.cpp

@@ -104,6 +104,11 @@ void ConvolutionFeature::initializeParameterVector()
                   << std::endl;
 }
 
+bool ConvolutionFeature::isColorMode() const
+{
+    return isColor;
+}
+
 /** return parameter vector */
 NICE::Vector ConvolutionFeature::getParameterVector() const
 {
@@ -207,29 +212,43 @@ double ConvolutionFeature::val ( const Example *example ) const
     x = example->x;
     y = example->y;
 
-    const int halfwsx = std::floor ( window_size_x / 2 );
-    const int halfwsy = std::floor ( window_size_y / 2 );
-    const int step = window_size_x*window_size_y;
+    const int colorStep = window_size_x*window_size_y;
+    const int scalingSteps = 1;
 
-    int k = 1;
-    for ( int v = -halfwsy; v <= halfwsy; v++ )
-        for ( int u = -halfwsx; u <= halfwsx; u++, k++ )
-        {
-            int uu = u;
-            int vv = v;
-            if (x+u < 0 || x+u >= xsize) uu=-u;
-            if (y+v < 0 || y+v >= ysize) vv=-v;
-            if ( x+uu > 0
-                 && x+uu < xsize
-                 && y+vv > 0
-                 && y+vv < ysize
-                 && k < beta->size() )
-            {
-                for ( int c = 0; c < numChannels; c++ )
-                    val1 += imgD->get(x+uu,y+vv,c) * beta->operator [](k+c*step);
+    int halfwsx = std::floor ( window_size_x / 2 );
+    int halfwsy = std::floor ( window_size_y / 2 );
+    int wScale = 3;
 
+    for ( int s = 0; s < scalingSteps; s++ )
+    {
+        int k = 1;
+        for ( int v = -halfwsy; v <= halfwsy; v++ )
+            for ( int u = -halfwsx; u <= halfwsx; u++, k++ )
+            {
+                int uu = u;
+                int vv = v;
+                if (x+u < 0 || x+u >= xsize) uu=-u;
+                if (y+v < 0 || y+v >= ysize) vv=-v;
+                if ( x+uu > 0
+                     && x+uu < xsize
+                     && y+vv > 0
+                     && y+vv < ysize
+                     && k < beta->size() )
+                {
+                    for ( int c = 0; c < numChannels; c++ )
+                        val1 += imgD->get(x+uu,y+vv,c) * beta->operator [](k+c*colorStep);
+
+                }
             }
-        }
+
+        // increase scaling
+        halfwsx *= 2;
+        halfwsy *= 2;
+        wScale *= 2;
+    }
+
+    // normalize scaling
+    val1 /= (double)scalingSteps;
 
     if (useSpatialPriors)
     {

+ 6 - 0
features/fpfeatures/ConvolutionFeature.h

@@ -72,6 +72,12 @@ class ConvolutionFeature : public Feature
     //                      FEATURE STUFF
     ///////////////////// ///////////////////// /////////////////////
 
+    /**
+     * @brief return isColor variable
+     * @return isColor
+     */
+    bool isColorMode () const;
+
     /**
      * @brief return parameter vector
      * @return parameter vector