17 #ifndef __itkLaplacianSharpeningImageFilter_txx
18 #define __itkLaplacianSharpeningImageFilter_txx
31 template<
class TInputImage,
class TOutputImage >
36 Superclass::PrintSelf(os,indent);
37 os << indent <<
"UseImageSpacing = " << m_UseImageSpacing << std::endl;
41 template <
class TInputImage,
class TOutputImage>
48 Superclass::GenerateInputRequestedRegion();
52 const_cast< TInputImage *
> ( this->GetInput() );
65 typename TInputImage::RegionType inputRequestedRegion;
66 inputRequestedRegion = inputPtr->GetRequestedRegion();
69 inputRequestedRegion.PadByRadius( oper.
GetRadius() );
72 if ( inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()) )
74 inputPtr->SetRequestedRegion( inputRequestedRegion );
83 inputPtr->SetRequestedRegion( inputRequestedRegion );
86 InvalidRequestedRegionError e(__FILE__, __LINE__);
88 e.
SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
94 template<
class TInputImage,
class TOutputImage >
101 double s[ImageDimension];
102 for (
unsigned i = 0; i < ImageDimension; i++)
104 if (this->GetInput()->GetSpacing()[i] == 0.0 )
106 itkExceptionMacro( <<
"Image spacing cannot be zero" );
110 s[i] = 1.0 / this->GetInput()->GetSpacing()[i];
121 typename NOIF::Pointer filter = NOIF::New();
122 filter->OverrideBoundaryCondition(static_cast<typename NOIF::ImageBoundaryConditionPointerType>(&nbc));
126 progress->SetMiniPipelineFilter(
this);
130 progress->RegisterInternalFilter(filter,0.8f);
135 filter->SetOperator(oper);
136 filter->SetInput(this->GetInput());
138 ->SetRequestedRegion( this->GetOutput()->GetRequestedRegion() );
149 inputCalculator->SetImage(this->GetInput());
150 inputCalculator->SetRegion(this->GetOutput()->GetRequestedRegion());
151 inputCalculator->Compute();
153 filteredCalculator->SetImage(filter->GetOutput());
154 filteredCalculator->SetRegion(this->GetOutput()->GetRequestedRegion());
155 filteredCalculator->Compute();
157 RealType inputShift, inputScale, filteredShift, filteredScale;
158 inputShift =
static_cast<RealType>(inputCalculator->GetMinimum());
159 inputScale =
static_cast<RealType>(inputCalculator->GetMaximum())
160 - static_cast<RealType>(inputCalculator->GetMinimum());
162 filteredShift = filteredCalculator->GetMinimum();
163 filteredScale = filteredCalculator->GetMaximum()
164 - filteredCalculator->GetMinimum();
167 it(filter->GetOutput(), filter->GetOutput()->GetRequestedRegion());
169 inIt(this->GetInput(), this->GetOutput()->GetRequestedRegion());
175 while ( !it.IsAtEnd() )
180 value = (value - filteredShift) / filteredScale;
183 value = value * inputScale + inputShift;
188 value = invalue - value;
192 enhancedSum += value;
197 /
static_cast<RealType>(this->GetOutput()->GetRequestedRegion()
198 .GetNumberOfPixels());
200 /
static_cast<RealType>(this->GetOutput()->GetRequestedRegion()
201 .GetNumberOfPixels());
204 this->UpdateProgress( 0.9 );
207 typename TOutputImage::Pointer output = this->GetOutput();
208 output->SetBufferedRegion(output->GetRequestedRegion());
211 RealType inputMinimum = inputCalculator->GetMinimum();
212 RealType inputMaximum = inputCalculator->GetMaximum();
220 output->GetRequestedRegion());
228 value = value - enhancedMean + inputMean;
230 if (value < inputMinimum)
232 outIt.
Set( castInputMinimum );
234 else if (value > inputMaximum)
236 outIt.
Set( castInputMaximum );
240 outIt.
Set( static_cast<OutputPixelType>(value) );
248 this->UpdateProgress( 1.0 );