diff --git a/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTile.java b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTile.java
index f5306264aa020bfb42bc0f0fda55ff200c21f0cc..75ac00fc34c97536673b5b2c89f67f427ad77486 100644
--- a/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTile.java
+++ b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTile.java
@@ -106,11 +106,15 @@ public class MinMaxTreeTile extends SimpleTile {
 
         // compute min/max trees
         if (start.length > 0) {
-            // TODO: we need to pre-process pixels so the min/max of *interpolation* is used
-            // now, we consider a single corner in each pixel, but all four corners
-            // contributes to the min/max at interpolation stage
-            applyRecursively(minTree, start.length - 1, nbRows, nbCols, new Min(), elevations, 0);
-            applyRecursively(maxTree, start.length - 1, nbRows, nbCols, new Max(), elevations, 0);
+
+            final double[] preprocessed = new double[elevations.length];
+
+            preprocess(preprocessed, elevations, nbRows, nbCols, new Min());
+            applyRecursively(minTree, start.length - 1, nbRows, nbCols, new Min(), preprocessed, 0);
+
+            preprocess(preprocessed, elevations, nbRows, nbCols, new Max());
+            applyRecursively(maxTree, start.length - 1, nbRows, nbCols, new Max(), preprocessed, 0);
+
         }
 
     }
@@ -357,8 +361,50 @@ public class MinMaxTreeTile extends SimpleTile {
 
     }
 
+    /** Preprocess recursive application of a function.
+     * <p>
+     * At start, the min/max should be computed for each pixel using the four corners values.
+     * </p>
+     * @param preprocessed preprocessed array to fill up
+     * @param elevations raw elevations te preprocess
+     * @param nbRows number of rows
+     * @param nbCols number of columns
+     * @param f function to apply
+     */
+    private void preprocess(final double[] preprocessed, final double[] elevations,
+                            final int nbRows, final int nbCols,
+                            final BivariateFunction f) {
+
+        int k = 0;
+
+        for (int i = 0; i < nbRows - 1; ++i) {
+
+            // regular elements with both a column at right and a row below
+            for (int j = 0; j < nbCols - 1; ++j) {
+                preprocessed[k] = f.value(f.value(elevations[k],          elevations[k + 1]),
+                                          f.value(elevations[k + nbCols], elevations[k + nbCols + 1]));
+                k++;
+            }
+
+            // last column elements, lacking a right column
+            preprocessed[k] = f.value(elevations[k], elevations[k + nbCols]);
+            k++;
+
+        }
+
+        // last row elements, lacking a below row
+        for (int j = 0; j < nbCols - 1; ++j) {
+            preprocessed[k] = f.value(elevations[k], elevations[k + 1]);
+            k++;
+        }
+
+        // last element
+        preprocessed[k] = elevations[k];
+
+    }
+
     /** Recursive application of a function.
-     * @param tree to fill-up with the recursive applications
+     * @param tree tree to fill-up with the recursive applications
      * @param level current level
      * @param levelRows number of rows at current level
      * @param levelColumns number of columns at current level
diff --git a/rugged-core/src/test/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTileTest.java b/rugged-core/src/test/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTileTest.java
index 72d30d26ac681b1dcd298d01144e5e8b91d97ad0..6eb06c36eb1740a8c6938775733946d124ded8d0 100644
--- a/rugged-core/src/test/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTileTest.java
+++ b/rugged-core/src/test/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTileTest.java
@@ -113,8 +113,8 @@ public class MinMaxTreeTileTest {
                             int[] neighbors = neighbors(row, column, nbRows, nbColumns, tile.getLevels() - level);
                             double min = Double.POSITIVE_INFINITY;
                             double max = Double.NEGATIVE_INFINITY;
-                            for (int i = neighbors[0]; i < neighbors[1]; ++i) {
-                                for (int j = neighbors[2]; j < neighbors[3]; ++j) {
+                            for (int i = neighbors[0]; i < FastMath.min(neighbors[1] + 1, nbRows); ++i) {
+                                for (int j = neighbors[2]; j < FastMath.min(neighbors[3] + 1, nbColumns); ++j) {
                                     double pixelValue = tile.getElevationAtIndices(i, j);
                                     min = FastMath.min(min, pixelValue);
                                     max = FastMath.max(max, pixelValue);