c++ - Garbage values in matching two matrices (having double type values) -
c++ - Garbage values in matching two matrices (having double type values) -
i have 2 2d matrices consist of elements havingdouble
datatype. want match these values using formula
value = | (a[i][j] - b[i][j]) | / ( 1 + a[i][j] + b[i][j] )
my code:
double colorcorrelogram::correlogrammatching(double (&a)[num_colorbin][distance_range] , double (&b)[num_colorbin][distance_range]) { for(int i=0; i<num_colorbin; i++) { for(int j=0; j<distance_range; j++) { double value = ( (std::abs)( a[i][j] - b[i][j] ) ) / (1 + a[i][j] + b[i][j]); cout<<"\n( "<<a[i][j] <<" , " <<b[i][j]<<" )"<<" gave "<<value<<" "; } } homecoming 0; }
matrix - 1:
matrix - 2:
result:
problem:
why valuesnegative
in result, when have used std::abs
. there garbage values can seen in line-2 in results.
you have code in form
((std::abs)(double))/double
instead of
(std::abs)(double/double)
and std::abs doesn't work type conversion.
c++ opencv
Comments
Post a Comment