当前位置: 首页>>代码示例>>C++>>正文


C++ Options::GetString方法代码示例

本文整理汇总了C++中Options::GetString方法的典型用法代码示例。如果您正苦于以下问题:C++ Options::GetString方法的具体用法?C++ Options::GetString怎么用?C++ Options::GetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Options的用法示例。


在下文中一共展示了Options::GetString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char* argv[]) {
    // show which dimension this executable is handling
    cout << argv[0] << " with dimension = " << __Dim << endl;

    
    Options opts;
    opts.addOption("-o", "Specify a filename for an output image", SO_REQ_SEP);
    opts.addOption("--fusion", "label fusion from a config", "`--fusion config-file output-file target-image`", SO_REQ_SEP);
    opts.addOption("--overlap", "Compute the overlap ratio (dice|jaccard). This option can take two or arguments. The first argument is a gold standard, and other arguments are multiple number of label images to be compared.", "--overlap dice output-text ref1 ref2-1 ref2-2 ... ref2-n", SO_REQ_SEP);
    opts.addOption("--p2mat", "point list to matrix", SO_NONE);
    opts.addOption("--slice", "extract a slice from 3d volume", "--slice dim index imagefile outputfile", SO_NONE);
    opts.addOption("--imageMerge", "merge 2D images into a 3d volume (--imageMerge output input1 input2 ...)", SO_REQ_SEP);
    opts.addOption("--qa", "extract a slice with a label map", SO_NONE);
    opts.addOption("--config", "[file] use this config file", SO_REQ_SEP);
    opts.addOption("--demons", "run Demons registration", SO_NONE);
    opts.addOption("--separate", "[input] [x] [y] [z] ... separate vector images into individual image files", SO_NONE);
    opts.addOption("--rx", "registration experiments ", SO_NONE);
    opts.addOption("--dots", "--rx --dots generate a series of gaussian dot images", SO_NONE);
    opts.addOption("--sigma", "sigma value [double]", "--sigma 0.8", SO_REQ_SEP);
    opts.addOption("--entropyImage", "Compute an entropy image from a set of given images", "`--entropyImage -o output.nrrd input1.nrrd input2.nrrd ...`", SO_NONE);
    opts.addOption("--test", "Run in a test mode. The test mode is context sensitive depending on the given argument. For example, if `--entropyImage --test` is given, it will automatically provide a set of input images and produce an output into a specific directory.", SO_NONE);
    opts.addOption("--distanceMap", "Compute the Danielsson's distance map. This will also generate distmag.nrrd, x.nrrd, y.nrrd, and z.nrrd that stores the component of the vector distance map for debugging purpose.", "--distanceMap input output-vector output-magnitude", SO_NONE);
    opts.addOption("--help", "print this message", SO_NONE);

    opts.ParseOptions(argc, argv, NULL);
    StringVector& args = opts.GetStringVector("args");

    if (opts.GetBool("--help") || opts.GetBool("-h")) {
        cout << "## ParticleRun Command Line Options" << endl;
        opts.PrintUsage();
        return 0;
    }


    particle2mat(opts, args);
    doSlice(opts, args);
    doSeparate(opts, args);


    if (opts.GetBool("--qa")) {
        executeQARunner(opts, args);
    } else if (opts.GetString("--imageMerge", "") != "" && args.size() > 0) {
        doMerge(opts, args);
    } else if (opts.GetBool("--demons")) {
        executeDemonsRunner(opts, args);
    } else if (opts.GetBool("--rx")) {
        executeRxRunner(opts, args);
    } else if (opts.GetString("--fusion", "") != "") {
        executeLabelFusionRunner(opts, args);
    } else if (opts.GetBool("--entropyImage")) {
        executeEntropyImage(opts, args);
    } else if (opts.GetString("--overlap") == "dice" || opts.GetString("--overlap") == "jaccard") {
        executeVolumeOverlaps(opts, args);
    } else if (opts.GetBool("--distanceMap")) {
        executeComputeDistanceMap(opts, args);
    } else {
        executeParticleRunner(opts, args);
    }
}
开发者ID:fayhot,项目名称:gradworks,代码行数:59,代码来源:particlesRun.cpp

示例2: doMerge

// merge a given list of arguments into the output-image that is given with the parameter --imageMerge
static void doMerge(Options& opts, StringVector& args) {
    string outputFile = opts.GetString("--imageMerge", "");
    if (outputFile == "") {
        return;
    }

    // first, create an empty image with the same x-y dimension with
    // the first argument image but has z-dimension with the number of arguments

    ImageIO<RealImage2> image2IO;
    ImageIO<RealImage3> image3IO;

    // read the first image and create the outputImage buffer
    RealImage2::Pointer inputImage = image2IO.ReadCastedImage(args[0]);
    RealImage3::Pointer outputImage = image3IO.NewImageT(
                inputImage->GetBufferedRegion().GetSize(0), inputImage->GetBufferedRegion().GetSize(1), args.size());

    // prepare the outputBuffer to write
    RealImage3::PixelType* outputBuffer = outputImage->GetBufferPointer();


    int i = 0;
    while (i < args.size()) {
        // prepare the inputImage buffer
        uint nSize = inputImage->GetPixelContainer()->Size();
        RealImage2::PixelType* inputBuffer = inputImage->GetBufferPointer();

        // copy the inputImage into the outputImage
        int nBytes = nSize * sizeof(RealImage3::PixelType);
        memcpy(outputBuffer, inputBuffer, nBytes);

        // forward the outputBuffer
        outputBuffer += nSize;

        // read the next image
        if (++i < args.size()) {
            inputImage = image2IO.ReadImage(args[i]);
        }
    }

    // output file preparation
    string outputFile = opts.GetString("--imageMerge");

    // write the 3d output image
    image3IO.WriteImage(outputFile, outputImage);

    // exit the program
    exit(0);
}
开发者ID:fayhot,项目名称:gradworks,代码行数:50,代码来源:particlesRun.cpp

示例3: runTraceScalarCombine

/// @brief Copy a scalar list from a seed object to a stream line object
void runTraceScalarCombine(Options& opts, StringVector& args) {
	if (args.size() < 3) {
		cout << "requires input-seed input-stream output-stream-file" << endl;
		return;
	}
	
	string inputSeedFile = args[0];
	string inputStreamFile = args[1];
	string outputStreamFile = args[2];
	string scalarName = opts.GetString("-scalarName");
	
	if (scalarName == "") {
		cout << "requires -scalarName scalarName" << endl;
		return;
	}
	
	vtkIO vio;
	vtkPolyData* inputSeed = vio.readFile(inputSeedFile);
	vtkPolyData* inputStream = vio.readFile(inputStreamFile);
	
	vtkDataArray* pointIds = inputStream->GetCellData()->GetScalars("PointIds");
	if (pointIds == NULL) {
		cout << "Can't find PointIds" << endl;
		return;
	}
	vtkDataArray* scalars = inputSeed->GetPointData()->GetScalars(scalarName.c_str());
	if (scalars == NULL) {
		cout << "Can't find scalars: " << scalarName << endl;
		return;
	}
	
	vtkDoubleArray* outputScalars = vtkDoubleArray::New();
	outputScalars->SetName(scalarName.c_str());
	for (int i = 0; i < pointIds->GetNumberOfTuples(); i++) {
		int ptId = pointIds->GetTuple1(i);
		double value = scalars->GetTuple1(ptId);
		outputScalars->InsertNextTuple1(value);
	}
	inputStream->GetCellData()->AddArray(outputScalars);
	
	if (opts.GetBool("-zrotate")) {
		cout << "The output is rotated!" << endl;
		vio.zrotate(inputStream);
	}
	vio.writeFile(outputStreamFile, inputStream);
}
开发者ID:fayhot,项目名称:gradworks,代码行数:47,代码来源:vtkUtils.cpp

示例4: runStreamLineThreshold

/// @brief Apply a filter to each stream line
void runStreamLineThreshold(Options& opts, StringVector& args) {
	string inputStream = args[0];
	string inputSeeds = args[1];
	string outputStreamFile = args[2];
	string scalarName = opts.GetString("-scalarName");
	
	double lowThreshold = opts.GetStringAsReal("-thresholdMin", DBL_MIN);
	double highThreshold = opts.GetStringAsReal("-thresholdMax", DBL_MAX);
	
	vtkIO vio;
	vtkPolyData* streamLines = vio.readFile(inputStream);
	vtkPolyData* streamSeeds = vio.readFile(inputSeeds);
	
	vtkPolyData* outputStream = vtkPolyData::New();
	outputStream->SetPoints(streamLines->GetPoints());
	
	/// - Lookup SeedId and a given scalar array
	vtkDataArray* seedList = streamLines->GetCellData()->GetScalars("SeedId");
	vtkDataArray* seedScalars = streamSeeds->GetPointData()->GetScalars(scalarName.c_str());
	vtkCellArray* lines = vtkCellArray::New();
	vtkDoubleArray* filteredScalars = vtkDoubleArray::New();
	filteredScalars->SetName(scalarName.c_str());
	filteredScalars->SetNumberOfComponents(1);
	
	/// - Lookup a corresponding point scalar, apply threashold filter, and add to the new object
	for (int i = 0; i < seedList->GetNumberOfTuples(); i++) {
		int seedId = seedList->GetTuple1(i);
		double value = seedScalars->GetTuple1(seedId);
		
		if (lowThreshold <= value && value <= highThreshold) {
			lines->InsertNextCell(streamLines->GetCell(i));
			filteredScalars->InsertNextValue(value);
		}
	}
	
	outputStream->SetLines(lines);
	outputStream->GetCellData()->AddArray(filteredScalars);
	outputStream->BuildCells();
	outputStream->BuildLinks();
	
	vio.writeFile(outputStreamFile, outputStream);
}
开发者ID:fayhot,项目名称:gradworks,代码行数:43,代码来源:vtkUtils.cpp

示例5: main

int main(int argc, char* argv[]) {
    Options argParser;
    argParser.addOption("-i", "print image information as ImageStat --info option", SO_NONE);
    argParser.addOption("-e", "The equation to compute each output pixel.", "-e (A+B)", SO_REQ_SEP);
    argParser.addOption("-o", "output filename (the same data type with the last input)", "-o output.nrrd", SO_REQ_SEP);
    argParser.addOption("-h", "print this message", SO_NONE);

    StringVector args = argParser.ParseOptions(argc, argv, NULL);
    string eq = argParser.GetString("-e");
    string outputFilename = argParser.GetString("-o");
    
    if (argParser.GetBool("-i") && args.size() > 0) {
        ImageInfo lastImageInfo;
        imgIo.ReadCastedImage(args[0], lastImageInfo);
        printf("Filename: %s\n", args[0].c_str());
        printf("Dims: %d %d %d\n", lastImageInfo.dimensions[0], lastImageInfo.dimensions[1], lastImageInfo.dimensions[2]);
        printf("Pixdims: %.2f %.2f %.2f\n", lastImageInfo.spacing[0], lastImageInfo.spacing[1], lastImageInfo.spacing[2]);
        printf("Origins: %.2f %.2f %.2f\n", lastImageInfo.origin[0], lastImageInfo.origin[1], lastImageInfo.origin[2]);
        return 0;
    }

    if (argParser.GetBool("-h") || eq == "" || args.size() == 0 || outputFilename == "") {
        cout << "## kcalc usage \n"
            "\tkcalc [-e equation] [-o output-file] input1:A input2:B ...\n\n"
            "The kcalc performs a pixel-wise arithmetic. The pixel value of each input image is given as variables, A,B,C,D, and E. Several functions implemented in [MuParser](http://muparser.beltoforion.de/) includes +,-,*,/, and ? as well as trigonometric functions.\n\n"
            "Also, there are the min, max values of each input image for the use of scaling and other purposes, which are given as AMIN, AMAX, BMIN, BMAX, and etc.\n\n"
            "Note that the output data type is the same with the last input file. The order of images may produce different results, if images with different types are used.\n\n"
            "Some examples are:\n"
            "* **Addition**: kcalc -e \"(A+B)\" input1.nrrd input2.nrrd -o output.nrrd\n"
            "* **Averaging**: kcalc -e \"(A+B)/2\" input1.nrrd input2.nrrd -o output.nrrd\n"
            "* **Thresholding**: kcalc -e \"(A>10?1:0)\" input.nrrd -o output.nrrd\n"
            "* **Scaling**: -e (A-AMIN)/AMAX*255\n"
            "* **Masking**: -e (A==8?B:0)\n"
            "* ...\n\n"
            "### Options\n";
        argParser.PrintUsage();
        cout << endl;
        return 0;
    }

    if (argParser.GetBool("-2")) {
        cout << "Working on 2D images" << endl;
        ImageIO<Image2D> io2;
        ImageInfo lastImageInfo;
        PixelMathImageFilter<Image2D, Image2D>::Pointer pixelFilter = PixelMathImageFilter<Image2D, Image2D>::New();
        pixelFilter->SetEquation(eq);
        for (int i = 0; i < args.size(); i++) {
            pixelFilter->PushBackInput(io2.ReadCastedImage(args[i], lastImageInfo));
        }
        try {
            pixelFilter->Update();
        } catch (itk::ExceptionObject& e) {
            cout << e.what() << endl;
        }
        io2.WriteCastedImage(outputFilename, pixelFilter->GetOutput(), lastImageInfo.componenttype);
    } else {
        ImageInfo lastImageInfo;
        PixelMathImageFilter<ImageType, ImageType>::Pointer pixelFilter = PixelMathImageFilter<ImageType, ImageType>::New();
        pixelFilter->SetEquation(eq);
        for (int i = 0; i < args.size(); i++) {
            pixelFilter->PushBackInput(imgIo.ReadCastedImage(args[i], lastImageInfo));
        }
        try {
            pixelFilter->Update();
        } catch (itk::ExceptionObject& e) {
            cout << e.what() << endl;
        }

        imgIo.WriteCastedImage(outputFilename, pixelFilter->GetOutput(), lastImageInfo.componenttype);
    }
    return 0;
}
开发者ID:fayhot,项目名称:gradworks,代码行数:72,代码来源:kcalc.cpp


注:本文中的Options::GetString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。