|
@@ -120,12 +120,13 @@ NICE::Vector ConvolutionFeature::getParameterVector() const
|
|
|
}
|
|
|
|
|
|
/** return feature vector */
|
|
|
-NICE::Vector ConvolutionFeature::getFeatureVector( const Example *example ) const
|
|
|
+void ConvolutionFeature::getFeatureVector(
|
|
|
+ const Example *example,
|
|
|
+ NICE::Vector & vec ) const
|
|
|
{
|
|
|
- NICE::Vector vec(paramsLength, 1.0);
|
|
|
-
|
|
|
NICE::MultiChannelImageT<double> * imgD = NULL;
|
|
|
imgD = & example->ce->getDChannel( CachedExample::D_EOH );
|
|
|
+ double** data = imgD->getDataPointer();
|
|
|
|
|
|
int xsize, ysize;
|
|
|
example->ce->getImageSize( xsize, ysize );
|
|
@@ -134,27 +135,22 @@ NICE::Vector ConvolutionFeature::getFeatureVector( const Example *example ) cons
|
|
|
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;
|
|
|
+ //const int step = window_size_x*window_size_y;
|
|
|
|
|
|
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 < vec.size() )
|
|
|
+ for ( int c = 0; c < numChannels; c++)
|
|
|
+ for ( int v = -halfwsy; v <= halfwsy; v++ )
|
|
|
+ for ( int u = -halfwsx; u <= halfwsx; u++, k++ )
|
|
|
{
|
|
|
- for ( int c = 0; c < numChannels; c++)
|
|
|
- vec[k+c*step] = imgD->get(x+uu,y+vv,c);
|
|
|
+ int uu = u;
|
|
|
+ int vv = v;
|
|
|
+ if (x+u < 0 || x+u >= xsize) uu=-u;
|
|
|
+ if (y+v < 0 || y+v >= ysize) vv=-v;
|
|
|
+
|
|
|
+ //vec[k] = imgD->get(x+uu,y+vv,c);
|
|
|
+ vec[k] = data[c][(x+uu)+(y+vv)*xsize];
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
if (useSpatialPriors)
|
|
|
{
|
|
@@ -162,7 +158,6 @@ NICE::Vector ConvolutionFeature::getFeatureVector( const Example *example ) cons
|
|
|
vec[paramsLength-1] = (double)y/(double)ysize;
|
|
|
}
|
|
|
|
|
|
- return vec;
|
|
|
}
|
|
|
|
|
|
/** return length of parameter vector */
|
|
@@ -217,7 +212,8 @@ double ConvolutionFeature::val ( const Example *example ) const
|
|
|
return val1;
|
|
|
}
|
|
|
|
|
|
- NICE::Vector featVec = getFeatureVector ( example );
|
|
|
+ NICE::Vector featVec (paramsLength, 1.0);
|
|
|
+ getFeatureVector ( example, featVec );
|
|
|
|
|
|
// for ( int i = 0; i < featVec.size(); i++ )
|
|
|
// val1 += featVec[i] * params->operator [](i);
|