// Rasterizor.h -- Analysis of 1D integer value Mondrian scenes // // // 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 #include "Scene.h" class CRegRast { public: int id; // its own index int nFrames; int minVel; int maxVel; bool*possVels; //Indexed by velocity. Stores whether or not a velocity is possible. int**data; //rasterized information itself. 1=region is there; 0=not sure; -1=region isn't there. int maxWidth; //width of image int*xmins; //minimum seen value in each frame int*xmaxes; //maximum seen value in each frame int*leftIDs; //id of region to the left int*rightIDs;//id of region to the right bool change; // constructor CRegRast(int id, int inFrames, int iwidth); CRegRast(){} //default bool operator == (CRegRast); bool limitV(int f1, int f2); bool limitP(int f1, int f2); bool restrictVel(); bool restrictPosition(); bool convexHull();//The epislice is convex iff the region is convex and moves at a constant speed void printStuff(); //used for debugging. Shows how data looks. }; // all regions class CRasterizor { int nFrames; // number of frames (used to allocate extent vectors) int nRegions; // number of regions observed so far int maxWidth; //length of image int maxID; bool change; // does info change during analysis int**relative;//the relative distances int**data;//the reduced image CRegRast* region; CByteImage im; bool concave; CRegRast null; int times; public: // constructor and destructor CRasterizor(int nFrames,bool iverbose,int iwidth) : nFrames(nFrames), nRegions(0), maxID(-1), data(new int*[nFrames]), null(CRegRast(-2,nFrames,iwidth)),verbose(iverbose){} ~CRasterizor(); void printData(); int goGoGo(bool iconcave); void readFrame(CByteImage im,int frame); void reportResults(); bool verbose; void checkAccuracy(CScene scene); private: // prototypes int compare(int a, int b); //looks up in relative who is closer void p(int a); //prints the name of the color bool setCloser(int c, int f); //records in relative that c is closer than f void addid(int a); //new id seen int getPixID(int row, int col);//looks up the color in row, col of im void startRegion(int id, int frame, int x, int prevId);//begin a new region void endRegion(int id, int frame, int x, int nextId); //ends a region void transitiveClosure(); void occlusionDetection(); void extendedT(); void possibilityElimination(); void checkTripletForQuadT(int id,int f1,int f2,int f3,int*minmax,int*rightleft); void quadT(); void printStuff(int i); //used for debugging. Shows how data looks and compares it to the truth };