コード例 #1
0
//Take in arguments from command line
int main(int argc,char* argv[]) {
    cout << "Volumetric Image Manipulation Tool - SCRSHA001" << endl;
    cout << "Available commands = -x -d -g " << endl;

    //Check if right amount of arguments
    if (argc >6 || argc < 4){
        cout << "Incorrect arguments passed (Not enough or too little found) " <<endl;
    }
    else { //right amount of arguments
        //Check if valid arguments
        if (string(argv[2]) == "-x" || string(argv[2]) == "-d" || string(argv[2]) == "-g"){
            cout <<"Arguments validated." <<endl;
            cout <<endl;
            //Done here as each command has the same start
            VolImage volImage = VolImage(); //Create VolImage object on stack so automatically deleted
            (volImage).readImages( string (argv[1])); //Read in all Images into vector inside VolImage
            cout << "Number of images: " << (volImage).numOfImages() <<endl;
            cout << "Number of bytes required: "<< (volImage).volImageSize() <<endl; //todo Find out how to get the number of bytes required
            cout <<endl;

            //If command is to extract
            if (string(argv[2]) == "-x"){
                cout<<"Extract option chosen"<<endl;
                //Get variables from the command line arguments
                int indexOfFile = getIntFromArgument(argv[3]);

                stringstream getOutputFileName(argv[4]);
                string outputName;
                getOutputFileName >> outputName;

                cout<< "Extracting slice "<< indexOfFile << " into file " << outputName << ".raw"<<endl;
                volImage.extract(indexOfFile,outputName);
            }
            else if (string(argv[2]) == "-d"){
コード例 #2
0
ファイル: driver.cpp プロジェクト: CarlaLlama/VolImage
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")){
コード例 #3
0
ファイル: driver.cpp プロジェクト: muhummadPatel/cs3022a2
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;
}