// Utils.h -- general image helper functions // // Copyright © Daniel Scharstein, 2003. // /////////////////////////////////////////////////////////////////////////// #define ROUND(x) ((x) > 0 ? ((int)((x) + .5)) : ((int)((x) - .5))) // downsample a color image simply by averaging 4 pixels together void downsample(CByteImage im, CByteImage &im2); // return a random float in closed interval min, max inline float randIn(float min, float max) { float r = (float)rand() / (float)RAND_MAX; return min + r * (max-min); } // miscellaneous // read an image and perhaps tell the user you're doing so void ReadImageVerb(CImage& img, const char* filename, int verbose); // write out an image and perhaps tell the user you're doing so void WriteImageVerb(CImage& img, const char* filename, int verbose); // safe parsing of integer argument int atoiSafe(char *s); //write float concisely. Rounds data. void justify(float f); //write nFrames images based on the integers in allData void arrayToImage(int*** allData, int nFrames, int h, int w, char* name);