1 #include <tclap/CmdLine.h> 6 #include <itkVectorImage.h> 7 #include <itkImageRegionIterator.h> 11 int main(
int argc,
char **argv)
13 TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
15 TCLAP::ValueArg<std::string> geomArg(
"g",
"geometryfile",
"Geometry image",
true,
"",
"Geometry image",cmd);
16 TCLAP::ValueArg<std::string> outArg(
"o",
"outputfile",
"output image",
true,
"",
"output image",cmd);
17 TCLAP::ValueArg<unsigned int> vdimArg(
"v",
"vdim",
"Force vdim to this value",
false,1,
"Force vdim",cmd);
18 TCLAP::ValueArg<unsigned int> valueArg(
"b",
"buffervalue",
"Value to fill buffer",
false,0,
"Value to fill buffer",cmd);
20 TCLAP::SwitchArg vecArg(
"V",
"isvec",
"Input image is a vector / tensor image",cmd,
false);
26 catch (TCLAP::ArgException& e)
28 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
32 typedef itk::Image <double,3> ImageType;
33 typedef itk::VectorImage <double,3> VectorImageType;
35 bool isVect = vecArg.isSet();
36 unsigned int fvdim = vdimArg.getValue();
42 ImageType::Pointer geomImage = anima::readImage <ImageType> (geomArg.getValue());
44 ImageType::Pointer resImage = ImageType::New();
45 resImage->Initialize();
46 resImage->SetRegions(geomImage->GetLargestPossibleRegion());
47 resImage->SetSpacing(geomImage->GetSpacing());
48 resImage->SetOrigin(geomImage->GetOrigin());
49 resImage->SetDirection(geomImage->GetDirection());
52 resImage->FillBuffer(valueArg.getValue());
54 anima::writeImage <ImageType> (outArg.getValue(),resImage);
58 VectorImageType::Pointer geomImage = anima::readImage <VectorImageType> (geomArg.getValue());
60 VectorImageType::Pointer resImage = VectorImageType::New();
61 resImage->Initialize();
62 resImage->SetRegions(geomImage->GetLargestPossibleRegion());
63 resImage->SetSpacing(geomImage->GetSpacing());
64 resImage->SetOrigin(geomImage->GetOrigin());
65 resImage->SetDirection(geomImage->GetDirection());
67 itk::VariableLengthVector <double> tmpData;
68 unsigned int vdim = geomImage->GetNumberOfComponentsPerPixel();
72 resImage->SetNumberOfComponentsPerPixel(vdim);
75 tmpData.SetSize(vdim);
76 for (
unsigned int i = 0;i < vdim;++i)
77 tmpData[i] = valueArg.getValue();
79 itk::ImageRegionIterator <VectorImageType> tmpIt(resImage,resImage->GetLargestPossibleRegion());
81 while(!tmpIt.IsAtEnd())
87 anima::writeImage <VectorImageType> (outArg.getValue(),resImage);
int main(int argc, char **argv)