// Rasterizor2D.h -- Analysis of 2D Mondrian Photographs // // // DESCRIPTION // // Copyright © Timothy Bahls, Daniel Scharstien 2004. // /////////////////////////////////////////////////////////////////////////// // unknown float value #define UNKNOWN -9876 #define UNKNOWNF -9876.5f #define MAX 1234.5f #define MIN -1234.5f #ifndef WIN32 #define __max(a,b) (((a) > (b)) ? (a) : (b)) #define __min(a,b) (((a) < (b)) ? (a) : (b)) #endif class CRasterizor2D; class CRegRast2D { public: int id; // its own index int nFrames; int maxVelocity;//The maximum and minimum of all velocities int minVelocity; int minVel;//The expected maximum and minimum for this region int maxVel; int *possVels;//Stores the likelyhood of each velocity int numberOfVels;//maximumVel-minimumVel+1 int oddsSoFar;//Number of guesses about velocity float velScale;//for ease of calculation int**data;//the rasterized information. High means likely there. Lower the less likely. 0 is neutral. int maxWidth;//of image // constructor CRegRast2D(){} //default CRegRast2D(int iid, CRasterizor2D * master); void limitV(int f1, int f2); void limitP(int f1, int f2); void restrictVel(); void restrictPosition(); void convexHull();//Assumes convexity void deleteOld();//clears data and prepares for new row void printStuff(); //prints information about region i and checks its accuracy. For debugging. void velLessThan(int max, int odds);//Guess that the velocity for this region is less taht max, probability odds void velMoreThan(int min, int odds); void velIsNot(int vel, int odds);//Velocity likely not vel. Probability odds. void guessVelocity();//Set minVel and maxVel }; // all regions class CRasterizor2D { int maxID;//highest id seen so far int**relative;//the relative distances int**data;//the reduced image CRegRast2D* region;//the regions themselves CByteImage im; bool concave; int times; public: // constructor and destructor CRasterizor2D(int nFrames,bool iverbose);//,int iwidth); ~CRasterizor2D(); int goGoGo(CByteImage*imgs, bool stereo, int minVelocity, int maxVelocity,bool iconcave); void readFrame(CByteImage im,int frame,int row); void reportResults(); bool verbose; CCol * colTable;//Stores what colors the intergers correspond to. Assumes similar colors only come from the same region. int maxVelocity;//The maximum and minimum of all velocities int minVelocity; int nFrames; // number of frames (used to allocate extent vectors) int maxWidth; //length of image int maxHeight; int***allData;//all frames of all rows reduced. Use to output final ppm's private: // prototypes int compare(int a, int b);//check to see if a is likely closer than b void p(int a); //print the description of the color at colTable[a] void setCloser(int c, int f, int odds);//c probably closer f with likelyhood odds void addid(int a); //new id seen int getPixID(int row, int col);//find color in im at row,col int colToID(CCol c); //find where in the colTable c goes. void analyzeT(int row, int col, int id1, int id2, int id3); //checks four by four box around a two by two T junction void checkForT(int row, int col, int displace);//looks for two by two T junctions void stereoRestriction(); void transitiveClosure(); void occlusionDetection(); void extendedT(); void possibilityElimination(); void printStuff(int i); //prints information about region i and checks its accuracy. For debugging. };