1 #include <tclap/CmdLine.h> 3 #include <itkHistogramMatchingImageFilter.h> 14 template <
class ComponentType,
unsigned int InputDim>
19 typedef itk::Image<ComponentType, InputDim> ImageType;
20 typedef itk::HistogramMatchingImageFilter<ImageType,ImageType> HistogramMatchingFilterType;
22 typename HistogramMatchingFilterType::Pointer mainFilter = HistogramMatchingFilterType::New();
23 mainFilter->SetReferenceImage(anima::readImage<ImageType>(args.
reference));
24 mainFilter->SetInput(anima::readImage<ImageType>(args.
moving));
25 mainFilter->SetNumberOfHistogramLevels(args.
nlevels);
26 mainFilter->SetNumberOfMatchPoints(args.
npoints);
27 mainFilter->SetNumberOfWorkUnits(args.
nthreads);
30 anima::writeImage<ImageType>(args.
output, mainFilter->GetOutput());
33 template <
class ComponentType>
40 int main(
int argc,
char **argv)
42 TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
44 TCLAP::ValueArg<std::string> refArg(
"r",
"referencefile",
"Reference image",
true,
"",
"reference image",cmd);
45 TCLAP::ValueArg<std::string> movArg(
"m",
"movingfile",
"Moving image",
true,
"",
"moving image",cmd);
46 TCLAP::ValueArg<std::string> outArg(
"o",
"outputfile",
"output image",
true,
"",
"output image",cmd);
48 TCLAP::ValueArg<unsigned int> nlvlArg(
"",
"nhl",
"Number of histogram levels (default: 100)",
false,100,
"number of histogram levels",cmd);
49 TCLAP::ValueArg<unsigned int> nptsArg(
"",
"nmp",
"Number of match points (default: 15)",
false,15,
"number of match points",cmd);
51 TCLAP::ValueArg<unsigned int> nbpArg(
"p",
"numberofthreads",
"Number of threads to run on (default: all cores)",
false,itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(),
"number of threads",cmd);
57 catch (TCLAP::ArgException& e)
59 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
64 itk::ImageIOBase::Pointer
imageIO = itk::ImageIOFactory::CreateImageIO(refArg.getValue().c_str(),itk::ImageIOFactory::ReadMode);
68 std::cerr <<
"Itk could not find a suitable IO factory for the input" << std::endl;
73 imageIO->SetFileName(refArg.getValue());
74 imageIO->ReadImageInformation();
79 args.
moving = movArg.getValue();
80 args.
output = outArg.getValue();
81 args.
nlevels = nlvlArg.getValue();
82 args.
npoints = nptsArg.getValue();
89 catch (itk::ExceptionObject &err)
91 std::cerr << err << std::endl;
int main(int argc, char **argv)
itk::ImageIOBase::Pointer imageIO
void standardize(itk::ImageIOBase::Pointer imageIO, const arguments &args)
#define ANIMA_RETRIEVE_COMPONENT_TYPE(imageIO, function,...)
void retrieveNbDimensions(itk::ImageIOBase::Pointer imageIO, const arguments &args)
#define ANIMA_RETRIEVE_NUMBER_OF_DIMENSIONS(imageIO, ComponentType, function,...)