//////////////////////////////////////////////////////////////////////////// // sender.cc // // Paul McCartney, Winter 1995 // // Copyright 1995, Washington University Computer Science Department // All Rights Reserved // // RCS: $Id: sender.cc,v 1.9 1995/10/27 22:40:02 paul Exp $ // // This module is a "server" for reading images from a RVG medical image // file, encoding each image as a Playground tuple, and sending out each // image to external modules. // // PLAYGROUND VARIABLES: // // frame (output) - PGimage tuple, storing image data // file (input) - string, specifying which RVG file to read from disk //////////////////////////////////////////////////////////////////////////// #include "PGimage.hh" #include "PG.hh" #include #include #include const int cNFrames = 32; const int cFrameWidth = 64; const int cFrameHeight = 64; PGimage gFrame; PGstring gFilename; unsigned short buf[cNFrames][cFrameHeight][cFrameWidth]; // scan all of the images, and all of the pixels, returning the maximum // pixel value. unsigned short FindMax() { unsigned short v; unsigned short max = 0; for (int f=0; f max) max = v; } } } return max; } // read all of the images from an RVG file. Scale each pixel value so // that the maximum pixel value is 255. The image information is stored // in the "buf" global variable. bool ReadRVG(const char* fname) { ifstream inFile(fname); if (!inFile) { cout << "Unsuccessful read." << endl; return false; } inFile.seekg(512*4); inFile.read((char*)buf, cNFrames*cFrameWidth*cFrameHeight*2); // each pixel is 2 bytes float scale = 255.0 / (float)(FindMax()); for (int f=0; f