// Set type of operation
typedef enum {
And = 0,
- AndNot = 1
+ AndNot = 1,
+ Or = 2
} OperationTypeEnumeration;
itkGetMacro(OperationType, OperationTypeEnumeration);
itkSetMacro(OperationType, OperationTypeEnumeration);
virtual void GenerateInputRequestedRegion();
virtual void GenerateData();
- virtual void ReleaseInputs() { } // Do not release date to keep input in memory and continue ...
+ // Do not release date to keep input in memory and continue ...
+ virtual void ReleaseInputs() { }
Input1ImagePixelType mBackgroundValue1;
Input2ImagePixelType mBackgroundValue2;
template<class Iter1, class Iter2> void LoopAndNot(Iter1 it1, Iter1 it2, Iter2 ot);
template<class Iter1, class Iter2> void LoopAnd(Iter1 it1, Iter1 it2, Iter2 ot);
+ template<class Iter1, class Iter2> void LoopOr(Iter1 it1, Iter1 it2, Iter2 ot);
private:
BooleanOperatorLabelImageFilter(const Self&); //purposely not implemented
}
// Compute intersection bounding box (in physical coordinate) and regions (in pixel coordinate)
- // DD(input1->GetLargestPossibleRegion());
- // DD(input2->GetLargestPossibleRegion());
- // DD(outputImage->GetLargestPossibleRegion());
typedef itk::BoundingBox<unsigned long, Dim> BBType;
typename BBType::Pointer bbInput1 = BBType::New();
ComputeBBFromImageRegion<Input1ImageType>(input1, input1->GetLargestPossibleRegion(), bbInput1);
typename BBType::Pointer bbOutput = BBType::New();
ComputeBBFromImageRegion<OutputImageType>(outputImage, outputImage->GetLargestPossibleRegion(), bbOutput);
- // DD(bbInput1);
- // DD(bbInput2);
- // DD(bbOutput);
-
typename BBType::Pointer bb = BBType::New();
ComputeBBIntersection<Dim>(bb, bbInput1, bbInput2);
- // DD(bb);
ComputeBBIntersection<Dim>(bb, bb, bbOutput);
- // DD(bb);
ComputeRegionFromBB<Input1ImageType>(input1, bb, input1Region);
ComputeRegionFromBB<Input2ImageType>(input2, bb, input2Region);
ComputeRegionFromBB<OutputImageType>(outputImage, bb, outputRegion);
-
}
//--------------------------------------------------------------------
OutputImagePointer output = this->GetOutput(0);
// Get Region iterators
- // DD(input1Region);
- // DD(input2Region);
- // DD(outputRegion);
itk::ImageRegionConstIterator<Input1ImageType> it1(input1, input1Region);
itk::ImageRegionConstIterator<Input2ImageType> it2(input2, input2Region);
itk::ImageRegionIterator<OutputImageType> ot (output, outputRegion);
switch (m_OperationType) {
case AndNot: LoopAndNot(it1, it2, ot); break;
case And: LoopAnd(it1, it2, ot); break;
+ case Or: LoopOr(it1, it2, ot); break;
}
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
LOOP_BEGIN(LoopAndNot)
- if ((it1.Get() != mBackgroundValue1) && (it2.Get() == mBackgroundValue2)) { ot.Set(mForegroundValue); }
+ if ((it1.Get() != mBackgroundValue1) && (it2.Get() == mBackgroundValue2))
+ { ot.Set(mForegroundValue); }
else { ot.Set(mBackgroundValue); }
LOOP_END
//--------------------------------------------------------------------
//--------------------------------------------------------------------
LOOP_BEGIN(LoopAnd)
- if ((it1.Get() != mBackgroundValue1) && (it2.Get() != mBackgroundValue2)) { ot.Set(mForegroundValue); }
+ if ((it1.Get() != mBackgroundValue1) && (it2.Get() != mBackgroundValue2))
+ { ot.Set(mForegroundValue); }
+ else { ot.Set(mBackgroundValue); }
+ LOOP_END
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ LOOP_BEGIN(LoopOr)
+ if ((it1.Get() != mBackgroundValue1) || (it2.Get() != mBackgroundValue2))
+ { ot.Set(mForegroundValue); }
else { ot.Set(mBackgroundValue); }
LOOP_END
//--------------------------------------------------------------------