1 /*=========================================================================
4 Module: $RCSfile: bbitkImageProperties.cxx,v $
6 Date: $Date: 2008/07/23 12:02:15 $
7 Version: $Revision: 1.5 $
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"
31 BBTK_BLACK_BOX_IMPLEMENTATION(ImageProperties,bbtk::AtomicBlackBox);
33 BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageProperties);
38 void ImageProperties::DoIt()
40 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(),DoIt);
48 template<class itkImageType>
49 void ImageProperties::DoIt()
51 bbtkDebugMessageInc("Core",9,"bbitk::ImageProperties::DoIt<"
52 <<bbtk::TypeName<itkImageType>()
56 itkImageType* im = bbGetInputIn().get<itkImageType*>();
57 unsigned int dim = im->GetImageDimension();
59 bbSetOutputTypeName(bbtk::TypeName<typename itkImageType::PixelType>());
60 bbSetOutputDimension(dim);
61 const typename itkImageType::RegionType& r =im->GetLargestPossibleRegion();
62 bbSetOutputLargestPossibleRegion(r);
64 const typename itkImageType::IndexType& ind = r.GetIndex();
65 std::vector<int> vind;
66 for (unsigned int i=0;i<dim;++i) vind.push_back(ind[i]);
67 bbSetOutputIndex(vind);
69 const typename itkImageType::SizeType& sz = r.GetSize();
71 for (unsigned int i=0;i<dim;++i) vsz.push_back(sz[i]);
74 typename itkImageType::SpacingType sp = im->GetSpacing();
75 std::vector<float> vsp;
76 for (unsigned int i=0;i<dim;++i) vsp.push_back(sp[i]);
77 bbSetOutputSpacing(vsp);
79 bbtkDebugDecTab("Core",9);