From 3c7871c3c0b11b8289ae2c10b71d22c0a1b182be Mon Sep 17 00:00:00 2001 From: dsarrut Date: Wed, 30 Jun 2010 06:15:08 +0000 Subject: [PATCH 1/1] min max (to remove) --- tools/clitkMinMaxMask.cxx | 90 +++++++++++++++++++++++++++++++++++++++ tools/clitkMinMaxMask.ggo | 10 +++++ 2 files changed, 100 insertions(+) create mode 100644 tools/clitkMinMaxMask.cxx create mode 100644 tools/clitkMinMaxMask.ggo diff --git a/tools/clitkMinMaxMask.cxx b/tools/clitkMinMaxMask.cxx new file mode 100644 index 0000000..8a41a8a --- /dev/null +++ b/tools/clitkMinMaxMask.cxx @@ -0,0 +1,90 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ + +// clitk +#include "clitkMinMaxMask_ggo.h" +#include "clitkIO.h" +#include "clitkImageCommon.h" +#include "itkConstSliceIterator.h" +#include "itkImageRegionIteratorWithIndex.h" + +//-------------------------------------------------------------------- +int main(int argc, char * argv[]) +{ + + // Init command line + GGO(clitkMinMaxMask, args_info); + CLITK_INIT; + + typedef short PixelType; + static const int Dim=3; + typedef itk::Image ImageType; + + ImageType::Pointer input1; + ImageType::Pointer input2; + input1 = clitk::readImage(args_info.input1_arg, false); + input2 = clitk::readImage(args_info.input2_arg, false); + + typedef itk::ImageRegionIteratorWithIndex IteratorType; + IteratorType it = IteratorType(input1, input1->GetLargestPossibleRegion()); + it.GoToBegin(); + ImageType::IndexType first1=it.GetIndex(); + ImageType::IndexType last1=it.GetIndex(); + bool firstFound = false; + while (!it.IsAtEnd()) { + if (!firstFound) { + if (it.Get() == 1) { + firstFound = true; + first1 = it.GetIndex(); + } + } + else { + if (it.Get() == 1) { + last1 = it.GetIndex(); + } + } + ++it; + } + + // typedef itk::ImageRegionIteratorWithIndex IteratorType; + it = IteratorType(input2, input2->GetLargestPossibleRegion()); + it.GoToBegin(); + ImageType::IndexType first2=it.GetIndex(); + ImageType::IndexType last2=it.GetIndex(); + firstFound = false; + while (!it.IsAtEnd()) { + if (!firstFound) { + if (it.Get() == 1) { + firstFound = true; + first2 = it.GetIndex(); + } + } + else { + if (it.Get() == 1) { + last2 = it.GetIndex(); + } + } + ++it; + } + + std::cout << " --i1 " << first1[2] << " --f1 " << last1[2] + << " --i2 " << first2[2] << " --f2 " << last2[2] << std::endl; + + return EXIT_SUCCESS; +} // This is the end, my friend +//-------------------------------------------------------------------- diff --git a/tools/clitkMinMaxMask.ggo b/tools/clitkMinMaxMask.ggo new file mode 100644 index 0000000..8ffc357 --- /dev/null +++ b/tools/clitkMinMaxMask.ggo @@ -0,0 +1,10 @@ +#File clitkExtractLungs.ggo +package "clitkMinMaxMask" +version "1.0" +purpose "ssdfgsfg ssdf g." + +option "config" - "Config file" string no +option "verbose" v "Verbose" flag off + +option "input1" i "Input mask image filename" string yes +option "input2" j "Input mask image filename" string yes -- 2.46.1