1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #ifndef CLITKBOOLEANOPERATORLABELIMAGEFILTER_H
20 #define CLITKBOOLEANOPERATORLABELIMAGEFILTER_H
22 #include "itkInPlaceImageFilter.h"
23 #include "itkImageRegionIteratorWithIndex.h"
27 //--------------------------------------------------------------------
29 Perform boolan operation between two mask images. Like itkAnd and
30 others, but take care of:
31 - origin of the images (spacing must be equal)
32 - in place or not output
33 - Binary or Label images as inputs. Label i BG only ; Binary is FG only
35 - NO THREAD -> I dont know how (yet) to manage two different inputRegionForThread
38 //--------------------------------------------------------------------
40 template <class TInputImage1, class TInputImage2=TInputImage1, class TOutputImage=TInputImage1>
41 class ITK_EXPORT BooleanOperatorLabelImageFilter:
42 public itk::InPlaceImageFilter<TInputImage1, TOutputImage> {
45 /** Standard class typedefs. */
46 typedef BooleanOperatorLabelImageFilter Self;
47 typedef itk::InPlaceImageFilter<TInputImage1,TOutputImage> Superclass;
48 typedef itk::SmartPointer<Self> Pointer;
49 typedef itk::SmartPointer<const Self> ConstPointer;
51 /** Method for creation through the object factory. */
54 /** Run-time type information (and related methods). */
55 itkTypeMacro(BooleanOperatorLabelImageFilter, InPlaceImageFilter);
57 /** Some convenient typedefs. */
58 typedef TInputImage1 Input1ImageType;
59 typedef typename Input1ImageType::ConstPointer Input1ImageConstPointer;
60 typedef typename Input1ImageType::Pointer Input1ImagePointer;
61 typedef typename Input1ImageType::RegionType Input1ImageRegionType;
62 typedef typename Input1ImageType::PixelType Input1ImagePixelType;
64 typedef TInputImage2 Input2ImageType;
65 typedef typename Input2ImageType::ConstPointer Input2ImageConstPointer;
66 typedef typename Input2ImageType::Pointer Input2ImagePointer;
67 typedef typename Input2ImageType::RegionType Input2ImageRegionType;
68 typedef typename Input2ImageType::PixelType Input2ImagePixelType;
70 typedef TOutputImage OutputImageType;
71 typedef typename OutputImageType::Pointer OutputImagePointer;
72 typedef typename OutputImageType::RegionType OutputImageRegionType;
73 typedef typename OutputImageType::PixelType OutputImagePixelType;
75 /** Connect one of the operands for pixel-wise addition */
76 void SetInput1( const TInputImage1 * image1);
78 /** Connect one of the operands for pixel-wise addition */
79 void SetInput2( const TInputImage2 * image2);
81 // Set type of operation
86 } OperationTypeEnumeration;
87 itkGetMacro(OperationType, OperationTypeEnumeration);
88 itkSetMacro(OperationType, OperationTypeEnumeration);
90 // LabelImage information (BG and FG)
91 void SetBackgroundValue1(Input1ImagePixelType p);
92 void SetBackgroundValue2(Input2ImagePixelType p);
93 void SetBackgroundValue(OutputImagePixelType p);
94 void SetForegroundValue(OutputImagePixelType p);
96 /** ImageDimension constants */
97 itkStaticConstMacro(InputImage1Dimension, unsigned int, TInputImage1::ImageDimension);
98 itkStaticConstMacro(InputImage2Dimension, unsigned int, TInputImage2::ImageDimension);
99 itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
101 // I dont want to verify inputs information
102 virtual void VerifyInputInformation() { }
105 BooleanOperatorLabelImageFilter();
106 virtual ~BooleanOperatorLabelImageFilter() {}
108 virtual void GenerateOutputInformation();
109 virtual void GenerateInputRequestedRegion();
110 virtual void GenerateData();
112 // Do not release date to keep input in memory and continue ...
113 virtual void ReleaseInputs() { }
115 Input1ImagePixelType mBackgroundValue1;
116 Input2ImagePixelType mBackgroundValue2;
117 OutputImagePixelType mBackgroundValue;
118 OutputImagePixelType mForegroundValue;
120 Input1ImageRegionType input1Region;
121 Input2ImageRegionType input2Region;
122 OutputImageRegionType outputRegion;
124 OperationTypeEnumeration m_OperationType;
126 template<class Iter1, class Iter2> void LoopAndNot(Iter1 it1, Iter1 it2, Iter2 ot);
127 template<class Iter1, class Iter2> void LoopAnd(Iter1 it1, Iter1 it2, Iter2 ot);
128 template<class Iter1, class Iter2> void LoopOr(Iter1 it1, Iter1 it2, Iter2 ot);
131 BooleanOperatorLabelImageFilter(const Self&); //purposely not implemented
132 void operator=(const Self&); //purposely not implemented
135 //--------------------------------------------------------------------
137 } // end namespace clitk
138 //--------------------------------------------------------------------
140 #ifndef ITK_MANUAL_INSTANTIATION
141 #include "clitkBooleanOperatorLabelImageFilter.txx"