/*** * PROJECT : Generation of Anatomical Models for Surgical Simulators (GAMSS) * AUTHOR : Raimundo Sierra * CONTACT : http://www.rsierra.com/?main=contact * CREATED : 21.03.2002 * CHANGED : * DESCRIPTION : Read arbitrary image files, docu see .h file */ #include "readImages.h" template T* readColorImage(const char * file, int &rows, int &columns, T *array, const float gamma=-1.0) { try { // Create an image object and read an image Image image( file ); if(gamma>0) image.gamma(gamma); cout << "Resolution of image: "<< image.rows() << "x"<< image.columns() << endl; rows = image.rows(); columns = image.columns(); array = new T[rows*columns*3]; // allocate memory for image ColorRGB color; int position = 0; for(int j=0; j T* readGreyImage(const char * file, int &rows, int &columns, T *array, const float gamma=-1.0) { try { Image image( file ); if(gamma>0) image.gamma(gamma); cout << "Resolution of image: "<< image.rows() << "x"<< image.columns() << endl; rows = image.rows(); columns = image.columns(); array = new T[rows*columns]; ColorGray gray; for(int j=0; j