18 #ifndef __itkVanHerkGilWermanErodeDilateImageFilter_txx
19 #define __itkVanHerkGilWermanErodeDilateImageFilter_txx
29 template <
class TImage,
class TKernel,
class TFunction1>
36 template <
class TImage,
class TKernel,
class TFunction1>
44 template <
class TImage,
class TKernel,
class TFunction1>
52 if (!m_Kernel.GetDecomposable())
54 itkExceptionMacro(
"VanHerkGilWerman morphology only works with decomposable structuring elements");
59 itkExceptionMacro(
"No kernel set");
75 IReg.PadByRadius( m_Kernel.GetRadius() );
77 IReg.Crop( this->GetInput()->GetRequestedRegion() );
80 typename InputImageType::Pointer internalbuffer = InputImageType::New();
81 internalbuffer->SetRegions(IReg);
82 internalbuffer->Allocate();
88 unsigned int bufflength = 0;
89 for (
unsigned i = 0; i<TImage::ImageDimension; i++)
91 bufflength += IReg.GetSize()[i];
101 typename KernelType::DecompType decomposition = m_Kernel.GetLines();
104 typedef typename KernelType::LType KernelLType;
106 for (
unsigned i = 0; i < decomposition.size(); i++)
108 typename KernelType::LType ThisLine = decomposition[i];
110 unsigned int SELength = GetLinePixels<KernelLType>(ThisLine);
115 InputImageRegionType BigFace = MakeEnlargedFace<InputImageType, KernelLType>(input, IReg, ThisLine);
117 DoFace<TImage, BresType, TFunction1, KernelLType>(input, output, m_Boundary, ThisLine,
118 TheseOffsets, SELength,
120 reverse, IReg, BigFace);
123 input = internalbuffer;
124 progress.CompletedPixel();
129 IterType oit(this->GetOutput(), OReg);
130 IterType iit(internalbuffer, OReg);
131 for (oit.GoToBegin(), iit.GoToBegin(); !oit.IsAtEnd(); ++oit, ++iit)
135 progress.CompletedPixel();
143 template<
class TImage,
class TKernel,
class TFunction1>
148 Superclass::PrintSelf(os, indent);
149 os << indent <<
"Boundary: " << m_Boundary << std::endl;
153 template<
class TImage,
class TKernel,
class TFunction1>
159 Superclass::GenerateInputRequestedRegion();
162 typename Superclass::InputImagePointer inputPtr =
163 const_cast< TImage *
>( this->GetInput() );
172 typename TImage::RegionType inputRequestedRegion;
173 inputRequestedRegion = inputPtr->GetRequestedRegion();
176 inputRequestedRegion.PadByRadius( m_Kernel.GetRadius() );
179 if ( inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()) )
181 inputPtr->SetRequestedRegion( inputRequestedRegion );
190 inputPtr->SetRequestedRegion( inputRequestedRegion );
195 msg << static_cast<const char *>(this->GetNameOfClass())
196 <<
"::GenerateInputRequestedRegion()";
198 e.
SetDescription(
"Requested region is (at least partially) outside the largest possible region.");