diff --git a/Code/BasicFilters/otbMeanShiftImageFilter2.h b/Code/BasicFilters/otbMeanShiftImageFilter2.h
index 095f6c447477941ba8fa7d0a84299bb3530fcb99..fb06eef49569e6e8203c9a706f3ca52e25943433 100644
--- a/Code/BasicFilters/otbMeanShiftImageFilter2.h
+++ b/Code/BasicFilters/otbMeanShiftImageFilter2.h
@@ -86,7 +86,7 @@ public:
   typedef typename InputImageType::PixelType    InputPixelType;
   typedef typename InputImageType::IndexType    InputIndexType;
   typedef typename InputImageType::SizeType     InputSizeType;
-  typedef typename InputImageType::IndexType    IndexType;
+  typedef typename InputImageType::IndexValueType InputIndexValueType;
   typedef typename InputImageType::PointType    PointType;
   typedef typename InputImageType::RegionType   RegionType;
   typedef typename InputImageType::SizeType     SizeType;
diff --git a/Code/BasicFilters/otbMeanShiftImageFilter2.txx b/Code/BasicFilters/otbMeanShiftImageFilter2.txx
index 206c802e53ff165d3a0ade00520da978fbee104a..722e9c42b4b1c4a05557f64758422b4a3278bcbf 100644
--- a/Code/BasicFilters/otbMeanShiftImageFilter2.txx
+++ b/Code/BasicFilters/otbMeanShiftImageFilter2.txx
@@ -513,26 +513,23 @@ void MeanShiftImageFilter2<TInputImage,TOutputMetricImage, TOutputImage, TKernel
   InputSizeType inputSize = requestedRegion.GetSize();
   InputIndexType inputIndex = requestedRegion.GetIndex();
 
-  unsigned int width = inputSize[0];
-  unsigned int height = inputSize[1];
-
   // define region
   itk::ImageRegion<2> imageRegion;
-  IndexType index;
-  index[0] = vcl_floor(latticePosition[0] + 0.5);
-  index[1] = vcl_floor(latticePosition[1] + 0.5);
-
-  int xMin = index[0] - vcl_floor(kernelSize[0] / 2);
-  int xMax = xMin + kernelSize[0];
-  int yMin = index[1] - vcl_floor(kernelSize[1] / 2);
-  int yMax = yMin + kernelSize[1];
-
-  IndexType minIndex;
-  minIndex[0] = vcl_max(xMin,static_cast<int>(inputIndex[0])); // add image index
-  minIndex[1] = vcl_max(yMin,static_cast<int>(inputIndex[1])); // add image index
-  IndexType maxIndex;
-  maxIndex[0] = vcl_min(xMax, static_cast<int> (width-1+inputIndex[0])); //add image index
-  maxIndex[1] = vcl_min(yMax, static_cast<int> (height-1+inputIndex[1])); //add image index
+  InputIndexType index;
+  index[0] = static_cast<InputIndexValueType>(vcl_floor(latticePosition[0] + 0.5));
+  index[1] = static_cast<InputIndexValueType>(vcl_floor(latticePosition[1] + 0.5));
+
+  InputIndexValueType xMin = index[0] - static_cast<InputIndexValueType>(vcl_floor(kernelSize[0] / 2));
+  InputIndexValueType xMax = xMin + kernelSize[0];
+  InputIndexValueType yMin = index[1] - static_cast<InputIndexValueType>(vcl_floor(kernelSize[1] / 2));
+  InputIndexValueType yMax = yMin + kernelSize[1];
+
+  InputIndexType minIndex;
+  minIndex[0] = vcl_max(xMin,inputIndex[0]); // add image index
+  minIndex[1] = vcl_max(yMin,inputIndex[1]); // add image index
+  InputIndexType maxIndex;
+  maxIndex[0] = vcl_min(xMax, static_cast<InputIndexValueType>(inputSize[0]-1+inputIndex[0])); //add image index
+  maxIndex[1] = vcl_min(yMax, static_cast<InputIndexValueType>(inputSize[1]-1+inputIndex[1])); //add image index
 
   imageRegion.SetIndex(index);
   SizeType size;
@@ -542,7 +539,7 @@ void MeanShiftImageFilter2<TInputImage,TOutputMetricImage, TOutputImage, TKernel
 
   OutputPixelType *it = *neighborhood;
   PointType pixelPos;
-  IndexType pixelIndex;
+  InputIndexType pixelIndex;
   InputPixelType inputPixel;
   inputPixel.SetSize(numberOfComponents);