added image loading and display results stuff- changes all commented in code
This commit is contained in:
parent
aaf6ebfeb4
commit
71e3a9a1db
@ -80,4 +80,88 @@ 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++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -40,6 +40,9 @@ 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;
|
||||
@ -59,5 +62,12 @@ 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;
|
||||
};
|
||||
@ -59,7 +59,7 @@ void CamNoiseAnalysis::acquire()
|
||||
|
||||
void CamNoiseAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -41,14 +41,18 @@ 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 = 150; // the right number is about 300
|
||||
DELTA_T_SAVE = 50;//150; // the right number is about 300
|
||||
NUM_PHASE = 1;
|
||||
NUM_RUN = 1;
|
||||
NUM_SAVE_PER_RUN = 300;
|
||||
NUM_SAVE_PER_RUN = 100;//;
|
||||
|
||||
create_dir();
|
||||
_frame_cnt = 0;
|
||||
@ -86,7 +90,31 @@ 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++;
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
@ -174,6 +202,8 @@ void ColorMultiAnalysis::save_cb(Timer& timer)
|
||||
|
||||
// cout<<_whole_file_path<<endl;
|
||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||
// _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;
|
||||
|
||||
@ -24,4 +24,5 @@ protected:
|
||||
bool _RUN_DONE;
|
||||
int _run_cnt, _save_cnt, _fade_cnt;
|
||||
float c, _frame_cnt, _frame_cnt_max;
|
||||
ofImage image1;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user