//-------------------------------------------------------------------------------- void ofxCvGrayscaleImage::operator = ( const ofxCvShortImage& _mom ) { // cast non-const, no worries, we will reverse any chages ofxCvShortImage& mom = const_cast<ofxCvShortImage&>(_mom); if( matchingROI(getROI(), mom.getROI()) ) { rangeMap( mom.getCvImage(), cvImage, 0, 65535.0f, 0, 255.0f ); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } }
//-------------------------------------------------------------------------------- void ofxCvColorImageAlpha::operator = ( const ofxCvGrayscaleImage& _mom ) { // cast non-const, no worries, we will reverse any chages ofxCvGrayscaleImage& mom = const_cast<ofxCvGrayscaleImage&>(_mom); if( matchingROI(getROI(), mom.getROI()) ) { cvCvtColor( mom.getCvImage(), cvImage, CV_GRAY2RGBA ); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } }
//-------------------------------------------------------------------------------- void setfilter::operator = ( const ofxCvColorImage& _mom ) { //-- for using a colorimage --// ofxCvColorImage& mom = const_cast<ofxCvColorImage&>(_mom); if( matchingROI(getROI(), mom.getROI()) ) { cvCvtColor( mom.getCvImage(), cvImage, CV_RGB2GRAY ); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } }
//-------------------------------------------------------------------------------- void setfilter::operator = ( const ofxCvFloatImage& _mom ) { //-- for using a floatimage --// ofxCvFloatImage& mom = const_cast<ofxCvFloatImage&>(_mom); if( matchingROI(getROI(), mom.getROI()) ) { cvConvert( mom.getCvImage(), cvImage ); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } }
//-------------------------------------------------------------------------------- void ofxCvColorImageAlpha::operator = ( const ofxCvColorImage& _mom ) { ofxCvColorImage& mom = const_cast<ofxCvColorImage&>(_mom); if( matchingROI(getROI(), mom.getROI()) ) { cvCopy( mom.getCvImage(), cvImage, 0 ); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } }
//-------------------------------------------------------------------------------- void ofxCvShortImage::addWeighted( ofxCvGrayscaleImage& mom, float f ) { if( !bAllocated ){ ofLog(OF_LOG_ERROR, "in addWeighted, image is not allocated"); return; } if( matchingROI(getROI(), mom.getROI()) ) { convertGrayToShort(mom.getCvImage(), cvImageTemp); cvAddWeighted( cvImageTemp, f, cvImage, 1.0f-f,0, cvImage ); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in addWeighted, ROI mismatch"); } }
//-------------------------------------------------------------------------------- void ofxCvGrayscaleImage::operator = ( const ofxCvGrayscaleImage& _mom ) { if(this != &_mom) { //check for self-assignment // cast non-const, no worries, we will reverse any chages ofxCvGrayscaleImage& mom = const_cast<ofxCvGrayscaleImage&>(_mom); if( matchingROI(getROI(), mom.getROI()) ) { cvCopy( mom.getCvImage(), cvImage, 0 ); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } } else { ofLog(OF_LOG_WARNING, "in =, you are assigning a ofxCvGrayscaleImage to itself"); } }
//-------------------------------------------------------------------------------- void ofxCvImage::operator &= ( ofxCvImage& mom ) { if( mom.getCvImage()->nChannels == cvImage->nChannels && mom.getCvImage()->depth == cvImage->depth ) { if( matchingROI(getROI(), mom.getROI()) ) { cvAnd( cvImage, mom.getCvImage(), cvImageTemp ); swapTemp(); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in &=, ROI mismatch"); } } else { ofLog(OF_LOG_ERROR, "in &=, images need to have matching type"); } }
//-------------------------------------------------------------------------------- void setfilter::operator = ( const ofxCvGrayscaleImage& _mom ) { //-- for using a grayimage --// if(this != &_mom) { ofxCvGrayscaleImage& mom = const_cast<ofxCvGrayscaleImage&>(_mom); if( matchingROI(getROI(), mom.getROI()) ) { cvCopy( mom.getCvImage(), cvImage, 0 ); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } } else { ofLog(OF_LOG_WARNING, "in =, you are assigning a ofxCvGrayscaleImage to itself"); } }
//-------------------------------------------------------------------------------- void ofxCvImage::operator *= ( ofxCvImage& mom ) { if( mom.getCvImage()->nChannels == cvImage->nChannels && mom.getCvImage()->depth == cvImage->depth ) { if( matchingROI(getROI(), mom.getROI()) ) { float scalef = 1.0f / 255.0f; cvMul( cvImage, mom.getCvImage(), cvImageTemp, scalef ); swapTemp(); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in *=, ROI mismatch"); } } else { ofLog(OF_LOG_ERROR, "in *=, images need to have matching type"); } }
//-------------------------------------------------------------------------------- void ofxCvFloatImage::operator &= ( ofxCvImage& mom ) { if( mom.getCvImage()->nChannels == cvImage->nChannels && mom.getCvImage()->depth == cvImage->depth ) { if( matchingROI(getROI(), mom.getROI()) ) { //this is doing it bit-wise; probably not what we want cvAnd( cvImage, mom.getCvImage(), cvImageTemp ); swapTemp(); 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 ofxCvShortImage& _mom ) { // cast non-const, no worries, we will reverse any chages ofxCvShortImage& mom = const_cast<ofxCvShortImage&>(_mom); if( matchingROI(getROI(), mom.getROI()) ) { if( cvGrayscaleImage == NULL ) { cvGrayscaleImage = cvCreateImage( cvSize(width,height), IPL_DEPTH_8U, 1 ); } ofRectangle roi = getROI(); setImageROI(cvGrayscaleImage, roi); rangeMap( mom.getCvImage(), cvGrayscaleImage, 0, 65535.0f, 0, 255.0f ); cvCvtColor( cvGrayscaleImage, cvImage, CV_GRAY2RGB ); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } }
//-------------------------------------------------------------------------------- void ofxCvGrayscaleImage::absDiff( ofxCvGrayscaleImage& mom ){ if( !mom.bAllocated ){ ofLog(OF_LOG_ERROR, "in absDiff, mom needs to be allocated"); return; } if( !bAllocated ){ ofLog(OF_LOG_NOTICE, "in absDiff, allocating to match dimensions"); allocate(mom.getWidth(), mom.getHeight()); } if( matchingROI(getROI(), mom.getROI()) ) { cvAbsDiff( cvImage, mom.getCvImage(), cvImageTemp ); swapTemp(); 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( mom.getWidth() == 0 || mom.getHeight() == 0 ){ ofLog(OF_LOG_ERROR, "in =, mom width or height is 0"); return; } if( !bAllocated ){ ofLog(OF_LOG_NOTICE, "in =, allocating to match dimensions"); allocate(mom.getWidth(), mom.getHeight()); } if( matchingROI(getROI(), mom.getROI()) ) { convertGrayToFloat(mom.getCvImage(), cvImage); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } }
//-------------------------------------------------------------------------------- void ofxCvGrayscaleImage::absDiff( ofxCvGrayscaleImage& mom ){ if( !mom.bAllocated ){ ofLogError("ofxCvGrayscaleImage") << "absDiff(): source image not allocated"; return; } if( !bAllocated ){ ofLogNotice("ofxCvGrayscaleImage") << "absDiff(): allocating to match dimensions: " << mom.getWidth() << " " << mom.getHeight(); allocate(mom.getWidth(), mom.getHeight()); } if( matchingROI(getROI(), mom.getROI()) ) { cvAbsDiff( cvImage, mom.getCvImage(), cvImageTemp ); swapTemp(); flagImageChanged(); } else { ofLogError("ofxCvGrayscaleImage") << "absDiff(): region of interest mismatch"; } }
//-------------------------------------------------------------------------------- void ofxCvGrayscaleImage::operator = ( const ofxCvShortImage& _mom ) { // cast non-const, no worries, we will reverse any changes ofxCvShortImage& mom = const_cast<ofxCvShortImage&>(_mom); if( mom.getWidth() == 0 || mom.getHeight() == 0 ){ ofLogError("ofxCvGrayscaleImage") << "operator=: source width and/or height are zero:" << mom.getWidth() << " " << mom.getHeight(); return; } if( !bAllocated ){ ofLogNotice("ofxCvGrayscaleImage") << "operator=: allocating to match dimensions: " << mom.getWidth() << " " << mom.getHeight(); allocate(mom.getWidth(), mom.getHeight()); } if( matchingROI(getROI(), mom.getROI()) ) { rangeMap( mom.getCvImage(), cvImage, 0, 65535.0f, 0, 255.0f ); flagImageChanged(); } else { ofLogError("ofxCvGrayscaleImage") << "operator=: region of interest mismatch"; } }
//-------------------------------------------------------------------------------- void ofxCvFloatImage::operator *= ( ofxCvImage& mom ) { if( mom.getWidth() == 0 || mom.getHeight() == 0 ){ ofLog(OF_LOG_ERROR, "in *=, mom width or height is 0"); return; } if( !bAllocated ){ ofLog(OF_LOG_ERROR, "in *=, image is not allocated"); return; } if( mom.getCvImage()->nChannels == cvImage->nChannels && mom.getCvImage()->depth == cvImage->depth ){ if( matchingROI(getROI(), mom.getROI()) ) { cvMul( cvImage, mom.getCvImage(), cvImageTemp ); swapTemp(); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in *=, ROI mismatch"); } } else { ofLog(OF_LOG_ERROR, "in *=, images need to have matching type"); } }
//-------------------------------------------------------------------------------- void ofxCvFloatImage::operator &= ( ofxCvImage& mom ) { if( mom.getWidth() == 0 || mom.getHeight() == 0 ){ ofLog(OF_LOG_ERROR, "in &=, mom width or height is 0"); return; } if( !bAllocated ){ ofLog(OF_LOG_ERROR, "in &=, image is not allocated"); return; } if( mom.getCvImage()->nChannels == cvImage->nChannels && mom.getCvImage()->depth == cvImage->depth ){ if( matchingROI(getROI(), mom.getROI()) ) { //this is doing it bit-wise; probably not what we want cvAnd( cvImage, mom.getCvImage(), cvImageTemp ); swapTemp(); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in &=, ROI mismatch"); } } else { ofLog(OF_LOG_ERROR, "in &=, images need to have matching type"); } }
//-------------------------------------------------------------------------------- void ofxCvGrayscaleImage::operator = ( const ofxCvGrayscaleImage& _mom ) { if(this != &_mom) { //check for self-assignment // cast non-const, no worries, we will reverse any chages ofxCvGrayscaleImage& mom = const_cast<ofxCvGrayscaleImage&>(_mom); if( mom.getWidth() == 0 || mom.getHeight() == 0 ){ ofLog(OF_LOG_ERROR, "in =, mom width or height is 0"); return; } if( !bAllocated ){ ofLog(OF_LOG_NOTICE, "in =, allocating to match dimensions"); allocate(mom.getWidth(), mom.getHeight()); } if( matchingROI(getROI(), mom.getROI()) ) { cvCopy( mom.getCvImage(), cvImage, 0 ); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in =, ROI mismatch"); } } else { ofLog(OF_LOG_WARNING, "in =, you are assigning a ofxCvGrayscaleImage to itself"); } }
//-------------------------------------------------------------------------------- void ofxCvImage::operator &= ( ofxCvImage& mom ) { if( !mom.bAllocated ){ ofLog(OF_LOG_ERROR, "in &=, mom needs to be allocated"); return; } if( !bAllocated ){ ofLog(OF_LOG_NOTICE, "in &=, allocating to match dimensions"); allocate(mom.getWidth(), mom.getHeight()); } if( mom.getCvImage()->nChannels == cvImage->nChannels && mom.getCvImage()->depth == cvImage->depth ) { if( matchingROI(getROI(), mom.getROI()) ) { cvAnd( cvImage, mom.getCvImage(), cvImageTemp ); swapTemp(); flagImageChanged(); } else { ofLog(OF_LOG_ERROR, "in &=, ROI mismatch"); } } else { ofLog(OF_LOG_ERROR, "in &=, images need to have matching type"); } }