1 /*=========================================================================
4 Module: $RCSfile: bbitkImageProperties.cxx,v $
6 Date: $Date: 2008/04/18 12:59:50 $
7 Version: $Revision: 1.3 $
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.
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.
17 =========================================================================*/
24 #include "bbitkImageProperties.h"
25 #include "bbitkPackage.h"
29 BBTK_BLACK_BOX_IMPLEMENTATION(ImageProperties,bbtk::AtomicBlackBox);
31 BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageProperties);
36 void ImageProperties::DoIt()
38 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(),DoIt);
46 template<class itkImageType>
47 void ImageProperties::DoIt()
49 bbtkDebugMessageInc("Core",9,"bbitk::ImageProperties::DoIt<"
50 <<bbtk::TypeName<itkImageType>()
53 itkImageType* im = bbGetInputIn().get<itkImageType*>();
54 unsigned int dim = im->GetImageDimension();
56 bbSetOutputTypeName(bbtk::TypeName<typename itkImageType::PixelType>());
57 bbSetOutputDimension(dim);
58 const typename itkImageType::RegionType& r =im->GetLargestPossibleRegion();
59 bbSetOutputLargestPossibleRegion(r);
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);
66 const typename itkImageType::SizeType& sz = r.GetSize();
68 for (int i=0;i<dim;++i) vsz.push_back(sz[i]);
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);
76 bbtkDebugDecTab("Core",9);