This is a relatively minor bug which affects an assignment operators in ofxCvGrayscaleImage.
In the following the cvConvertScale line is wrong:
void ofxCvGrayscaleImage::operator = ( ofxCvFloatImage& mom ) {
if( mom.width == width && mom.height == height ) {
cvConvertScale( mom.getCvImage(), cvImage, 1.0f/255.0f, 0);
} else {
cout << "error in =, images are different sizes" << endl;
}
}
it should be:
cvConvertScale( mom.getCvImage(), cvImage, 1.0f, 0);
or for brevity ( and I also read speed optimization) simply:
cvConvert( mom.getCvImage(), cvImage );
We also might want to change addWeighted to:
void ofxCvFloatImage::addWeighted( ofxCvGrayscaleImage& mom, float f ) {
if( mom.width == width && mom.height == height ) {
IplImage* cvTemp = cvCreateImage( cvSize(width,height), IPL_DEPTH_32F, 1 );
//cvConvertScale( mom.getCvImage(), cvTemp, 1, 0 );
cvConvert( mom.getCvImage(), cvTemp );
cvAddWeighted( cvTemp, f, cvImage, 1.0f-f,0, cvImageTemp );
swapTemp();
cvReleaseImage( &cvTemp );
} else {
cout << "error in addWeighted, images are different sizes" << endl;
}
}
And ofxCvFloatImage::getPixels should probably also use cvConvert instead of cvConvertScale.