ANIMA  4.0
animaImageDataSplitter.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <string>
5 #include <itkVectorImage.h>
6 #include <itkImageFileReader.h>
7 #include <itkImage.h>
8 
9 namespace anima
10 {
11 template <class TInputImage> class ImageDataSplitter
12 {
13 public:
14  typedef itk::Image <unsigned char, 3> MaskImageType;
15  typedef typename TInputImage::IndexType TInputIndexType;
16  typedef typename TInputImage::RegionType TInputRegionType;
17  typedef typename TInputImage::Pointer TInputPointer;
18 
19  typedef itk::ImageFileReader <TInputImage> InputReaderType;
20  typedef typename InputReaderType::Pointer InputReaderPointer;
21 
22  typedef typename MaskImageType::Pointer MaskImagePointer;
25 
26  void SetUniqueFileName(std::string &inputFileName);
27 
28  void SetFileNames(std::string &inputFileList);
29  std::string GetFileName(unsigned int i) {return (i > m_FileNames.size() ? "" : m_FileNames[i]);}
30 
31  void SetComputationMask(MaskImageType::Pointer &maskIm);
32  void SetNumberOfBlocks(TInputIndexType &bNumBlocks);
33  void SetBlockIndex(TInputIndexType &bIndex);
34  void SetBlockMargin(TInputIndexType &bMargin);
35 
36  bool EmptyMask(TInputIndexType &bIndex);
37 
38  void Update();
39 
40  TInputRegionType GetSpecificBlockRegion(TInputIndexType &block);
41  TInputRegionType GetBlockRegion() {if (m_NeedsUpdate) this->Update(); return m_BlockRegion;}
42  TInputRegionType GetBlockRegionWithMargin() {if (m_NeedsUpdate) this->Update(); return m_BlockRegionWithMargin;}
43  TInputRegionType GetBlockRegionInsideMargin();
44 
45  MaskImageType *GetSmallMask() {if (m_NeedsUpdate) this->Update(); return m_SmallMask;}
46  MaskImageType *GetSmallMaskWithMargin() {if (m_NeedsUpdate) this->Update(); return m_SmallMaskWithMargin;}
47  TInputImage *GetOutput(unsigned int i) {if (m_NeedsUpdate) this->Update(); return m_Images[i];}
48  unsigned int GetNbImages() {return m_NbImages;}
49 
50 private:
51  unsigned int m_NbImages;
52  bool m_NeedsUpdate;
53  TInputIndexType m_NbBlocks;
54  TInputIndexType m_Block;
55  TInputIndexType m_Margin;
56 
57  TInputRegionType m_GlobalRegionOfInterest;
58  TInputRegionType m_BlockRegion, m_BlockRegionWithMargin;
59 
60  std::vector <TInputPointer> m_Images;
61  std::vector <std::string> m_FileNames;
62  MaskImagePointer m_MaskImage, m_SmallMask, m_SmallMaskWithMargin;
63 };
64 
65 } // end namespace anima
66 
68 
69 
void SetUniqueFileName(std::string &inputFileName)
itk::ImageFileReader< TInputImage > InputReaderType
TInputRegionType GetBlockRegionInsideMargin()
MaskImageType * GetSmallMaskWithMargin()
TInputImage::RegionType TInputRegionType
void SetFileNames(std::string &inputFileList)
void SetComputationMask(MaskImageType::Pointer &maskIm)
void SetBlockMargin(TInputIndexType &bMargin)
MaskImageType::Pointer MaskImagePointer
void SetBlockIndex(TInputIndexType &bIndex)
itk::Image< unsigned char, 3 > MaskImageType
void SetNumberOfBlocks(TInputIndexType &bNumBlocks)
TInputImage * GetOutput(unsigned int i)
TInputRegionType GetSpecificBlockRegion(TInputIndexType &block)
InputReaderType::Pointer InputReaderPointer
TInputRegionType GetBlockRegion()
std::string GetFileName(unsigned int i)
bool EmptyMask(TInputIndexType &bIndex)
TInputImage::Pointer TInputPointer
TInputRegionType GetBlockRegionWithMargin()
TInputImage::IndexType TInputIndexType