#include "rtsFunction3D.h" #include "cimg/cimg.h" #include #include #include using namespace std; using namespace cimg_library; ///This file contains a series of functions useful for loading images into other structures. These function use the CImg header file. void rts_cimgLoadImage(rtsFunction3D& result, const char* filename) /// image(filename), visu(500,400,1,3,0); result = rtsFunction3D(image.width, image.height, 1); unsigned int x, y; for(x=0; x& result, int z, const char* filename) { CImg image(result.DimX(), result.DimY()); unsigned int x, y; for(x=0; x& result, const char* filename, unsigned int min, unsigned int max, unsigned int color = 0) { /** This function loads a sequence of images into a 3D implicit function. The filename is passed using the '?' wild card. The wild cards are then replaced with the given min through max values in order to construct the names for the image files to be loaded. The files are then loaded and placed in sequential order along the z-axis of the implicit function. **/ string sequence_name = filename; //turn the filename into a string unsigned int wild_card_begin = sequence_name.find_first_of('?'); //find the start and end indices of the wild card unsigned int wild_card_end = sequence_name.find_last_of('?'); unsigned int max_number_length = wild_card_end - wild_card_begin + 1; //find the maximum number of characters in the image number unsigned int max_number = (unsigned int)pow((double)10, (double)max_number_length) - 1; //find the maximum possible number //make sure that the data is given correctly if(max < min) return; if(max > max_number) max = max_number; //create an array of file names int num_images = max - min + 1; //compute the number of images bool implicit_created = false; for(int i=0; i image(file_name.c_str()); //load the frame if(implicit_created == false) //create the implicit function for the first frame { result = rtsFunction3D(image.width, image.height, num_images); implicit_created = true; } //place the frame in the implicit function unsigned int x, y; for(x=0; x& result, const char* filename) { string sequence_name = filename; //turn the filename into a string unsigned int wild_card_begin = sequence_name.find_first_of('?'); //find the start and end indices of the wild card unsigned int wild_card_end = sequence_name.find_last_of('?'); unsigned int max_number_length = wild_card_end - wild_card_begin + 1; //find the maximum number of characters in the image number unsigned int max_number = (unsigned int)pow((double)10, (double)max_number_length) - 1; //find the maximum possible number //make sure that the data is given correctly unsigned int max = result.DimZ(); if(max > max_number) max = max_number; //save each individual file int num_images = max; //compute the number of images CImg image(result.DimX(), result.DimY()); //create an image for saving for(int i=0; i source, unsigned int z) { CImg image(source.DimX(), source.DimY()); int x, y; for(x=0; x