diff --git a/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.h b/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.h index 2e05ce8bba2fd04f955ad5be896d13f9c00e4c4f..d603a827269ea31cbe21b3dcb764ca36da648331 100644 --- a/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.h +++ b/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.h @@ -175,7 +175,7 @@ protected: unsigned int FillNeighborhoodHistogram(std::vector<std::pair<PixelType, unsigned int> >& histoNeigh, const NeighborhoodIteratorType &nit, const KernelIteratorType kernelBegin, - const KernelIteratorType kernelEnd); + const KernelIteratorType kernelEnd) const; struct CompareHistoFequencies { diff --git a/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.txx b/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.txx index 87d73068574c11e6ced39cfb889a203882ef8a48..d4e85ae8709b0c3d2a7dfc8ec7b88f5bff2a37f5 100644 --- a/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.txx +++ b/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.txx @@ -48,18 +48,17 @@ typename NeighborhoodMajorityVotingImageFilter<TInputImage, TOutputImage, TKernel>::PixelType NeighborhoodMajorityVotingImageFilter<TInputImage, TOutputImage, TKernel>::Evaluate(const NeighborhoodIteratorType &nit, const KernelIteratorType kernelBegin, - const KernelIteratorType kernelEnd) + const KernelIteratorType kernelEnd) { - PixelType majorityLabel = 0; //Value of the more representative pixels in the neighborhood - unsigned int majorityFreq = 0; //Number of pixels with the more representative value (majorityLabel) in the neighborhood - - PixelType centerPixel = nit.GetCenterPixel(); + const PixelType centerPixel = nit.GetCenterPixel(); + PixelType majorityLabel = centerPixel; //Value of the more representative pixels in the neighborhood + unsigned int majorityFreq = 1; //Number of pixels with the more representative value (majorityLabel) in the neighborhood if (centerPixel != m_LabelForNoDataPixels) { std::vector< std::pair<PixelType, unsigned int> > histoNeighVec; //Get a histogram of label frequencies where the 2 highest are at the beginning and sorted - unsigned int freqCenterLabel = this->FillNeighborhoodHistogram(histoNeighVec, nit, kernelBegin, kernelEnd); + const unsigned int freqCenterLabel = this->FillNeighborhoodHistogram(histoNeighVec, nit, kernelBegin, kernelEnd); if(m_OnlyIsolatedPixels && freqCenterLabel > m_IsolatedThreshold) { @@ -106,7 +105,7 @@ unsigned int NeighborhoodMajorityVotingImageFilter<TInputImage, TKernel>::FillNeighborhoodHistogram(std::vector<std::pair<PixelType, unsigned int> >& histoNeighVec, const NeighborhoodIteratorType &nit, const KernelIteratorType kernelBegin, - const KernelIteratorType kernelEnd) + const KernelIteratorType kernelEnd) const { std::map<PixelType, unsigned int> histoNeigh; PixelType centerPixel = nit.GetCenterPixel();