示例#1
0
int main(int argc, char* argv[])
{
	string prefix;
	string outfile;
	int img_no;
	int bytes_no;
	string operation_message;

	if(argc < 2){
		cout << "Incorrect program entry." << endl;
		cout << "Correct usage: volimage <imageBase> [-d i j output_file_name] [-x i output_file_name] [-g i output_file_name]" << endl;
		return 0;
	}

	// Make volimage Object, read in images
	VolImage volimg;
	prefix = string(argv[1]);
	volimg.readImages(prefix);

	if(argc == 2){
		// Build the internal representation and then exit after memory is correctly cleaned up
		operation_message = "Built internal representation, now exiting.";
	}else if((argc == 5) && (string(argv[2]) == "-g")){
		int imgi;
		istringstream is(argv[3]);
		is >> imgi;
		outfile = string(argv[4]);

		// int checking
		if(!imgi){
			cout << "Incorrect program entry." << endl;
			cout << "Variable i must be an integer." << endl;
			return 0;
		}

		volimg.extractRow(imgi, outfile);
		operation_message = "Extract image along row " + string(argv[3]) + " across all slices. Wrote to: " + outfile + ".raw";
	}else if((argc == 5) && (string(argv[2]) == "-x")){
示例#2
0
int main(int argc, char* argv[]){
    using namespace ptlmuh006;
    
    VolImage volimg;
    if(argc < 2){
        //Invalid usage
        handleInvalidArgs();
        
    }else if(argc == 2){
        //Just load data and exit        
        bool success = volimg.readImages(argv[1]);
        if(!success){
            std::cout << "Error reading in data." << std::endl;
            return 1;
        }
        
    }else{
        bool success = volimg.readImages(argv[1]);
        if(!success){
            std::cout << "Error reading in data." << std::endl;
            return 1;
        }
        
        //Handle flags        
        std::string flag = std::string(argv[2]);
        
        if(flag == "-d" && argc == 6){
            //Handle diffmap option
            
            int sliceI = std::stoi(argv[3]);
            int sliceJ = std::stoi(argv[4]);
            std::string output_prefix = argv[5];
            
            volimg.diffmap(sliceI, sliceJ, output_prefix);
            
            std::cout << "Difference-map between slice ";
            std::cout << sliceI << " and " << sliceJ;
            std::cout << " computed and written to ";
            std::cout << output_prefix << ".dat and ";
            std::cout << output_prefix << ".raw." << std::endl;
            
        }else if(flag == "-x" && argc == 5){
            //Handle extract option
        
            int slice = std::stoi(argv[3]);
            std::string output_prefix = argv[4];
            
            volimg.extract(slice, output_prefix);
            
            std::cout << "Extracted slice " << slice;
            std::cout << " and wrote it to ";
            std::cout << output_prefix << ".dat and ";
            std::cout << output_prefix << ".raw." << std::endl;
            
        }else if(flag == "-g" && argc == 5){
            //Handle row extract option
            
            int row = std::stoi(argv[3]);
            std::string output_prefix = argv[4];
            
            volimg.extractRow(row, output_prefix);
            
            std::cout << "Extracted row " << row;
            std::cout << " across all slices and wrote it to ";
            std::cout << output_prefix << ".dat and ";
            std::cout << output_prefix << ".raw." << std::endl;
            
        }else{
            //Invalid usage
            handleInvalidArgs();
        }
    }
    
    return 0;
}