diff --git a/Core/Code/DataManagement/mitkImageCastPart3.cpp b/Core/Code/DataManagement/mitkImageCastPart3.cpp index 30bb5fe7a4..a095c4b26f 100644 --- a/Core/Code/DataManagement/mitkImageCastPart3.cpp +++ b/Core/Code/DataManagement/mitkImageCastPart3.cpp @@ -1,121 +1,123 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include #include #include #include namespace mitk { #ifndef DOXYGEN_SKIP template < typename TPixel, unsigned int VImageDimension, class ItkOutputImageType > void _CastToItkImage2Access( itk::Image* itkInputImage, itk::SmartPointer& itkOutputImage) { typedef itk::Image ItkInputImageType; if(typeid(ItkInputImageType) == typeid(ItkOutputImageType)) { itkOutputImage = reinterpret_cast(itkInputImage); return; } typedef itk::CastImageFilter< ItkInputImageType, ItkOutputImageType > CastImageFilterType; typename CastImageFilterType::Pointer castImageFilter = CastImageFilterType::New(); castImageFilter->SetInput( itkInputImage ); castImageFilter->Update(); itkOutputImage = castImageFilter->GetOutput(); } #endif //DOXYGEN_SKIP typedef itk::Image, 2> itkImageRGBUC2; typedef itk::Image, 2> itkImageDTIF2; typedef itk::Image, 2> itkImageDTID2; template void MITK_CORE_EXPORT _CastToItkImage2Access(itkImageRGBUC2*, itk::SmartPointer&); template void MITK_CORE_EXPORT _CastToItkImage2Access(itkImageDTIF2*, itk::SmartPointer&); template void MITK_CORE_EXPORT _CastToItkImage2Access(itkImageDTID2*, itk::SmartPointer&); typedef itk::Image, 3> itkImageRGBUC3; +typedef itk::Image, 3> itkImageRGBF3; typedef itk::Image, 3> itkImageDTIF3; typedef itk::Image, 3> itkImageDTID3; template void MITK_CORE_EXPORT _CastToItkImage2Access(itkImageRGBUC3*, itk::SmartPointer&); +template void MITK_CORE_EXPORT _CastToItkImage2Access(itkImageRGBF3*, itk::SmartPointer&); template void MITK_CORE_EXPORT _CastToItkImage2Access(itkImageDTIF3*, itk::SmartPointer&); template void MITK_CORE_EXPORT _CastToItkImage2Access(itkImageDTID3*, itk::SmartPointer&); #define CAST_HUNDRED_VECS(HUN) \ CAST_TEN_VECS(HUN) \ CAST_TEN_VECS(HUN+10) \ CAST_TEN_VECS(HUN+20) \ CAST_TEN_VECS(HUN+30) \ CAST_TEN_VECS(HUN+40) \ CAST_TEN_VECS(HUN+50) \ CAST_TEN_VECS(HUN+60) \ CAST_TEN_VECS(HUN+70) \ CAST_TEN_VECS(HUN+80) \ CAST_TEN_VECS(HUN+90) \ #define CAST_TEN_VECS(TEN) \ CAST_N_VEC(TEN+ 1) \ CAST_N_VEC(TEN+ 2) \ CAST_N_VEC(TEN+ 3) \ CAST_N_VEC(TEN+ 4) \ CAST_N_VEC(TEN+ 5) \ CAST_N_VEC(TEN+ 6) \ CAST_N_VEC(TEN+ 7) \ CAST_N_VEC(TEN+ 8) \ CAST_N_VEC(TEN+ 9) \ CAST_N_VEC(TEN+10) \ #define CAST_N_VEC(N_DIRS) \ _CAST_N_VEC(N_DIRS,double) \ _CAST_N_VEC(N_DIRS,float) \ _CAST_N_VEC(N_DIRS,short) \ #define _CAST_N_VEC(N_DIRS,PIXTYPE) \ template void MITK_CORE_EXPORT _CastToItkImage2Access(itk::Image, 2> *, itk::SmartPointer, 2> >&); \ template void MITK_CORE_EXPORT _CastToItkImage2Access(itk::Image, 3> *, itk::SmartPointer, 3> >&); \ // the following lines allow for fixed-size vector images up to a certain size limit // (commented out for shorter compile times) //CAST_HUNDRED_VECS(0) //CAST_HUNDRED_VECS(100) //CAST_HUNDRED_VECS(200) //CAST_HUNDRED_VECS(300) // allow for fixed-size vectors of specific length // (inspired by itkPointshell.cpp, precompiled q-ball configs) //CAST_TEN_VECS(0) //CAST_N_VEC(11) //CAST_N_VEC(12) CAST_N_VEC(2) CAST_N_VEC(3) CAST_N_VEC(6) CAST_N_VEC(42) CAST_N_VEC(92) CAST_N_VEC(162) CAST_N_VEC(252) CAST_N_VEC(362) CAST_N_VEC(492) CAST_N_VEC(642) CAST_N_VEC(812) CAST_N_VEC(1002) } diff --git a/Core/Code/DataManagement/mitkImageCastPart4.cpp b/Core/Code/DataManagement/mitkImageCastPart4.cpp index 7503af1702..7d0cb5c6ef 100644 --- a/Core/Code/DataManagement/mitkImageCastPart4.cpp +++ b/Core/Code/DataManagement/mitkImageCastPart4.cpp @@ -1,154 +1,163 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include #include #include #include namespace mitk { #ifndef DOXYGEN_SKIP template void CastToItkImage(const mitk::Image * mitkImage, itk::SmartPointer& itkOutputImage) { AccessFixedDimensionByItk_1(mitkImage, _CastToItkImage2Access, (ItkOutputImageType::ImageDimension), itkOutputImage); } #endif //DOXYGEN_SKIP typedef itk::Image, 2> itkImageRGBUC2; typedef itk::Image, 2> itkImageDTIF2; typedef itk::Image, 2> itkImageDTID2; template <> void MITK_CORE_EXPORT CastToItkImage(const mitk::Image * mitkImage, itk::SmartPointer& itkOutputImage) { typedef itkImageRGBUC2 ItkOutputImageType; AccessFixedTypeByItk_1(mitkImage, _CastToItkImage2Access, (itk::RGBPixel), (ItkOutputImageType::ImageDimension), itkOutputImage); } template <> void MITK_CORE_EXPORT CastToItkImage(const mitk::Image * mitkImage, itk::SmartPointer& itkOutputImage) { typedef itkImageDTIF2 ItkOutputImageType; AccessFixedTypeByItk_1(mitkImage, _CastToItkImage2Access, (itk::DiffusionTensor3D), (ItkOutputImageType::ImageDimension), itkOutputImage); } template <> void MITK_CORE_EXPORT CastToItkImage(const mitk::Image * mitkImage, itk::SmartPointer& itkOutputImage) { typedef itkImageDTID2 ItkOutputImageType; AccessFixedTypeByItk_1(mitkImage, _CastToItkImage2Access, (itk::DiffusionTensor3D), (ItkOutputImageType::ImageDimension), itkOutputImage); } typedef itk::Image, 3> itkImageRGBUC3; +typedef itk::Image, 3> itkImageRGBF3; typedef itk::Image, 3> itkImageDTIF3; typedef itk::Image, 3> itkImageDTID3; template <> void MITK_CORE_EXPORT CastToItkImage(const mitk::Image * mitkImage, itk::SmartPointer& itkOutputImage) { typedef itkImageRGBUC3 ItkOutputImageType; AccessFixedTypeByItk_1(mitkImage, _CastToItkImage2Access, (itk::RGBPixel), (ItkOutputImageType::ImageDimension), itkOutputImage); } + +template <> void MITK_CORE_EXPORT CastToItkImage(const mitk::Image * mitkImage, itk::SmartPointer& itkOutputImage) +{ + typedef itkImageRGBF3 ItkOutputImageType; + AccessFixedTypeByItk_1(mitkImage, _CastToItkImage2Access, (itk::RGBPixel), (ItkOutputImageType::ImageDimension), itkOutputImage); +} + + template <> void MITK_CORE_EXPORT CastToItkImage(const mitk::Image * mitkImage, itk::SmartPointer& itkOutputImage) { typedef itkImageDTIF3 ItkOutputImageType; AccessFixedTypeByItk_1(mitkImage, _CastToItkImage2Access, (itk::DiffusionTensor3D), (ItkOutputImageType::ImageDimension), itkOutputImage); } template <> void MITK_CORE_EXPORT CastToItkImage(const mitk::Image * mitkImage, itk::SmartPointer& itkOutputImage) { typedef itkImageDTID3 ItkOutputImageType; AccessFixedTypeByItk_1(mitkImage, _CastToItkImage2Access, (itk::DiffusionTensor3D), (ItkOutputImageType::ImageDimension), itkOutputImage); } #define TYPE_VECS(HUN) \ TYPE_TEN_VECS(HUN) \ TYPE_TEN_VECS(HUN + 10) \ TYPE_TEN_VECS(HUN + 20) \ TYPE_TEN_VECS(HUN + 30) \ TYPE_TEN_VECS(HUN + 40) \ TYPE_TEN_VECS(HUN + 50) \ TYPE_TEN_VECS(HUN + 60) \ TYPE_TEN_VECS(HUN + 70) \ TYPE_TEN_VECS(HUN + 80) \ TYPE_TEN_VECS(HUN + 90) \ #define TYPE_TEN_VECS(HUN) \ TYPE_N_VEC(HUN + 1) \ TYPE_N_VEC(HUN + 2) \ TYPE_N_VEC(HUN + 3) \ TYPE_N_VEC(HUN + 4) \ TYPE_N_VEC(HUN + 5) \ TYPE_N_VEC(HUN + 6) \ TYPE_N_VEC(HUN + 7) \ TYPE_N_VEC(HUN + 8) \ TYPE_N_VEC(HUN + 9) \ TYPE_N_VEC(HUN + 10) \ #define TYPE_N_VEC(N_DIRS) \ _TYPE_N_VEC(N_DIRS,double) \ _TYPE_N_VEC(N_DIRS,float) \ _TYPE_N_VEC(N_DIRS,short) \ #define _TYPE_N_VEC(N_DIRS,PIXTYPE) \ template <> void MITK_CORE_EXPORT CastToItkImage, 2> >(const mitk::Image * mitkImage, itk::SmartPointer, 2> >& itkOutputImage) \ { \ typedef itk::Vector VECTORTYPE; \ typedef itk::Image ItkOutputImageType2; \ AccessFixedTypeByItk_1(mitkImage, _CastToItkImage2Access, (VECTORTYPE), (ItkOutputImageType2::ImageDimension), itkOutputImage); \ } \ template <> void MITK_CORE_EXPORT CastToItkImage, 3> >(const mitk::Image * mitkImage, itk::SmartPointer, 3> >& itkOutputImage) \ { \ typedef itk::Vector VECTORTYPE; \ typedef itk::Image ItkOutputImageType3; \ AccessFixedTypeByItk_1(mitkImage, _CastToItkImage2Access, (VECTORTYPE), (ItkOutputImageType3::ImageDimension), itkOutputImage); \ } \ // the following lines allow for fixed-size vector images up to a certain size limit // (commented out for shorter compile times) //TYPE_VECS(000) //TYPE_VECS(100) //TYPE_VECS(200) //TYPE_VECS(300) //TYPE_VECS(400) //TYPE_VECS(500) //TYPE_VECS(600) //TYPE_VECS(700) // allow for fixed-size vectors of specific length // (inspired by itkPointshell.cpp, precompiled q-ball configs) //TYPE_TEN_VECS(0) //TYPE_N_VEC(11) //TYPE_N_VEC(12) TYPE_N_VEC(2) TYPE_N_VEC(3) TYPE_N_VEC(6) TYPE_N_VEC(42) TYPE_N_VEC(92) TYPE_N_VEC(162) TYPE_N_VEC(252) TYPE_N_VEC(362) TYPE_N_VEC(492) TYPE_N_VEC(642) TYPE_N_VEC(812) TYPE_N_VEC(1002) #ifndef DOXYGEN_SKIP #endif //DOXYGEN_SKIP }