diff --git a/Code/BasicFilters/otbMeanShiftImageFilter2.h b/Code/BasicFilters/otbMeanShiftImageFilter2.h index 49b3a7935744d775427f57ada15ddb5fc68edc7f..37ed0f24406b3fbbafdc3f06bcf549986cc709e7 100644 --- a/Code/BasicFilters/otbMeanShiftImageFilter2.h +++ b/Code/BasicFilters/otbMeanShiftImageFilter2.h @@ -192,6 +192,7 @@ public: typedef TOutputIterationImage OutputIterationImageType; typedef otb::VectorImage<RealType, InputImageType::ImageDimension> OutputSpatialImageType; + typedef typename OutputSpatialImageType::Pointer OutputSpatialImagePointerType; typedef typename OutputSpatialImageType::PixelType OutputSpatialPixelType; typedef TKernel KernelType; diff --git a/Code/BasicFilters/otbMeanShiftImageFilter2.txx b/Code/BasicFilters/otbMeanShiftImageFilter2.txx index 17c1abb6ddb3c2a3dd203d8b150f60a1eacb41fc..175ac0c961f681462ace1e8ca8bfab43c72c9c0a 100644 --- a/Code/BasicFilters/otbMeanShiftImageFilter2.txx +++ b/Code/BasicFilters/otbMeanShiftImageFilter2.txx @@ -41,7 +41,7 @@ MeanShiftImageFilter2<TInputImage, TOutputImage, TKernel, TNorm, TOutputMetricIm m_ModeSearchOptimization = true; this->SetNumberOfOutputs(4); - this->SetNthOutput(0, OutputImageType::New()); + this->SetNthOutput(0, OutputSpatialImageType::New()); this->SetNthOutput(1, OutputImageType::New()); this->SetNthOutput(2, OutputMetricImageType::New()); this->SetNthOutput(3, OutputIterationImageType::New()); @@ -214,15 +214,11 @@ MeanShiftImageFilter2<TInputImage, TOutputImage, TKernel, TNorm, TOutputMetricIm Superclass::GenerateInputRequestedRegion(); // Retrieve input pointers - TInputImage * inPtr = const_cast<TInputImage *>(this->GetInput()); - - TOutputMetricImage * outMetricPtr = this->GetMetricOutput(); - OutputSpatialImageType * outSpatialPtr = this->GetSpatialOutput(); - TOutputImage * outRangePtr = this->GetRangeOutput(); - OutputIterationImageType * outIterationPtr = this->GetIterationOutput(); + InputImagePointerType inPtr = const_cast<TInputImage *>(this->GetInput()); + OutputImagePointerType outRangePtr = this->GetRangeOutput(); // Check pointers before using them - if(!inPtr || !outMetricPtr || !outSpatialPtr || !outRangePtr || !outIterationPtr) + if ( !inPtr || !outRangePtr ) { return; } @@ -230,7 +226,7 @@ MeanShiftImageFilter2<TInputImage, TOutputImage, TKernel, TNorm, TOutputMetricIm // Retrieve requested region (TODO: check if we need to handle // region for outHDispPtr) - RegionType outputRequestedRegion = outMetricPtr->GetRequestedRegion(); + RegionType outputRequestedRegion = outRangePtr->GetRequestedRegion(); // spatial and range radius may differ, padding must be done with the largest. //unsigned int largestRadius= this->GetLargestRadius(); @@ -278,10 +274,10 @@ MeanShiftImageFilter2<TInputImage, TOutputImage, TKernel, TNorm, TOutputMetricIm typedef itk::ImageRegionConstIteratorWithIndex<InputImageType> InputIteratorWithIndexType; typedef itk::ImageRegionIterator<RealVectorImageType> JointImageIteratorType; - TOutputMetricImage * outMetricPtr = this->GetMetricOutput(); - OutputSpatialImageType * outSpatialPtr = this->GetSpatialOutput(); - TOutputImage * outRangePtr = this->GetRangeOutput(); - typename InputImageType::ConstPointer inputPtr = this->GetInput(); + OutputMetricImagePointerType outMetricPtr = this->GetMetricOutput(); + OutputSpatialImagePointerType outSpatialPtr = this->GetSpatialOutput(); + OutputImagePointerType outRangePtr = this->GetRangeOutput(); + typename InputImageType::ConstPointer inputPtr = this->GetInput(); InputIndexType index;