//-------------------------------------------------------------------------------- void ofxCvFloatImage::addWeighted( ofxCvGrayscaleImage& mom, float f ) { if( pushSetBothToTheirIntersectionROI(*this,mom) ) { convertGrayToFloat(mom.getCvImage(), cvImageTemp); cvAddWeighted( cvImageTemp, f, cvImage, 1.0f-f,0, cvImage ); popROI(); //restore prevoius ROI mom.popROI(); //restore prevoius ROI flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in addWeighted, ROI mismatch"); } }
//-------------------------------------------------------------------------------- void CPUImageFilter::operator = ( const ofxCvColorImage& _mom ) { // cast non-const, no worries, we will reverse any chages ofxCvColorImage& mom = const_cast<ofxCvColorImage&>(_mom); if( pushSetBothToTheirIntersectionROI(*this,mom) ) { cvCvtColor( mom.getCvImage(), cvImage, CV_RGB2GRAY ); popROI(); //restore prevoius ROI mom.popROI(); //restore prevoius ROI flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } }
//-------------------------------------------------------------------------------- void ofxCvFloatImage::operator = ( const ofxCvGrayscaleImage& _mom ) { // cast non-const, no worries, we will reverse any chages ofxCvGrayscaleImage& mom = const_cast<ofxCvGrayscaleImage&>(_mom); if( pushSetBothToTheirIntersectionROI(*this,mom) ) { convertGrayToFloat(mom.getCvImage(), cvImage); popROI(); //restore prevoius ROI mom.popROI(); //restore prevoius ROI flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } }
//-------------------------------------------------------------------------------- void ofxCvShortImage::operator = ( const ofxCvFloatImage& _mom ) { // cast non-const, no worries, we will reverse any chages ofxCvFloatImage& mom = const_cast<ofxCvFloatImage&>(_mom); if( pushSetBothToTheirIntersectionROI(*this,mom) ) { // map from 0-1 to 0-65535 cvConvertScale( mom.getCvImage(), cvImage, 65535, 0 ); popROI(); //restore prevoius ROI mom.popROI(); //restore prevoius ROI flagImageChanged(); } else { ofLog(OF_ERROR, "in =, ROI mismatch"); } }
//-------------------------------------------------------------------------------- void ofxCvColorImage::operator = ( const ofxCvColorImage& _mom ) { if(this != &_mom) { //check for self-assignment // cast non-const, no worries, we will reverse any chages ofxCvColorImage& mom = const_cast<ofxCvColorImage&>(_mom); if( pushSetBothToTheirIntersectionROI(*this,mom) ) { cvCopy( mom.getCvImage(), cvImage, 0 ); popROI(); //restore prevoius ROI mom.popROI(); //restore prevoius ROI flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } } else { ofLog(OF_LOG_WARNING, "in =, you are assigning a ofxCvColorImage to itself"); } }
//-------------------------------------------------------------------------------- void ofxCvFloatImage::operator *= ( ofxCvImage& mom ) { if( mom.getCvImage()->nChannels == cvImage->nChannels && mom.getCvImage()->depth == cvImage->depth ) { if( pushSetBothToTheirIntersectionROI(*this,mom) ) { cvMul( cvImage, mom.getCvImage(), cvImageTemp ); swapTemp(); popROI(); //restore prevoius ROI mom.popROI(); //restore prevoius ROI flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in *=, ROI mismatch"); } } else { ofLog(OF_LOG_ERROR, "in *=, images need to have matching type"); } }
//-------------------------------------------------------------------------------- void ofxCvColorImage::operator = ( const ofxCvFloatImage& _mom ) { // cast non-const, no worries, we will reverse any chages ofxCvFloatImage& mom = const_cast<ofxCvFloatImage&>(_mom); if( pushSetBothToTheirIntersectionROI(*this,mom) ) { if( cvGrayscaleImage == NULL ) { cvGrayscaleImage = cvCreateImage( cvSize(cvImage->width,cvImage->height), IPL_DEPTH_8U, 1 ); } cvSetImageROI(cvGrayscaleImage, cvRect(roiX,roiY,width,height)); cvConvertScale( mom.getCvImage(), cvGrayscaleImage, 1, 0 ); cvCvtColor( cvGrayscaleImage, cvImage, CV_GRAY2RGB ); popROI(); //restore prevoius ROI mom.popROI(); //restore prevoius ROI cvSetImageROI(cvGrayscaleImage, cvRect(roiX,roiY,width,height)); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } }
//-------------------------------------------------------------------------------- void ofxCvFloatImage::operator &= ( ofxCvImage& mom ) { if( mom.getCvImage()->nChannels == cvImage->nChannels && mom.getCvImage()->depth == cvImage->depth ) { if( pushSetBothToTheirIntersectionROI(*this,mom) ) { //this is doing it bit-wise; probably not what we want cvAnd( cvImage, mom.getCvImage(), cvImageTemp ); swapTemp(); popROI(); //restore prevoius ROI mom.popROI(); //restore prevoius ROI flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in &=, ROI mismatch"); } } else { ofLog(OF_LOG_ERROR, "in &=, images need to have matching type"); } }