converting cv images properly (thanks Tom) and possible fix for Windows saving of greyscale images

cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);

cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
This commit is contained in:
Jamie Allen 2012-02-27 20:08:48 +01:00
parent 0d62dbd135
commit 1f23d167c2
8 changed files with 22 additions and 31 deletions

View File

@ -111,7 +111,7 @@ void AbstractAnalysis::create_dir_allocate_images()
myGrayImage1.clear(); myGrayImage1.clear();
myGrayImage1.setUseTexture(false); myGrayImage1.setUseTexture(false);
myGrayImage1.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, OF_IMAGE_GRAYSCALE); myGrayImage1.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, OF_IMAGE_GRAYSCALE);
//////////////////////////////END ALLOCATE IMAGES ////////////////////////////////////////////////// //////////////////////////////END ALLOCATE IMAGES //////////////////////////////////////////////////
} }
@ -153,17 +153,16 @@ void AbstractAnalysis::saveImageAnalysis(string filename)
void AbstractAnalysis::saveImageSynthesis(string filename, ofxCvImage* newPixels, ofImageType newType) void AbstractAnalysis::saveImageSynthesis(string filename, ofxCvImage* newPixels, ofImageType newType)
{ {
//#ifdef TARGET_OSX #ifdef TARGET_OSX
// ofSaveImage(newPixels->getPixelsRef(), _whole_file_path_synthesis+"/"+filename, OF_IMAGE_QUALITY_BEST); // ofSaveImage(newPixels->getPixelsRef(), _whole_file_path_synthesis+"/"+filename, OF_IMAGE_QUALITY_BEST);
//#elif defined(TARGET_WIN32) #elif defined(TARGET_WIN32)
if (newType == OF_IMAGE_COLOR){ if (newType == OF_IMAGE_COLOR){
myColorImage2.setUseTexture(false); myColorImage2.setUseTexture(false);
myColorImage2.setFromPixels(newPixels->getPixels(), newPixels->getWidth(), newPixels->getHeight(), OF_IMAGE_COLOR); myColorImage2.setFromPixels(newPixels->getPixels(), newPixels->getWidth(), newPixels->getHeight(), OF_IMAGE_COLOR);
myColorImage2.saveImage(_whole_file_path_synthesis+"/"+filename); myColorImage2.saveImage(_whole_file_path_synthesis+"/"+filename);
myColorImage2.clear();
} }
if (newType == OF_IMAGE_GRAYSCALE){ if (newType == OF_IMAGE_GRAYSCALE){
@ -171,16 +170,16 @@ void AbstractAnalysis::saveImageSynthesis(string filename, ofxCvImage* newPixels
// THIS IS HOW YOU HAVE TO SAVE OUT THE GREYSCALE IMAGES on WINDOWS FOR SOME REASON --> i.e.: as an OF_IMAGE_COLOR // THIS IS HOW YOU HAVE TO SAVE OUT THE GREYSCALE IMAGES on WINDOWS FOR SOME REASON --> i.e.: as an OF_IMAGE_COLOR
// But they don't save properly - they're spatially translated and generally f'd up // But they don't save properly - they're spatially translated and generally f'd up
myGrayImage1.setFromPixels(newPixels->getPixels(), newPixels->getWidth(), newPixels->getHeight()); myGrayImage1.setFromPixels(newPixels->getPixels(), newPixels->getWidth(), newPixels->getHeight(), OF_IMAGE_GRAYSCALE);
myGrayImage1.setImageType(OF_IMAGE_COLOR);
// THIS DOESN' SEEM TO SAVE OUT IMAGES AT ALL ON WINDOWS // THIS DOESN' SEEM TO SAVE OUT IMAGES AT ALL ON WINDOWS
//myGrayImage1.setFromPixels(newPixels->getPixels(), newPixels->getWidth(), newPixels->getHeight(), OF_IMAGE_GRAYSCALE); //myGrayImage1.setFromPixels(newPixels->getPixels(), newPixels->getWidth(), newPixels->getHeight(), OF_IMAGE_GRAYSCALE);
myGrayImage1.saveImage(_whole_file_path_synthesis+"/"+filename); myGrayImage1.saveImage(_whole_file_path_synthesis+"/"+filename);
myGrayImage1.clear();
} }
//#endif #endif
_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+filename); _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+filename);

View File

@ -146,8 +146,8 @@ void CamNoiseAnalysis::synthesise()
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height); cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
//cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height); //cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
cvGrayImage1 = cvColorImage1; cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
//cvGrayImage2 = cvColorImage2; // cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
//cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1); //cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
cvGrayImage1.erode(); cvGrayImage1.erode();

View File

@ -151,16 +151,6 @@ void ColorSingleAnalysis::synthesise()
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height); cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
//cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height); //cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
//cvGrayImage1 = cvColorImage1;
//cvGrayImage2 = cvColorImage2;
//cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
//cvGrayDiff1.erode();
//cvGrayDiff1.contrastStretch();
//cvGrayDiff1.blur(5);
//cvGrayDiff1.dilate();
//cvGrayDiff1.contrastStretch();
cvColorImage1.blur(5); cvColorImage1.blur(5);
cvColorImage1.erode(); cvColorImage1.erode();
cvColorImage1.erode(); cvColorImage1.erode();

View File

@ -146,8 +146,8 @@ void IResponseAnalysis::synthesise()
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height); cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height); cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
cvGrayImage1 = cvColorImage1; cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
cvGrayImage2 = cvColorImage2; cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1); cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
cvGrayDiff1.erode(); cvGrayDiff1.erode();

View File

@ -139,7 +139,9 @@ void RelaxRateAnalysis::synthesise()
///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES ////////////////////////// ///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height); cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
cvGrayDiff1 = cvColorImage1;
cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
cvGrayDiff1.threshold(_treshold); cvGrayDiff1.threshold(_treshold);
rfiCvContourFinder* cf = new rfiCvContourFinder(); rfiCvContourFinder* cf = new rfiCvContourFinder();

View File

@ -143,9 +143,9 @@ void ShadowScapesAnalysis::synthesise()
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height); cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height); cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
cvGrayImage1 = cvColorImage1; cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
cvGrayImage2 = cvColorImage2; cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1); cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
cvGrayDiff1.erode(); cvGrayDiff1.erode();
cvGrayDiff1.contrastStretch(); cvGrayDiff1.contrastStretch();

View File

@ -165,8 +165,8 @@ void ShapeFromShadingAnalysis::synthesise()
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height); cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height); cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
cvGrayImage1 = cvColorImage1; cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
cvGrayImage2 = cvColorImage2; cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1); cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
cvGrayDiff1.erode(); cvGrayDiff1.erode();

View File

@ -147,9 +147,9 @@ void StrobeAnalysis::synthesise()
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height); cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height); cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
cvGrayImage1 = cvColorImage1; cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
cvGrayImage2 = cvColorImage2; cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1); cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
cvGrayDiff1.dilate(); cvGrayDiff1.dilate();
cvGrayDiff1.dilate(); cvGrayDiff1.dilate();