]> Creatis software - bbtk.git/blob - packages/itk/src/bbitkImageProperties.cxx
=== MAJOR RELEASE ====
[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/04/18 12:59:50 $
7   Version:   $Revision: 1.3 $
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 namespace bbitk 
28 {
29   BBTK_BLACK_BOX_IMPLEMENTATION(ImageProperties,bbtk::AtomicBlackBox);
30
31   BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageProperties);
32
33
34
35
36   void ImageProperties::DoIt()
37   {
38     BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(),DoIt);
39   }
40
41
42
43   /** 
44       Template Processing 
45   */
46   template<class itkImageType>
47   void ImageProperties::DoIt()
48   {
49     bbtkDebugMessageInc("Core",9,"bbitk::ImageProperties::DoIt<"
50                         <<bbtk::TypeName<itkImageType>()
51                         <<">()"<<std::endl);
52
53     itkImageType* im = bbGetInputIn().get<itkImageType*>();
54     unsigned int dim = im->GetImageDimension();
55
56     bbSetOutputTypeName(bbtk::TypeName<typename itkImageType::PixelType>());
57     bbSetOutputDimension(dim);
58     const typename itkImageType::RegionType& r =im->GetLargestPossibleRegion();
59     bbSetOutputLargestPossibleRegion(r);
60
61     const typename itkImageType::IndexType& ind = r.GetIndex();
62     std::vector<int> vind;
63     for (int i=0;i<dim;++i) vind.push_back(ind[i]);
64     bbSetOutputIndex(vind);
65
66     const typename itkImageType::SizeType& sz = r.GetSize();
67     std::vector<int> vsz;
68     for (int i=0;i<dim;++i) vsz.push_back(sz[i]);
69     bbSetOutputSize(vsz);
70
71     typename itkImageType::SpacingType sp = im->GetSpacing();
72     std::vector<float> vsp;
73     for (int i=0;i<dim;++i) vsp.push_back(sp[i]);
74     bbSetOutputSpacing(vsp);
75
76     bbtkDebugDecTab("Core",9);
77   }
78
79
80
81
82
83
84 }
85 // eo namespace bbtk
86
87 #endif