]> Creatis software - clitk.git/blob - tools/clitkMinMaxMask.cxx
Precision on clitkBlurImage help
[clitk.git] / tools / clitkMinMaxMask.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18
19 // clitk
20 #include "clitkMinMaxMask_ggo.h"
21 #include "clitkIO.h"
22 #include "clitkImageCommon.h"
23 #include "clitkCommon.h"
24 #include "itkConstSliceIterator.h"
25 #include "itkImageRegionIteratorWithIndex.h"
26
27 //--------------------------------------------------------------------
28 int main(int argc, char * argv[])
29 {
30
31   // Init command line
32   GGO(clitkMinMaxMask, args_info);
33   CLITK_INIT;
34
35   typedef short PixelType;
36   static const int Dim=3;
37   typedef itk::Image<PixelType, Dim> ImageType;
38
39   ImageType::Pointer input1;
40   ImageType::Pointer input2;
41   input1 = clitk::readImage<ImageType>(args_info.input1_arg, false);
42   input2 = clitk::readImage<ImageType>(args_info.input2_arg, false);
43   
44   typedef itk::ImageRegionIteratorWithIndex<ImageType> IteratorType;
45   IteratorType it = IteratorType(input1, input1->GetLargestPossibleRegion());
46   it.GoToBegin();
47   ImageType::IndexType first1=it.GetIndex();
48   ImageType::IndexType last1=it.GetIndex();
49   bool firstFound = false;
50   while (!it.IsAtEnd()) {
51     if (!firstFound) {
52       if (it.Get() == 1) {
53         firstFound = true;
54         first1 = it.GetIndex();
55       }
56     }
57     else {
58       if (it.Get() == 1) {
59         last1 = it.GetIndex();
60       }
61     }
62     ++it;
63   }
64   
65   // typedef itk::ImageRegionIteratorWithIndex<ImageType> IteratorType;
66   it = IteratorType(input2, input2->GetLargestPossibleRegion());
67   it.GoToBegin();
68   ImageType::IndexType first2=it.GetIndex();
69   ImageType::IndexType last2=it.GetIndex();
70   firstFound = false;
71   while (!it.IsAtEnd()) {
72     if (!firstFound) {
73       if (it.Get() == 1) {
74         firstFound = true;
75         first2 = it.GetIndex();
76       }
77     }
78     else {
79       if (it.Get() == 1) {
80         last2 = it.GetIndex();
81       }
82     }
83     ++it;
84   }
85   
86   std::cout << " --i1 " << first1[2] << " --f1 " << last1[2]
87             << " --i2 " << first2[2] << " --f2 " << last2[2] << std::endl;
88
89   return EXIT_SUCCESS;
90 } // This is the end, my friend
91 //--------------------------------------------------------------------