Revert 85ce9c2e6729fc1cee394b46ac868e4086d476f9^..HEAD

This commit is contained in:
Jamie Allen 2012-02-19 22:47:55 +01:00
parent 7bb5734eed
commit 6395b1c0a0
12 changed files with 62 additions and 190 deletions

View File

@ -80,88 +80,4 @@ void AbstractAnalysis::create_dir()
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
}
ofPixels AbstractAnalysis::calculateListOfZValues(ofImage image1, ofImage image2, int whichComparison){
//zScale is the mapping factor from pixel difference to shift on the zPlane
int zScale=200;
ofPixels imagePixels1 = image1.getPixelsRef();
ofPixels imagePixels2 = image2.getPixelsRef();
ofPixels difference;
//this unsigned char should be unnecessary - I would have thought - can't you just address the pixel locations in ofPixels directly?
unsigned char * thesePixels = new unsigned char[ imagePixels1.getWidth()*imagePixels1.getHeight()*3];
//where are we in the image pixel array
int x=0;
int y=0;
//for each pixel...
for(int i=0;i<imagePixels1.size();i+=3){
//get the colour of each image at this x y location - we will use these colours for comparison according to the below criteria
ofColor colourImage1 = imagePixels1.getColor(x, y);
ofColor colourImage2 = imagePixels2.getColor(x, y);
//COMPARE THIS PIXEL'S VALUES with the first image in the sequence
int thisDiff;
//compare Red
if (whichComparison==1) {
thisDiff=ofMap((colourImage1.r-colourImage2.r),-255,255,0,zScale);
}
//compare blue
if (whichComparison==2) {
thisDiff=ofMap((colourImage1.g-colourImage2.g),-255,255,0,zScale);
}
//compare green
if (whichComparison==3) {
thisDiff=ofMap((colourImage1.b-colourImage2.b),-255,255,0,zScale);
}
//compare hue
if (whichComparison==4) {
thisDiff=ofMap((colourImage1.getHue()-colourImage2.getHue()),-255,255,0,zScale);
}
//compare brightness
if (whichComparison==5) {
thisDiff=ofMap((colourImage1.getBrightness()-colourImage2.getBrightness()),-255,255,0,zScale);
}
thesePixels[i]=thisDiff;
thesePixels[i+1]=thisDiff;
thesePixels[i+2]=thisDiff;
x++;
//new line
if(x>imagePixels1.getWidth()){
x=0;
y++;
}
}
difference.setFromPixels(thesePixels,imagePixels1.getWidth(),imagePixels1.getHeight(), 3);
return difference;
}
void AbstractAnalysis:: setMeshFromPixels(ofPixels somePixels, ofImage currentSecondImage, ofMesh * someMesh){
int x=0;
int y=0;
//get rid of all previous vectors and colours - uncomment if re-setting the mesh on the fly - ie live rather than saving it first
//someMesh->clear();
unsigned char * thesePixels =currentSecondImage.getPixels();
for(int i=0;i<somePixels.size();i+=3){
someMesh->addVertex(ofVec3f(x,y,- somePixels.getColor(x, y).getBrightness() ));
// add colour from current second image of two
someMesh->addColor( currentSecondImage.getColor(x, y) );
x++;
if(x>somePixels.getWidth()){
x=0;
y++;
}
}
}

View File

@ -40,9 +40,6 @@ protected:
// analysis + synthesize images - all the children (see - do_synthesize)
virtual void synthesise() = 0;
virtual ofPixels calculateListOfZValues(ofImage image1, ofImage image2, int whichComparison);
virtual void setMeshFromPixels(ofPixels somePixels, ofImage currentSecondImage, ofMesh * someMesh);
public:
string _name;
@ -62,12 +59,5 @@ protected:
int NUM_RUN;
int NUM_SAVE_PER_RUN;
//added Tom S 19/2/12
//each mesh in the vector is a seperate 3D point cloud which is coloured with pixel data and shifted in the z plane according to the specified type of colour difference eg red value or hue
vector<ofMesh>meshes;
//how fast to move from one mesh to the next
float speed;
//the index (inside the vector of meshes) of the current mesh being displayed
float whichMesh;
friend class AnalysisAdaptor;
};

View File

@ -59,7 +59,7 @@ void CamNoiseAnalysis::acquire()
void CamNoiseAnalysis::synthesise()
{
// _saved_filenames has all the file names of all the saved images
}
@ -152,13 +152,14 @@ void CamNoiseAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
cout << "ColorSingleAnalysis::saving...\n";
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location;
string file = _whole_file_path+"/"+file_name;
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(_whole_file_path+"/"+file_name);
_saved_filenames.push_back(file);
//if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;

View File

@ -41,18 +41,14 @@ using Poco::Timer;
using Poco::TimerCallback;
using Poco::Thread;
#define COMPARE_RED 1
#define COMPARE_BLUE 2
#define COMPARE_GREEN 3
#define COMPARE_HUE 4
#define COMPARE_BRIGHTNESS 5
void ColorMultiAnalysis::setup(int camWidth, int camHeight)
{
DELTA_T_SAVE = 50;//150; // the right number is about 300
DELTA_T_SAVE = 150; // the right number is about 300
NUM_PHASE = 1;
NUM_RUN = 1;
NUM_SAVE_PER_RUN = 100;//;
NUM_SAVE_PER_RUN = 300;
create_dir();
_frame_cnt = 0;
@ -70,7 +66,7 @@ void ColorMultiAnalysis::acquire()
// RUN ROUTINE
for(int i = 0; i < NUM_RUN; i++) {
_run_cnt = i;
cout << "RUN NUM = " << i;
@ -90,31 +86,7 @@ void ColorMultiAnalysis::acquire()
void ColorMultiAnalysis::synthesise()
{
cout<<"SYNTHESISING MULTI";
// _saved_filenames has all the file names of all the saved images
// _saved_filenames has all the file names of all the saved images
//incrementer to whichMesh
speed=0.2;
//whichMesh is the index in the vector of meshes
whichMesh=0;
cout<<"image loaded ";
//there is a problem with natural vs alphabetical order when loading the files - we need to make a fix for this
int shift=0;
cout<<_saved_filenames.size()<<" image filenames ";
int index=0;
//for(int i=shift;i<_saved_filenames.size()-2;i+=2){
// cout<<_saved_filenames[i]<<endl;
meshes.push_back(ofMesh());
image1.loadImage("/Users/tomschofield/of_preRelease_v007_osx/apps/refracitveGitRepoFeb/RefractiveIndex/src/macro.png");
/*ofImage image2;
image2.loadImage(_saved_filenames[i+1]);
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BLUE), image2, &meshes[index]);
*/
index++;
//}
}
@ -204,24 +176,17 @@ void ColorMultiAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
cout << "ColorMultiAnalysis::saving...\n";
// UPDATE THE COLOR ON THE SCREEN
//float c_last = c;
// cout << "COLORMULTIANALYSIS::saving...\n";
// cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
// cout<<_whole_file_path<<endl;
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
<<<<<<< HEAD
_saved_filenames.push_back(_whole_file_path+"/"+file_name);
//if(_save_cnt >= NUM_SAVE_PER_RUN){
// _RUN_DONE = true;
//}
=======
// _saved_filenames.push_back("/Users/tomschofield/of_preRelease_v007_osx/apps/myApps/refractiveIndexDavidFeb/bin/data/"+_whole_file_path+"/"+file_name);
_saved_filenames.push_back("fish.jpg");
if(_save_cnt >= NUM_SAVE_PER_RUN){
_RUN_DONE = true;
}
>>>>>>> added image loading and display results stuff- changes all commented in code
}

View File

@ -24,5 +24,4 @@ protected:
bool _RUN_DONE;
int _run_cnt, _save_cnt, _fade_cnt;
float c, _frame_cnt, _frame_cnt_max;
ofImage image1;
};

View File

@ -156,14 +156,14 @@ void ColorSingleAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
cout << "ColorSingleAnalysis::saving...\n";
// cout << "ColorSingleAnalysis::saving...\n";
string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg";
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(_whole_file_path+"/"+file_name);
//cout<<_whole_file_path+"/"+file_name<<endl;
//if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;

View File

@ -167,16 +167,30 @@ void DiffNoiseAnalysis::draw()
// this runs at save_cb timer rate = DELTA_T_SAVE
void DiffNoiseAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
cout << "DiffNoiseAnalysis::saving...\n";
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(_whole_file_path+"/"+file_name);
float rand10 = ofRandom(0,10);
if (rand10 > 5.0) {
cout << "DiffNoiseAnalysis::saving...\n";
cout << "c_last... " << c << endl;
cout<<"rand10... " <<rand10<<endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location;
//RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
// fileName = imageSaveFolderPath+whichAnalysis+"_"+ofToString(100.0*i*scanLineSpeed/ofGetHeight(),2)+"%_"+ofToString(i)+".jpg";
//ofSaveImage(vectorOfPixels[i], fileName, OF_IMAGE_QUALITY_BEST);
string file = _whole_file_path+"/"+file_name;
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(file);
}
_save_cnt++;
//if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;

View File

@ -110,17 +110,19 @@ void IResponseAnalysis::draw()
// this runs at save_cb timer rate = DELTA_T_SAVE
void IResponseAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
cout << "IResponseAnalysis::saving...\n";
//cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location;
//RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
// fileName = imageSaveFolderPath+whichAnalysis+"_"+ofToString(100.0*i*scanLineSpeed/ofGetHeight(),2)+"%_"+ofToString(i)+".jpg";
//ofSaveImage(vectorOfPixels[i], fileName, OF_IMAGE_QUALITY_BEST);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(_whole_file_path+"/"+file_name);
//if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;
}

View File

@ -128,15 +128,17 @@ void RelaxRateAnalysis::draw()
void RelaxRateAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
cout << "RelaxRateAnalysis::saving...\n";
//cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
string thisLocation = RefractiveIndex::_location;
_saved_filenames.push_back(_whole_file_path+"/"+file_name);
string file = _whole_file_path+"/"+file_name;
ofSaveImage(RefractiveIndex::_pixels, file, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(file);
//if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;

View File

@ -211,10 +211,7 @@ void ShadowScapesAnalysis::draw()
void ShadowScapesAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
cout << "ShadowScapesAnalysis::saving...\n";
string file_name;
if(_dir == H) {
@ -230,8 +227,6 @@ void ShadowScapesAnalysis::save_cb(Timer& timer)
}
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(_whole_file_path+"/"+file_name);
_save_cnt++;
}

View File

@ -306,9 +306,7 @@ void ShapeFromShadingAnalysis::draw()
}
ofDisableAlphaBlending();
} else {
_RUN_DONE = true;
}
}
_frame_cnt++;
//cout << "_frame_cnt:" << _frame_cnt << endl;
@ -341,16 +339,10 @@ void ShapeFromShadingAnalysis::save_cb(Timer& timer)
{
//cout << "ShapeFromShadingAnalysis::saving...\n";
_save_cnt++;
cout << "ShapeFromShadingAnalysis::saving...\n";
string file_name = ofToString(_save_cnt,2)+"_"+ quad +"_"+ofToString(_run_cnt,2)+".jpg";
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(_whole_file_path+"/"+file_name);
_save_cnt++;
//if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;

View File

@ -152,17 +152,13 @@ void StrobeAnalysis::draw()
// this runs at save_cb timer rate = DELTA_T_SAVE
void StrobeAnalysis::save_cb(Timer& timer)
{
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(_strobe_on) +"_"+ofToString(_run_cnt,2)+".jpg";
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_save_cnt++;
cout << "StrobeAnalysis::saving...\n";
cout << "_save_cnt" << _save_cnt << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(_strobe_on) +"_"+ofToString(_run_cnt,2)+".jpg";
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(_whole_file_path+"/"+file_name);
cout << "_save_cnt_max" << _save_cnt_max << endl;
//TODO: something fucked here with my calc of _save_cnt_max - new structure should fix it?
//if(_save_cnt >= _save_cnt_max-10) {