diff --git a/Code/BasicFilters/otbMeanShiftImageFilter2.h b/Code/BasicFilters/otbMeanShiftImageFilter2.h index ded460881051dffa583ffa0efda99851742a28e5..467652249aa521e48d27bf585e776af571794a19 100644 --- a/Code/BasicFilters/otbMeanShiftImageFilter2.h +++ b/Code/BasicFilters/otbMeanShiftImageFilter2.h @@ -101,7 +101,7 @@ public: typedef typename OutputMetricImageType::RegionType MetricRegionType; typedef unsigned int OutputIterationPixelType; - typedef otb::Image<OutputIterationPixelType, 2> OutputIterationImageType; + typedef otb::Image<OutputIterationPixelType, 2> OutputIterationImageType; typedef TKernel KernelType; diff --git a/Code/BasicFilters/otbMeanShiftImageFilter2.txx b/Code/BasicFilters/otbMeanShiftImageFilter2.txx index 16ce46f90bb9d4883cf94bd6c2e1e7ac258083e7..6ccb5405bc3abb7591c17ff50ea8c9a870927a3c 100644 --- a/Code/BasicFilters/otbMeanShiftImageFilter2.txx +++ b/Code/BasicFilters/otbMeanShiftImageFilter2.txx @@ -457,56 +457,56 @@ typename MeanShiftImageFilter2<TInputImage,TOutputMetricImage, TOutputImage, TKe // std::cout<<"it.Size "<<it->Size()<<std::endl; isInside=true; for(unsigned int comp=0; comp<rangeNumberOfComponents; comp++) - { - - neighborhoodValue=it->GetElement(comp+spatialNumberOfComponents); - if(vcl_abs(neighborhoodValue-rangePixel[comp])>m_SpectralBandwidth) - isInside=false; - } + { + + neighborhoodValue=it->GetElement(comp+spatialNumberOfComponents); + if(vcl_abs(neighborhoodValue-rangePixel[comp])>m_SpectralBandwidth) + isInside=false; + } - if(it->GetElement(boundaryWeightIndex) && isInside) - { - + if(it->GetElement(boundaryWeightIndex) && isInside) + { + for(unsigned int comp=0; comp<spatialNumberOfComponents; comp++) - { - neighborhoodValue=it->GetElement(comp); - //value=spatialIt->GetElement(comp); - value=1; - meanShiftVector[comp]+=(neighborhoodValue); - weightingMeanShiftVector[comp]+=value; - - } - for(unsigned int comp=0; comp<rangeNumberOfComponents; comp++) - { - neighborhoodValue=it->GetElement(comp+spatialNumberOfComponents); - //value=rangeIt->GetElement(comp); - value=1; - // meanShiftVector[spatialNumberOfComponents+comp]+=(neighborhoodValue-rangePixel[comp])*(neighborhoodValue-rangePixel[comp])*neighborhoodValue*value; - // weightingMeanShiftVector[spatialNumberOfComponents+comp]+=(neighborhoodValue-rangePixel[comp])*(neighborhoodValue-rangePixel[comp])*value; - meanShiftVector[spatialNumberOfComponents+comp]+=(neighborhoodValue); - weightingMeanShiftVector[spatialNumberOfComponents+comp]+=value; - } - - } - ++it; - ++rangeIt; - ++spatialIt; + { + neighborhoodValue=it->GetElement(comp); + //value=spatialIt->GetElement(comp); + value=1; + meanShiftVector[comp]+=(neighborhoodValue); + weightingMeanShiftVector[comp]+=value; + + } + for(unsigned int comp=0; comp<rangeNumberOfComponents; comp++) + { + neighborhoodValue=it->GetElement(comp+spatialNumberOfComponents); + //value=rangeIt->GetElement(comp); + value=1; + // meanShiftVector[spatialNumberOfComponents+comp]+=(neighborhoodValue-rangePixel[comp])*(neighborhoodValue-rangePixel[comp])*neighborhoodValue*value; + // weightingMeanShiftVector[spatialNumberOfComponents+comp]+=(neighborhoodValue-rangePixel[comp])*(neighborhoodValue-rangePixel[comp])*value; + meanShiftVector[spatialNumberOfComponents+comp]+=(neighborhoodValue); + weightingMeanShiftVector[spatialNumberOfComponents+comp]+=value; + } + + } + ++it; + ++rangeIt; + ++spatialIt; } } for(unsigned int comp=0; comp<spatialNumberOfComponents; comp++) { if( weightingMeanShiftVector[comp]>0) - meanShiftVector[comp]=meanShiftVector[comp]/weightingMeanShiftVector[comp]-spatialPixel[comp]; + meanShiftVector[comp]=meanShiftVector[comp]/weightingMeanShiftVector[comp]-spatialPixel[comp]; else - meanShiftVector[comp]=0; + meanShiftVector[comp]=0; } for(unsigned int comp=0; comp<rangeNumberOfComponents; comp++) { if( weightingMeanShiftVector[spatialNumberOfComponents+comp]>0) - meanShiftVector[spatialNumberOfComponents+comp]=meanShiftVector[spatialNumberOfComponents+comp]/weightingMeanShiftVector[spatialNumberOfComponents+comp]-rangePixel[comp]; + meanShiftVector[spatialNumberOfComponents+comp]=meanShiftVector[spatialNumberOfComponents+comp]/weightingMeanShiftVector[spatialNumberOfComponents+comp]-rangePixel[comp]; else - meanShiftVector[spatialNumberOfComponents+comp]=0; + meanShiftVector[spatialNumberOfComponents+comp]=0; } return meanShiftVector;