|
@@ -125,12 +125,11 @@ NICE::Vector ConvolutionFeature::getFeatureVector( const Example *example ) cons
|
|
NICE::MultiChannelImageT<double> * imgD = NULL;
|
|
NICE::MultiChannelImageT<double> * imgD = NULL;
|
|
imgD = & example->ce->getDChannel( CachedExample::D_EOH );
|
|
imgD = & example->ce->getDChannel( CachedExample::D_EOH );
|
|
|
|
|
|
- int xsize, ysize, x, y;
|
|
|
|
-
|
|
|
|
|
|
+ int xsize, ysize;
|
|
example->ce->getImageSize( xsize, ysize );
|
|
example->ce->getImageSize( xsize, ysize );
|
|
- x = example->x;
|
|
|
|
- y = example->y;
|
|
|
|
|
|
|
|
|
|
+ const int x = example->x;
|
|
|
|
+ const int y = example->y;
|
|
const int halfwsx = std::floor ( window_size_x / 2 );
|
|
const int halfwsx = std::floor ( window_size_x / 2 );
|
|
const int halfwsy = std::floor ( window_size_y / 2 );
|
|
const int halfwsy = std::floor ( window_size_y / 2 );
|
|
const int step = window_size_x*window_size_y;
|
|
const int step = window_size_x*window_size_y;
|
|
@@ -207,59 +206,34 @@ double ConvolutionFeature::val ( const Example *example ) const
|
|
NICE::MultiChannelImageT<double> * imgD = NULL;
|
|
NICE::MultiChannelImageT<double> * imgD = NULL;
|
|
imgD = & example->ce->getDChannel( CachedExample::D_EOH );
|
|
imgD = & example->ce->getDChannel( CachedExample::D_EOH );
|
|
|
|
|
|
- int xsize, ysize, x, y;
|
|
|
|
-
|
|
|
|
|
|
+ int xsize, ysize;
|
|
example->ce->getImageSize( xsize, ysize );
|
|
example->ce->getImageSize( xsize, ysize );
|
|
- x = example->x;
|
|
|
|
- y = example->y;
|
|
|
|
-
|
|
|
|
- const int colorStep = window_size_x*window_size_y;
|
|
|
|
- const int scalingSteps = 1;
|
|
|
|
|
|
|
|
- int halfwsx = std::floor ( window_size_x / 2 );
|
|
|
|
- int halfwsy = std::floor ( window_size_y / 2 );
|
|
|
|
- int wScale = 1;
|
|
|
|
|
|
+ const int x = example->x;
|
|
|
|
+ const int 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;
|
|
|
|
|
|
- for ( int s = 0; s < scalingSteps; s++ )
|
|
|
|
- {
|
|
|
|
- for ( int c = 0; c < numChannels; c++ )
|
|
|
|
|
|
+ int k = 1;
|
|
|
|
+ for ( int v = -halfwsy; v <= halfwsy; v++ )
|
|
|
|
+ for ( int u = -halfwsx; u <= halfwsx; u++, k++ )
|
|
{
|
|
{
|
|
- int paramIdx = 1;
|
|
|
|
- int pxIdx = 0;
|
|
|
|
- for ( int v = -halfwsy; v <= halfwsy; v++ )
|
|
|
|
- for ( int u = -halfwsx; u <= halfwsx; u++, pxIdx++ )
|
|
|
|
- {
|
|
|
|
- if (pxIdx % wScale == 0) paramIdx++;
|
|
|
|
-
|
|
|
|
- int colorShift = paramIdx + c*colorStep;
|
|
|
|
- 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
|
|
|
|
- && paramIdx < beta->size() )
|
|
|
|
- {
|
|
|
|
- val1 += imgD->get(x+uu,y+vv,c)
|
|
|
|
- * beta->operator [](colorShift)
|
|
|
|
- / wScale * wScale;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // increase scaling
|
|
|
|
- halfwsx *= 3;
|
|
|
|
- halfwsy *= 3;
|
|
|
|
- wScale *= 3;
|
|
|
|
- }
|
|
|
|
|
|
+ int uu = u;
|
|
|
|
+ int vv = v;
|
|
|
|
+ if (x+u < 0 || x+u >= xsize) uu=-u;
|
|
|
|
+ if (y+v < 0 || y+v >= ysize) vv=-v;
|
|
|
|
|
|
- // normalize scaling
|
|
|
|
- val1 /= (double)scalingSteps;
|
|
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
if (useSpatialPriors)
|
|
if (useSpatialPriors)
|
|
{
|
|
{
|