Revision: 56502
          http://sourceforge.net/p/brlcad/code/56502
Author:   mohitdaga
Date:     2013-08-03 17:45:38 +0000 (Sat, 03 Aug 2013)
Log Message:
-----------
Bilinear interpolation binterp for up scaling of images.

Modified Paths:
--------------
    brlcad/trunk/src/libicv/decimate.c

Modified: brlcad/trunk/src/libicv/decimate.c
===================================================================
--- brlcad/trunk/src/libicv/decimate.c  2013-08-03 14:39:07 UTC (rev 56501)
+++ brlcad/trunk/src/libicv/decimate.c  2013-08-03 17:45:38 UTC (rev 56502)
@@ -129,7 +129,54 @@
     return;
 
 }
+HIDDEN void binterp(icv_image_t *bif, int out_width, int out_height)
+{
+    int i, j, c;
+    double x, y, dx, dy, mid1, mid2;
+    double xstep, ystep;
+    double *out_data, *out_p;
+    double *upp_r, *low_r; /*<< upper and lower row */
+    double *upp_c, *low_c;
+    int widthstep;
 
+    xstep = (double) (bif->width - 1) / (double)out_width - 1.0e-6;
+    ystep = (double) (bif->height -1) / (double)out_height - 1.0e-6;
+
+    out_p = out_data = bu_malloc(out_width*out_height*bif->channels, "binterp 
: out data");
+
+    widthstep = bif->width*bif->channels;
+
+    for (j = 0; j < out_height; j++) {
+        y = j*ystep;
+        dy = y - (int)y;
+
+        low_r = bif->data + widthstep* (int)y;
+        upp_r = bif->data + widthstep* (int) (y+1);
+
+        for (i = 0; i < out_width; i++) {
+            x = i*xstep;
+            dx = x - (int)x;
+
+            upp_c = upp_r + (int)x*bif->channels;
+            low_c = low_r + (int)x*bif->channels;
+
+            for(c=0; c<bif->channels; c++) {
+                mid1 = low_c[0] + dx * ((double) low_c[bif->channels] - 
(double) low_c[0] );
+                mid2 = upp_c[0] + dx * ((double) upp_c[bif->channels] - 
(double) upp_c[0] );
+                *out_p = mid1 + dy * (mid2 - mid1);
+
+                out_p++;
+                upp_c++;
+                low_c++;
+            }
+        }
+    }
+    bu_free(bif->data, "binterep : Input Data");
+    bif->data = out_data;
+    bif->widht = out_width;
+    bif->height = bif->height;
+}
+
 /*
  * Local Variables:
  * tab-width: 8

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to