2 #include <tclap/CmdLine.h> 8 void eventCallback (itk::Object* caller,
const itk::EventObject& event,
void* clientData)
10 itk::ProcessObject * processObject = (itk::ProcessObject*) caller;
11 std::cout<<
"\033[K\rProgression: "<<(int)(processObject->GetProgress() * 100)<<
"%"<<std::flush;
14 int main(
int argc,
char **argv)
16 TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
18 TCLAP::ValueArg<std::string> dataLTArg(
"i",
"database",
"Database Image List",
true,
"",
"database image list",cmd);
20 TCLAP::ValueArg<std::string> maskArg(
"m",
"maskname",
"Computation mask",
true,
"",
"computation mask",cmd);
21 TCLAP::ValueArg<std::string> resArg(
"o",
"outputmean",
"Average distance output image",
true,
"",
"Average distance output image",cmd);
23 TCLAP::ValueArg<std::string> resStdArg(
"O",
"outputstd",
"Standard deviation output image",
false,
"",
"Standard deviation output image",cmd);
25 TCLAP::ValueArg<unsigned int> nbpArg(
"p",
"numberofthreads",
"Number of threads to run on (default: all cores)",
false,itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(),
"number of threads",cmd);
27 TCLAP::ValueArg<unsigned int> patchHSArg(
"",
"patchhalfsize",
"Patch half size in each direction (default: 1)",
false,1,
"patch half size",cmd);
33 catch (TCLAP::ArgException& e)
35 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
39 typedef itk::VectorImage<double,3> LogTensorImageType;
42 itk::CStyleCommand::Pointer callback = itk::CStyleCommand::New();
45 MainFilterType::Pointer mainFilter = MainFilterType::New();
46 mainFilter->SetComputationMask(
anima::readImage < itk::Image <unsigned char, 3> > (maskArg.getValue()));
47 mainFilter->SetNumberOfWorkUnits(nbpArg.getValue());
49 mainFilter->SetPatchHalfSize(patchHSArg.getValue());
50 mainFilter->AddObserver(itk::ProgressEvent(), callback);
52 std::ifstream fileIn(dataLTArg.getValue());
54 unsigned int count = 0;
58 fileIn.getline(tmpStr,2048);
60 if (strcmp(tmpStr,
"") == 0)
63 std::cout <<
"Loading database image " << tmpStr <<
"..." << std::endl;
64 mainFilter->SetInput(count,anima::readImage <LogTensorImageType> (tmpStr));
73 catch(itk::ExceptionObject &e)
75 std::cerr << e << std::endl;
79 anima::writeImage < itk::Image <double, 3> > (resArg.getValue(),mainFilter->GetOutput(0));
81 if (resStdArg.getValue() !=
"")
82 anima::writeImage < itk::Image <double, 3> > (resStdArg.getValue(),mainFilter->GetOutput(1));
void eventCallback(itk::Object *caller, const itk::EventObject &event, void *clientData)
int main(int argc, char **argv)
void writeImage(std::string filename, OutputImageType *img)
itk::SmartPointer< ImageType > readImage(std::string filename)