[GRASS-SVN] r43936 - grass/trunk/imagery/i.rectify
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Oct 16 12:50:35 EDT 2010
Author: mmetz
Date: 2010-10-16 09:50:35 -0700 (Sat, 16 Oct 2010)
New Revision: 43936
Modified:
grass/trunk/imagery/i.rectify/bilinear.c
grass/trunk/imagery/i.rectify/cubic.c
grass/trunk/imagery/i.rectify/nearest.c
Log:
fix bilinear/bicubic interpolation
Modified: grass/trunk/imagery/i.rectify/bilinear.c
===================================================================
--- grass/trunk/imagery/i.rectify/bilinear.c 2010-10-16 15:23:47 UTC (rev 43935)
+++ grass/trunk/imagery/i.rectify/bilinear.c 2010-10-16 16:50:35 UTC (rev 43936)
@@ -32,7 +32,11 @@
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;
Modified: grass/trunk/imagery/i.rectify/cubic.c
===================================================================
--- grass/trunk/imagery/i.rectify/cubic.c 2010-10-16 15:23:47 UTC (rev 43935)
+++ grass/trunk/imagery/i.rectify/cubic.c 2010-10-16 16:50:35 UTC (rev 43936)
@@ -33,7 +33,14 @@
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);
Modified: grass/trunk/imagery/i.rectify/nearest.c
===================================================================
--- grass/trunk/imagery/i.rectify/nearest.c 2010-10-16 15:23:47 UTC (rev 43935)
+++ grass/trunk/imagery/i.rectify/nearest.c 2010-10-16 16:50:35 UTC (rev 43936)
@@ -20,7 +20,8 @@
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);
More information about the grass-commit
mailing list