本文整理汇总了C++中GetPot::size方法的典型用法代码示例。如果您正苦于以下问题:C++ GetPot::size方法的具体用法?C++ GetPot::size怎么用?C++ GetPot::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GetPot
的用法示例。
在下文中一共展示了GetPot::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char *argv[])
{
const unsigned int ImageDimension = 2;
GetPot cl (argc, const_cast<char**>(argv));
if( cl.size() == 1 || cl.search (2,"--help","-h") )
{
std::cout << "Not Enough Arguments" << std::endl;
std::cout << "Generate the Gradient Table" << std::endl;
std::cout << "Usage: return -1" << std::endl;
}
const string image_n = cl.follow("NoFile",1, "-i");
const string out_n = cl.follow("NoFile",1, "-o");
typedef itk::DiffusionTensor3D<float> DiffusionTensorType;
typedef itk::Image<DiffusionTensorType, 3> ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(image_n);
reader->Update();
ImageType::Pointer image = reader->GetOutput();
typedef itk::ImageRegionIterator<ImageType> TensorIterator;
TensorIterator itImg(image, image->GetLargestPossibleRegion());
std::ofstream file;
file.open(out_n);
for(itImg.GoToBegin(); !itImg.IsAtEnd(); ++itImg)
{
file << itImg.Get() << std::endl;
}
file.close();
return 0;
}
示例2: main
int main (int argc, char *argv[])
{
GetPot cl (argc, const_cast<char**>(argv));
if( cl.size() == 1 || cl.search (2,"--help","-h") )
{
std::cout << "Not Enough Arguments" << std::endl;
std::cout << "Scales the tensors with a scalar factor" << std::endl;
std::cout << "Usage: -trueB0 <true B0> -m <MaskImage> -true <True Tensors> -f <flag for extended gradient> -t <initial tensor estimate> -g <gradient> -o <Output File> -s <Sigma> -nm <Noise Model> -Sim <intelligent COnvergence>" << std::endl;
return -1;
}
const string image_n =cl.follow("NoFile", 1, "-i");
const string out_n = cl.follow("NoFile", 1, "-o");
const int idx = cl.follow(0, 1, "-ix");
const int idy = cl.follow(0, 1, "-iy");
const int idz = cl.follow(0, 1, "-iz");
const int sx = cl.follow(0, 1, "-sx");
const int sy = cl.follow(0, 1, "-sy");
const int sz = cl.follow(0, 1, "-sz");
typedef itk::Image< float, 3> ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(image_n);
reader->Update();
ImageType::Pointer image = reader->GetOutput();
ImageType::SizeType size;
ImageType::IndexType id;
id[0] = idx; id[1] = idy; id[2] = idz;
size[0] = sx; size[1] = sy; size[2] =sz;
ImageType::RegionType region(id, size);
typedef itk::ExtractImageFilter<ImageType, ImageType> FilterType;
FilterType::Pointer filter = FilterType::New();
filter->SetExtractionRegion(region);
filter->SetInput(image);
filter->SetDirectionCollapseToIdentity();
filter->Update();
ImageType::Pointer exImage = filter ->GetOutput();
typedef itk::ImageFileWriter<ImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(out_n);
writer->SetInput(exImage);
writer->Update();
return 0;
}
示例3: main
int main(int argc, char *argv[])
{
GetPot cl (argc, const_cast<char**>(argv));
if( cl.size() == 1 || cl.search (2,"--help","-h") )
{
std::cout << "Not Enough Arguments" << std::endl;
std::cout << "Generate the Gradient Table" << std::endl;
std::cout << "Usage: return -1" << std::endl;
}
// One idea is to apply the rotation matrix
const string Linear_trans_n = cl.follow("NoFile",1,"-t");
const string ref_Image_n = cl.follow("NoFile",1, "-r");
const string out_n = cl.follow("NoFile",1,"-o");
const string B0_n =cl.follow("NoFile",1,"-B0");
const string T1_n =cl.follow("NoFile",1,"-T1");
typedef itk::Image<float, 3> ImageType;
typedef itk::ImageFileReader<ImageType> ImageReaderType;
ImageReaderType::Pointer imageReaderB0 = ImageReaderType::New();
imageReaderB0->SetFileName(B0_n);
imageReaderB0->Update();
std::cout << imageReaderB0->GetOutput()->GetDirection() << std::endl;
ImageReaderType::Pointer imageReaderT1 = ImageReaderType::New();
imageReaderT1->SetFileName(B0_n);
imageReaderT1->Update();
std::cout << imageReaderT1->GetOutput()->GetDirection() << std::endl;
// typedef itk::TransformFileReader TransformFileReaderType;
// typedef TransformFileReaderType::TransformListType TransformListType;
// typedef itk::TransformBase TransformBaseType;
// typedef itk::AffineTransform<double, 3> AffineTransformType;
//
// typedef itk::Image<float, 3> ImageType;
// typedef itk::ImageFileReader<ImageType> ImageReaderType;
// ImageReaderType::Pointer imageReader = ImageReaderType::New();
//
// imageReader->SetFileName(ref_Image_n);
// imageReader->Update();
// ImageType::Pointer refImage = imageReader->GetOutput();
//
//
//
// TransformFileReaderType::Pointer readerTransform = TransformFileReaderType::New();
// readerTransform->SetFileName(Linear_trans_n);
// readerTransform -> Update();
// TransformListType *list = readerTransform->GetTransformList();
// TransformBaseType * transform = list->front().GetPointer();
// TransformBaseType::ParametersType parameters = transform->GetParameters();
// AffineTransformType::Pointer transform_fwd = AffineTransformType::New();
// transform_fwd->SetParameters(parameters);
//
// std::cout << transform_fwd->GetParameters() << std::endl;
// typedef itk::Vector< float, 3 > VectorPixelType;
// typedef itk::Image< VectorPixelType, 3 > DisplacementFieldImageType;
//
//
// typedef itk::TransformToDisplacementFieldFilter<DisplacementFieldImageType, double> DisplacementFieldGeneratorType;
// DisplacementFieldGeneratorType::Pointer dispfieldGenerator = DisplacementFieldGeneratorType::New();
//
// dispfieldGenerator->UseReferenceImageOn();
// dispfieldGenerator->SetReferenceImage( refImage );
// dispfieldGenerator->SetTransform( transform_fwd );
// dispfieldGenerator->Update();
// DisplacementFieldImageType::Pointer dispField = dispfieldGenerator->GetOutput();
//
// typedef itk::ImageFileWriter<DisplacementFieldImageType> DispFieldWriterType;
// DispFieldWriterType::Pointer writer = DispFieldWriterType::New();
// writer->SetFileName(out_n);
// writer->SetInput(dispField);
// writer->Update();
return 0;
}
示例4: main
int main (int argc, char *argv[])
{
GetPot cl (argc, const_cast<char**>(argv));
if( cl.size() == 1 || cl.search (2,"--help","-h") )
{
std::cout << "Not Enough Arguments" << std::endl;
std::cout << "Scales the tensors with a scalar factor" << std::endl;
std::cout << "Usage: -trueB0 <true B0> -m <MaskImage> -true <True Tensors> -f <flag for extended gradient> -t <initial tensor estimate> -g <gradient> -o <Output File> -s <Sigma> -nm <Noise Model> -Sim <intelligent COnvergence>" << std::endl;
return -1;
}
const string file_g_n = cl.follow("NoFile",1, "-g");
const string fileIn = cl.follow("NoFile",1,"-i");
const string fileIn_HR = cl.follow("NoFile",1,"-iHR");
const string B0_n = cl.follow("NoFile", 1, "-B0");
const string mask_LR_n = cl.follow("NoFile",1, "-mLR");
const int numOfIter = cl.follow(1,1, "-n");
const float kappa_L = cl.follow(0.05, 1, "-k");
const float lambda_L = cl.follow(0.25, 1, "-lamb_L");
const string B0Image_HR_n = cl.follow("NoFile", 1, "-B0HR");
const string dispField_n = cl.follow("NoFile",1,"-d");
const string T1Image_n = cl.follow("NoFile",1,"-T1");
const string mask_HR_n = cl.follow("NoFile", 1, "-mHR");
// Usual Typedefs
typedef float RealType;
const int ImageDim =3;
typedef itk::Image<RealType, ImageDim> ScalarImageType;
typedef itk::Vector<double, ImageDim> VectorType;
typedef itk::Image<VectorType, ImageDim> DeformationFieldType;
typedef itk::Image<VectorType, ImageDim> VectorImageType;
typedef itk::ImageFileReader<ScalarImageType> ScalarImageReaderType;
typedef itk::ImageFileWriter<ScalarImageType> ScalarImageWriterType;
//Read T1 image
ScalarImageReaderType::Pointer scalarReader = ScalarImageReaderType::New();
scalarReader->SetFileName(T1Image_n.c_str());
scalarReader->Update();
ScalarImageType::Pointer T1_image = scalarReader->GetOutput();
// Read LR ImageList
typedef std::vector<ScalarImageType::Pointer> ImageListType;
ImageListType DWIList;
std::ifstream file(fileIn.c_str());
int numOfImages = 0;
file >> numOfImages;
for (int i=0; i < numOfImages ; i++) // change of numOfImages
{
char filename[256];
file >> filename;
ScalarImageReaderType::Pointer myReader=ScalarImageReaderType::New();
myReader->SetFileName(filename);
std::cout << "Reading.." << filename << std::endl; // add a try catch block
myReader->Update();
DWIList.push_back( myReader->GetOutput() ); //using push back to create a stack of diffusion images
}
// Read deformation field
typedef itk::ImageFileReader<DeformationFieldType> DeformationFieldReaderType;
DeformationFieldReaderType::Pointer deformationFieldReader = DeformationFieldReaderType::New();
deformationFieldReader->SetFileName(dispField_n.c_str());
deformationFieldReader->Update();
DeformationFieldType::Pointer defField = deformationFieldReader->GetOutput();
// Read Mask Image Spatial
typedef itk::ImageMaskSpatialObject<ImageDim> MaskSpatialObjectType;
typedef MaskSpatialObjectType::ImageType MaskSpatialImageType;
typedef itk::ImageFileReader<MaskSpatialImageType> MaskSpatialImageReaderType;
MaskSpatialImageReaderType::Pointer spatialReader = MaskSpatialImageReaderType::New();
spatialReader->SetFileName(mask_LR_n.c_str());
spatialReader->Update();
MaskSpatialImageType::Pointer maskSpatialImage_LR = spatialReader->GetOutput();
//Read Mask Image Normal
ScalarImageReaderType::Pointer maskImageReader = ScalarImageReaderType::New();
maskImageReader->SetFileName(mask_LR_n.c_str());
maskImageReader->Update();
ScalarImageType::Pointer maskImage_LR = maskImageReader->GetOutput();
// Resample diffusion Images
/* typedef itk::WarpImageFilter<ScalarImageType, ScalarImageType, DeformationFieldType> WarpImageFilterType;
typedef itk::ImageFileWriter<ScalarImageType> ScalarImageWriterType;
//.........这里部分代码省略.........
示例5: main
int main (int argc, char *argv[])
{
const unsigned int ImageDimension = 2;
GetPot cl (argc, const_cast<char**>(argv));
if( cl.size() == 1 || cl.search (2,"--help","-h") )
{
std::cout << "Not Enough Arguments" << std::endl;
std::cout << "Generate the Gradient Table" << std::endl;
std::cout << "Usage: return -1" << std::endl;
}
const string image_n = cl.follow("NoFile",1, "-i");
const string mask_n = cl.follow("NoFile", 1, "-m");
const string out_n = cl.follow("NoFile",1, "-o");
typedef itk::DiffusionTensor3D<float> DiffusionTensorType;
typedef itk::Image<DiffusionTensorType, 3> TensorImageType;
typedef itk::ImageFileReader<TensorImageType> TensorReaderType;
TensorReaderType::Pointer reader = TensorReaderType::New();
reader->SetFileName(image_n.c_str());
reader->Update();
TensorImageType::Pointer image = reader->GetOutput();
typedef itk::Image<float, 3> ScalarImageType;
typedef itk::ImageFileReader<ScalarImageType> ScalarReaderType;
ScalarReaderType::Pointer scalarReader = ScalarReaderType::New();
scalarReader->SetFileName(mask_n.c_str());
scalarReader->Update();
ScalarImageType::Pointer maskImage = scalarReader->GetOutput();
typedef itk::ImageRegionIterator<TensorImageType> TensorIterator;
typedef itk::ImageRegionIterator<ScalarImageType> ScalarIterator;
ScalarIterator itMask(maskImage, maskImage->GetLargestPossibleRegion());
TensorUtilities utilsTensor;
TensorImageType::Pointer logTensorImage = utilsTensor.LogTensorImageFilter(image, maskImage);
typedef itk::ImageFileWriter<TensorImageType> TensorImageWriterType;
TensorImageWriterType::Pointer tensorImageWriter = TensorImageWriterType::New();
tensorImageWriter->SetFileName("LogTensorImage_stupid.nii.gz");
tensorImageWriter->SetInput(logTensorImage);
tensorImageWriter->Update();
std::ofstream file;
file.open(out_n);
ScalarImageType::Pointer TraceImage = ScalarImageType::New();
CopyImage cpImage;
cpImage.CopyScalarImage(maskImage, TraceImage);
ScalarIterator itTr(TraceImage, TraceImage->GetLargestPossibleRegion());
TensorIterator itImg(logTensorImage, logTensorImage->GetLargestPossibleRegion());
for(itImg.GoToBegin(), itMask.GoToBegin(), itTr.GoToBegin(); !itTr.IsAtEnd(), !itImg.IsAtEnd(), !itMask.IsAtEnd(); ++itTr, ++itImg, ++itMask)
{
file << itImg.Get().GetTrace() << std::endl;
itTr.Set(itImg.Get().GetTrace()) ;
}
typedef itk::ImageFileWriter<ScalarImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName("LogTense_Trace.nii.gz");
writer->SetInput(TraceImage);
writer->Update();
file.close();
return 0;
}