|
@@ -14,6 +14,11 @@ using namespace OBJREC;
|
|
|
|
|
|
using namespace NICE;
|
|
|
|
|
|
+/* Convolutional feature consists of shift parameter beta[0] and the
|
|
|
+ convolutional mask, which is stored in the rest of the parameter vector
|
|
|
+ beta */
|
|
|
+
|
|
|
+
|
|
|
/** simple constructor */
|
|
|
ConvolutionFeature::ConvolutionFeature ( )
|
|
|
{
|
|
@@ -69,8 +74,9 @@ void ConvolutionFeature::initializeParameterVector()
|
|
|
{
|
|
|
if (window_size_x > 0 && window_size_y > 0)
|
|
|
{
|
|
|
- beta_length = window_size_x*window_size_y;
|
|
|
- beta = new NICE::Vector( beta_length, (1.0/beta_length) );
|
|
|
+ beta_length = window_size_x*window_size_y + 1;
|
|
|
+ beta = new NICE::Vector( beta_length, (1.0/(double)(beta_length-1) ) );
|
|
|
+ beta[0] = 1;
|
|
|
}
|
|
|
else
|
|
|
std::cerr << "ConvolutionFeature::initializeVector: Size of window is Zero! Could not initialize..." << std::endl;
|
|
@@ -86,7 +92,7 @@ NICE::Vector ConvolutionFeature::getParameterVector() const
|
|
|
/** return feature vector */
|
|
|
NICE::Vector ConvolutionFeature::getFeatureVector( const Example *example ) const
|
|
|
{
|
|
|
- NICE::Vector vec(window_size_x*window_size_y, 0.0);;
|
|
|
+ NICE::Vector vec(window_size_x*window_size_y + 1, 1.0);;
|
|
|
|
|
|
const NICE::MultiChannelImageT<int> & img =
|
|
|
example->ce->getIChannel( CachedExample::I_GRAYVALUES );
|
|
@@ -100,7 +106,7 @@ NICE::Vector ConvolutionFeature::getFeatureVector( const Example *example ) cons
|
|
|
int halfwsx = std::floor ( window_size_x / 2 );
|
|
|
int halfwsy = std::floor ( window_size_y / 2 );
|
|
|
|
|
|
- int k = 0;
|
|
|
+ int k = 1;
|
|
|
for ( int v = -halfwsy; v <= halfwsy; v++ )
|
|
|
for ( int u = -halfwsx; u <= halfwsx; u++ )
|
|
|
{
|
|
@@ -135,12 +141,20 @@ void ConvolutionFeature::setParameterVector( const Vector & vec )
|
|
|
if ( beta->size() == vec.size() )
|
|
|
{
|
|
|
int i = 0;
|
|
|
+ double sum = 0.0;
|
|
|
for ( NICE::Vector::iterator it = beta->begin();
|
|
|
it != beta->end(); ++it, i++ )
|
|
|
{
|
|
|
*it = vec[i];
|
|
|
+ sum = vec[i];
|
|
|
}
|
|
|
- beta->normalizeL2();
|
|
|
+
|
|
|
+ // Normalize only kernel parameters
|
|
|
+ double betaZero = vec[0];
|
|
|
+ sum -= betaZero;
|
|
|
+ beta->operator/= (sum);
|
|
|
+ beta->operator[](0) = betaZero;
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
std::cerr << "ConvolutionFeature::setParameterVector: Vector sizes do not match! Could not update parameter vector..." << std::endl;
|
|
@@ -166,7 +180,7 @@ double ConvolutionFeature::val ( const Example *example ) const
|
|
|
int halfwsx = std::floor ( window_size_x / 2 );
|
|
|
int halfwsy = std::floor ( window_size_y / 2 );
|
|
|
|
|
|
- int k = 0;
|
|
|
+ int k = 1;
|
|
|
double val1 = 0.0;
|
|
|
for ( int v = -halfwsy; v <= halfwsy; v++ )
|
|
|
for ( int u = -halfwsx; u <= halfwsx; u++, k++ )
|
|
@@ -185,7 +199,7 @@ double ConvolutionFeature::val ( const Example *example ) const
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return std::floor(val1);
|
|
|
+ return val1;
|
|
|
}
|
|
|
|
|
|
/** creature feature pool */
|