#include #include #include #include "Geom.hpp" #include "Mask.hpp" ImportMask *MASK; RealMask *readMask(istream& in) { char magicP, magicNum; int width, height, maxval; in >> magicP >> magicNum; in >> width >> height >> maxval; if( magicP != 'P' ) { cerr << "readMask: This is not PGM data." << endl; return NULL; } RealMask *mask = new RealMask(width, height); if( magicNum == '2' ) { for(int j=0; j> val; mask->ref(i, j) = val; } } else if( magicNum == '5' ) { for(int j=0; j> val; mask->ref(i, j) = (real)val; } } else { cerr << "readMask: This is not PGM data." << endl; return NULL; } real max = (real)maxval; for(int i=0; iref(i,j) /= max; return mask; }