本文整理汇总了C++中Options::ParseOptions方法的典型用法代码示例。如果您正苦于以下问题:C++ Options::ParseOptions方法的具体用法?C++ Options::ParseOptions怎么用?C++ Options::ParseOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options::ParseOptions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
/**
* This program generates a sphere (closed surface, vtkPolyData) and converts it into volume
* representation (vtkImageData) where the foreground voxels are 1 and the background voxels are
* 0. Internally vtkPolyDataToImageStencil is utilized. The resultant image is saved to disk
* in metaimage file format (SphereVolume.mhd).
*/
int main(int argc, char * argv[])
{
/*
vtkSmartPointer<vtkSphereSource> sphereSource =
vtkSmartPointer<vtkSphereSource>::New();
sphereSource->SetRadius(20);
sphereSource->SetPhiResolution(30);
sphereSource->SetThetaResolution(30);
vtkSmartPointer<vtkPolyData> pd = sphereSource->GetOutput();
sphereSource->Update();
*/
Options opts;
opts.addOption("--v", "voxelize a given mesh into a binary image [mesh] [refimage] [outimage]", SO_NONE);
opts.addOption("--m", "create a binary image with a mark per point [mesh] [refimage] [outimage]", SO_NONE);
StringVector args = opts.ParseOptions(argc, argv, NULL);
if (opts.GetBool("--v")) {
runScanConversion(opts, args);
} else if (opts.GetBool("--m")) {
runPointMarks(opts, args);
}
}
示例2: main
int main(int argc, char* argv[]) {
CSimpleOpt::SOption specs[] = {
{ 0, "-o", SO_REQ_SEP },
SO_END_OF_OPTIONS
};
Options argParser;
StringVector args = argParser.ParseOptions(argc, argv, specs);
if (args.size() < 1) {
cout << argv[0] << " [input-vector] [output-rgb]" << endl;
return 1;
}
ImageIO<DeformFieldImageType> io;
DeformFieldImageType::Pointer img = io.ReadImage(args[0]);
// itk::UnaryFunctorImageFilter<DeformFieldImageType,RGBImageType> CastFilter;
typedef itk::UnaryFunctorImageFilter<DeformFieldImageType, RGBImageType, Vector2RGB> CastFilter;
CastFilter::Pointer caster = CastFilter::New();
caster->SetInput(img);
caster->Update();
RGBImageType::Pointer rgbImg = caster->GetOutput();
rgbImg->Print(cout);
io.WriteImageS<RGBImageType>(args[1], rgbImg);
return 0;
}
示例3: 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);
}
}
示例4: main
int main(int argc, char* argv[]) {
CSimpleOpt::SOption spec[] = {
{ 10, "--ncctest", SO_NONE },
SO_END_OF_OPTIONS
};
Options parser;
StringVector& args = parser.ParseOptions(argc, argv, spec);
if (parser.GetBool("--ncctest")) {
itkNormalizedCorrelationImageMetricTest(0,NULL);
return 0;
}
}
示例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;
}