merge tom's grayscale saving code

This commit is contained in:
dviid 2012-02-28 20:13:08 +01:00
parent ebe29d2c8a
commit d31fd93932
18 changed files with 88 additions and 15 deletions

View File

@ -15,7 +15,7 @@
#include "ofxXmlSettings.h" #include "ofxXmlSettings.h"
#define CAMERA_ID 1 #define CAMERA_ID 0
#define CAMERA_ACQU_WIDTH 640 #define CAMERA_ACQU_WIDTH 640
#define CAMERA_ACQU_HEIGHT 480 #define CAMERA_ACQU_HEIGHT 480
@ -102,6 +102,7 @@ void RefractiveIndex::setup()
_analysisVector.push_back(new RelaxRateAnalysis()); _analysisVector.push_back(new RelaxRateAnalysis());
_analysisVector.push_back(new IResponseAnalysis()); _analysisVector.push_back(new IResponseAnalysis());
_analysisVector.push_back(new ShapeFromShadingAnalysis()); _analysisVector.push_back(new ShapeFromShadingAnalysis());

View File

@ -153,6 +153,7 @@ void AbstractAnalysis::saveImageSynthesis(string filename, ofxCvImage* newPixels
#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)
@ -168,13 +169,10 @@ 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(), OF_IMAGE_GRAYSCALE); myGrayImage1.setFromPixels(newPixels->getPixels(), newPixels->getWidth(), newPixels->getHeight(), OF_IMAGE_COLOR);
myGrayImage1.setImageType(OF_IMAGE_COLOR); myGrayImage1.setImageType(OF_IMAGE_COLOR);
// THIS DOESN' SEEM TO SAVE OUT IMAGES AT ALL ON WINDOWS
//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

View File

@ -80,6 +80,8 @@ void CamNoiseAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.clear(); cvGrayImage2.clear();
cvGrayDiff2.clear(); cvGrayDiff2.clear();
cvConvertorImage.clear();
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
@ -88,6 +90,8 @@ void CamNoiseAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
} }
@ -179,7 +183,9 @@ void CamNoiseAnalysis::synthesise()
//_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
// <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
saveImageSynthesis(file_name, &cvGrayImage1, OF_IMAGE_GRAYSCALE); cvConvertorImage.setFromGrayscalePlanarImages(cvGrayDiff1,cvGrayDiff1,cvGrayDiff1);
saveImageSynthesis(file_name, &cvConvertorImage, OF_IMAGE_GRAYSCALE);
_synth_save_cnt++; _synth_save_cnt++;

View File

@ -60,4 +60,8 @@ protected:
ofxCvGrayscaleImage cvGrayImage4; ofxCvGrayscaleImage cvGrayImage4;
ofxCvContourFinder cvContourFinder1; ofxCvContourFinder cvContourFinder1;
//this is the temporary container to allow us to convert and save out greyscale images
ofxCvColorImage cvConvertorImage;
}; };

View File

@ -77,6 +77,8 @@ void ColorMultiAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.clear(); cvGrayImage2.clear();
cvGrayDiff2.clear(); cvGrayDiff2.clear();
cvConvertorImage.clear();
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
@ -85,6 +87,8 @@ void ColorMultiAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
} }
void ColorMultiAnalysis::acquire() void ColorMultiAnalysis::acquire()

View File

@ -55,4 +55,8 @@ protected:
ofxCvContourFinder cvContourFinder1; ofxCvContourFinder cvContourFinder1;
//this is the temporary container to allow us to convert and save out greyscale images
ofxCvColorImage cvConvertorImage;
}; };

View File

@ -84,6 +84,8 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.clear(); cvGrayImage2.clear();
cvGrayDiff2.clear(); cvGrayDiff2.clear();
cvConvertorImage.clear();
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
@ -91,6 +93,9 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight)
cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
} }
@ -184,6 +189,7 @@ void ColorSingleAnalysis::synthesise()
//_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
// <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR); saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR);
_synth_save_cnt++; _synth_save_cnt++;

View File

@ -62,4 +62,8 @@ protected:
ofxCvContourFinder cvContourFinder1; ofxCvContourFinder cvContourFinder1;
//this is the temporary container to allow us to convert and save out greyscale images
ofxCvColorImage cvConvertorImage;
}; };

View File

@ -78,6 +78,8 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.clear(); cvGrayImage2.clear();
cvGrayDiff2.clear(); cvGrayDiff2.clear();
cvConvertorImage.clear();
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
@ -85,6 +87,9 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
} }

View File

@ -59,4 +59,8 @@ protected:
ofxCvGrayscaleImage cvGrayImage4; ofxCvGrayscaleImage cvGrayImage4;
ofxCvContourFinder cvContourFinder1; ofxCvContourFinder cvContourFinder1;
//this is the temporary container to allow us to convert and save out greyscale images
ofxCvColorImage cvConvertorImage;
}; };

View File

@ -78,6 +78,8 @@ void IResponseAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.clear(); cvGrayImage2.clear();
cvGrayDiff2.clear(); cvGrayDiff2.clear();
cvConvertorImage.clear();
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
@ -86,6 +88,7 @@ void IResponseAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
} }
@ -178,9 +181,10 @@ void IResponseAnalysis::synthesise()
// <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
saveImageSynthesis(file_name, &cvGrayDiff1, OF_IMAGE_GRAYSCALE); cvConvertorImage.setFromGrayscalePlanarImages(cvGrayDiff1,cvGrayDiff1,cvGrayDiff1);
_synth_save_cnt++;
saveImageSynthesis(file_name, &cvConvertorImage, OF_IMAGE_GRAYSCALE);
_synth_save_cnt++;
} }
} }
} }

View File

@ -58,4 +58,8 @@ protected:
ofxCvGrayscaleImage cvGrayImage4; ofxCvGrayscaleImage cvGrayImage4;
ofxCvContourFinder cvContourFinder1; ofxCvContourFinder cvContourFinder1;
//this is the temporary container to allow us to convert and save out greyscale images
ofxCvColorImage cvConvertorImage;
}; };

View File

@ -86,6 +86,8 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.clear(); cvGrayImage2.clear();
cvGrayDiff2.clear(); cvGrayDiff2.clear();
cvConvertorImage.clear();
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
@ -93,6 +95,9 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
} }
void ShadowScapesAnalysis::acquire() void ShadowScapesAnalysis::acquire()
@ -189,7 +194,9 @@ void ShadowScapesAnalysis::synthesise()
//_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
// <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
saveImageSynthesis(file_name, &cvGrayDiff1, OF_IMAGE_GRAYSCALE); cvConvertorImage.setFromGrayscalePlanarImages(cvGrayDiff1,cvGrayDiff1,cvGrayDiff1);
saveImageSynthesis(file_name, &cvConvertorImage, OF_IMAGE_GRAYSCALE);
_synth_save_cnt++; _synth_save_cnt++;
} }
} }

View File

@ -66,4 +66,7 @@ protected:
ofxCvContourFinder cvContourFinder1; ofxCvContourFinder cvContourFinder1;
//this is the temporary container to allow us to convert and save out greyscale images
ofxCvColorImage cvConvertorImage;
}; };

View File

@ -78,6 +78,8 @@ void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.clear(); cvGrayImage2.clear();
cvGrayDiff2.clear(); cvGrayDiff2.clear();
cvConvertorImage.clear();
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
@ -86,6 +88,8 @@ void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
} }
@ -198,7 +202,9 @@ void ShapeFromShadingAnalysis::synthesise()
// <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
saveImageSynthesis(file_name, &cvGrayDiff1, OF_IMAGE_GRAYSCALE); cvConvertorImage.setFromGrayscalePlanarImages(cvGrayDiff1,cvGrayDiff1,cvGrayDiff1);
saveImageSynthesis(file_name, &cvConvertorImage, OF_IMAGE_GRAYSCALE);
_synth_save_cnt++; _synth_save_cnt++;
} }

View File

@ -78,4 +78,8 @@ protected:
ofxCvGrayscaleImage cvGrayImage4; ofxCvGrayscaleImage cvGrayImage4;
ofxCvContourFinder cvContourFinder1; ofxCvContourFinder cvContourFinder1;
//this is the temporary container to allow us to convert and save out greyscale images
ofxCvColorImage cvConvertorImage;
}; };

View File

@ -79,6 +79,8 @@ void StrobeAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.clear(); cvGrayImage2.clear();
cvGrayDiff2.clear(); cvGrayDiff2.clear();
cvConvertorImage.clear();
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
@ -87,6 +89,8 @@ void StrobeAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
} }
@ -180,7 +184,9 @@ void StrobeAnalysis::synthesise()
// <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
saveImageSynthesis(file_name, &cvGrayDiff1, OF_IMAGE_GRAYSCALE); cvConvertorImage.setFromGrayscalePlanarImages(cvGrayDiff1,cvGrayDiff1,cvGrayDiff1);
saveImageSynthesis(file_name, &cvConvertorImage, OF_IMAGE_GRAYSCALE);
_synth_save_cnt++; _synth_save_cnt++;

View File

@ -65,4 +65,7 @@ protected:
ofxCvContourFinder cvContourFinder1; ofxCvContourFinder cvContourFinder1;
//this is the temporary container to allow us to convert and save out greyscale images
ofxCvColorImage cvConvertorImage;
}; };