FusionHelper.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #include "Common.h"
  3. #include <io.h>
  4. #include <direct.h>
  5. #include <itkImage.h>
  6. #include <itkImportImageFilter.h>
  7. #include <itkTranslationTransform.h>
  8. #include <itkRegularStepGradientDescentOptimizerv4.h>
  9. #include <itkCorrelationImageToImageMetricv4.h>
  10. #include <itkGradientDifferenceImageToImageMetric.h>
  11. #include <itkImageRegistrationMethodv4.h>
  12. #include <itkImageRegistrationMethod.h>
  13. #include <itkMetaImageIO.h>
  14. #include <itkImageFileWriter.h>
  15. #include <itkExtractImageFilter.h>
  16. #include <itkRescaleIntensityImageFilter.h>
  17. #include <itkBMPImageIO.h>
  18. #include <itkFlipImageFilter.h>
  19. #include <itkDiscreteGaussianImageFilter.h>
  20. #include <itkRegionOfInterestImageFilter.h>
  21. #include "ITKCommand.h"
  22. using PixelType = float;
  23. using VolumeImageType = itk::Image<PixelType, 3>;
  24. using SliceImageType = itk::Image<PixelType, 2>;
  25. using ImportFilterType = itk::ImportImageFilter<PixelType, 3>;
  26. using SizeType = ImportFilterType::SizeType;
  27. using IndexType = ImportFilterType::IndexType;
  28. using RegionType = ImportFilterType::RegionType;
  29. using OriginType = itk::SpacePrecisionType;
  30. using SpacingType = itk::SpacePrecisionType;
  31. using Transform3DType = itk::TranslationTransform<double, 3>;
  32. using Transform2DType = itk::TranslationTransform<double, 2>;
  33. using OutputPixelType = unsigned char;
  34. using OutputImageType = itk::Image<OutputPixelType, 3>;
  35. const bool ItkOwnTheBuffer = true;
  36. class FusionHelper
  37. {
  38. public:
  39. FusionHelper();
  40. ~FusionHelper();
  41. bool LoadBaseVolumeData(UniformVolumeDataInfo baseVolumeInfo);
  42. bool FuseWithAnotherVolumeData(UniformVolumeDataInfo anotherVolumeInfo);
  43. bool GetFusedVolumeData(UniformVolumeDataInfo& fusedVolumeInfo);
  44. private:
  45. ImportFilterType::Pointer CreateITKImageFromImportVolumeDatas(UniformVolumeDataInfo volumeInfo, bool flip=false);
  46. Transform3DType::ParametersType Get3DTransformationsWithCorrelationMetrics();
  47. Transform2DType::ParametersType Get2DTransformationsWithGradientDifferenceMetric(double translationZ);
  48. SliceImageType::Pointer ExtractOneFrame(VolumeImageType::Pointer image,int indexZ);
  49. void WriteMhaImage(VolumeImageType::Pointer image, std::string fileName);
  50. void WriteBmpImage(SliceImageType* image, std::string fileNmae);
  51. VolumeImageType::Pointer Translate3DImage(VolumeImageType::Pointer image,Transform3DType::OutputVectorType translation);
  52. ImportFilterType::Pointer ConcatTwoVolumeImageAlongX(VolumeImageType::Pointer oneImage, bool flipOneImage,
  53. VolumeImageType::Pointer anotherImage,bool flipAnotherImage);
  54. VolumeImageType::Pointer _fixedImage;
  55. VolumeImageType::Pointer _movingImage;
  56. ImportFilterType::Pointer _fixedImageImpporter;
  57. ImportFilterType::Pointer _movingImageImporter;
  58. float _spacing;
  59. ColorType _colorType;
  60. const std::string _outputFolderName = "Outputs";
  61. };