]> Creatis software - clitk.git/blob - tools/clitkImageInfo.cxx
Increase number of decimal for fusion and overlay
[clitk.git] / tools / clitkImageInfo.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    =================================================
20    * @file   clitkImageInfo.cxx
21    * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
22    * @date   02 Jul 2006
23    =================================================*/
24
25 // itk include
26 #include "itkImageIOBase.h"
27
28 // clitk include
29 #include "clitkImageInfo_ggo.h"
30 #include "clitkIO.h"
31 #include "clitkImageCommon.h"
32 #include "clitkCommon.h"
33 #include "vvImageReader.h"
34
35 //====================================================================
36 int main(int argc, char * argv[])
37 {
38
39   // init command line
40   GGO(clitkImageInfo, args_info);
41   CLITK_INIT;
42
43   // check arg
44   if (args_info.inputs_num == 0) return 0;
45
46   // read Header
47   for(unsigned int i=0; i<args_info.inputs_num; i++) {
48     itk::ImageIOBase::Pointer header = clitk::readImageHeader(args_info.inputs[i]);
49     if (header) {
50       if (args_info.name_flag) std::cout << "[" << args_info.inputs[i] << "]\t ";
51       if (args_info.long_given) {
52         //      std::cout << std::endl;
53         clitk::printImageHeader(header, std::cout, args_info.long_arg);
54       } else {
55         if (args_info.verbose_flag) clitk::printImageHeader(header, std::cout, 1);
56         else {
57           clitk::printImageHeader(header, std::cout, 0);
58           std::cout << std::endl;
59         }
60       }
61     }  // heade null ; non fatal error
62     else {
63       std::cerr << "*** Warning : I could not read '" << args_info.inputs[i] << "' ***" << std::endl;
64     }
65
66     if (args_info.matrix_flag) {
67       vvImageReader::Pointer r = vvImageReader::New();
68       r->SetInputFilename(args_info.inputs[i]);
69       r->Update(vvImageReader::IMAGE);
70       vtkMatrix4x4 * m = r->GetOutput()->GetTransform()[0]->GetMatrix();
71       for(int i=0; i<4; i++) {
72         for(int j=0; j<4; j++)
73           std::cout << m->GetElement(i,j) << " ";
74         std::cout << std::endl;
75       }
76
77       // inverse
78       m->Invert();
79       for(int i=0; i<4; i++) {
80         for(int j=0; j<4; j++)
81           std::cout << m->GetElement(i,j) << " ";
82         std::cout << std::endl;
83       }
84
85     }
86   } // end for
87
88
89   // this is the end my friend
90   return 0;
91 }
92 //====================================================================