]> Creatis software - bbtk.git/blob - packages/itk/src/bbitkImageProperties.cxx
*** empty log message ***
[bbtk.git] / packages / itk / src / bbitkImageProperties.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbitkImageProperties.cxx,v $
5   Language:  C++
6   Date:      $Date: 2008/06/19 09:46:44 $
7   Version:   $Revision: 1.4 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18 /**
19  *  \file 
20  *  \brief 
21  */
22 #ifdef _USE_ITK_
23
24 #include "bbitkImageProperties.h"
25 #include "bbitkPackage.h"
26
27
28
29 namespace bbitk 
30 {
31   BBTK_BLACK_BOX_IMPLEMENTATION(ImageProperties,bbtk::AtomicBlackBox);
32
33   BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageProperties);
34
35
36
37
38   void ImageProperties::DoIt()
39   {
40     BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(),DoIt);
41   }
42
43
44
45   /** 
46       Template Processing 
47   */
48   template<class itkImageType>
49   void ImageProperties::DoIt()
50   {
51     bbtkDebugMessageInc("Core",9,"bbitk::ImageProperties::DoIt<"
52                         <<bbtk::TypeName<itkImageType>()
53                         <<">()"<<std::endl);
54
55
56         itkImageType* im = bbGetInputIn().get<itkImageType*>();
57     unsigned int dim = im->GetImageDimension();
58
59     bbSetOutputTypeName(bbtk::TypeName<typename itkImageType::PixelType>());
60     bbSetOutputDimension(dim);
61     const typename itkImageType::RegionType& r =im->GetLargestPossibleRegion();
62     bbSetOutputLargestPossibleRegion(r);
63
64     const typename itkImageType::IndexType& ind = r.GetIndex();
65     std::vector<int> vind;
66     for (int i=0;i<dim;++i) vind.push_back(ind[i]);
67     bbSetOutputIndex(vind);
68
69     const typename itkImageType::SizeType& sz = r.GetSize();
70     std::vector<int> vsz;
71     for (int i=0;i<dim;++i) vsz.push_back(sz[i]);
72     bbSetOutputSize(vsz);
73
74     typename itkImageType::SpacingType sp = im->GetSpacing();
75     std::vector<float> vsp;
76     for (int i=0;i<dim;++i) vsp.push_back(sp[i]);
77     bbSetOutputSpacing(vsp);
78
79     bbtkDebugDecTab("Core",9);
80   }
81
82
83
84
85
86
87 }
88 // eo namespace bbtk
89
90 #endif