Преглед на файлове

fix bilinear/bicubic interpolation

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@43936 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz преди 14 години
родител
ревизия
530b7a1382
променени са 3 файла, в които са добавени 15 реда и са изтрити 3 реда
  1. 5 1
      imagery/i.rectify/bilinear.c
  2. 8 1
      imagery/i.rectify/cubic.c
  3. 2 1
      imagery/i.rectify/nearest.c

+ 5 - 1
imagery/i.rectify/bilinear.c

@@ -32,7 +32,11 @@ void p_bilinear(struct cache *ibuffer,	/* input buffer                  */
       result;			/* result of interpolation       */
     DCELL *c00, *c01, *c10, *c11;
 
-    /* cut indices to integer */
+    /* cut indices to integer and get nearest cells */
+    /* example: *row_idx = 2.1
+     * nearest rows are 1 and 2, not 2 and 3 */
+    *row_idx -= 0.5;
+    *col_idx -= 0.5;
     row0 = (int)floor(*row_idx);
     col0 = (int)floor(*col_idx);
     row1 = row0 + 1;

+ 8 - 1
imagery/i.rectify/cubic.c

@@ -33,7 +33,14 @@ void p_cubic(struct cache *ibuffer,	/* input buffer                  */
       val[4];			/* buffer for temporary values   */
     DCELL *cellp[4][4];
 
-    /* cut indices to integer */
+    /* cut indices to integer and get nearest cells */
+    /* example: *row_idx = 2.1
+     * nearest rows are 0, 1, 2 and 3, not 1, 2, 3 and 4
+     * row 0 streches from 0 to 1, row 4 from 4 to 5
+     * 2.1 - 1 = 1.1
+     * 4 - 2.1 = 1.9 */
+    *row_idx -= 0.5;
+    *col_idx -= 0.5;
     row = (int)floor(*row_idx);
     col = (int)floor(*col_idx);
 

+ 2 - 1
imagery/i.rectify/nearest.c

@@ -20,7 +20,8 @@ void p_nearest(struct cache *ibuffer,	/* input buffer                  */
     int row, col;		/* row/col of nearest neighbor   */
     DCELL *cellp;
 
-    /* cut indices to integer */
+    /* cut indices to integer and get nearest cell */
+    /* the row_idx, col_idx correction for bilinear/bicubic does not apply here */
     row = (int)floor(*row_idx);
     col = (int)floor(*col_idx);