Revision: 56499
          http://sourceforge.net/p/brlcad/code/56499
Author:   mohitdaga
Date:     2013-08-03 10:46:14 +0000 (Sat, 03 Aug 2013)
Log Message:
-----------
Add under_sample function. This will be one of the methods to decimate an image.

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

Modified: brlcad/trunk/src/libicv/decimate.c
===================================================================
--- brlcad/trunk/src/libicv/decimate.c  2013-08-03 10:00:44 UTC (rev 56498)
+++ brlcad/trunk/src/libicv/decimate.c  2013-08-03 10:46:14 UTC (rev 56499)
@@ -26,6 +26,7 @@
 
 #include "bu.h"
 #include "icv.h"
+#include "vmath.h"
 
 HIDDEN void shrink_image(icv_image_t* bif, int factor)
 {
@@ -66,6 +67,28 @@
 
 }
 
+HIDDEN void under_sample(icv_image_t* bif, int factor)
+{
+    double *data_p, *res_p;
+    int x,y,widthstep;
+
+    widthstep = bif->width*bif->channels;
+
+    res_p = data_p = bif->data;
+
+    for (y=0; y<bif->height; y+=factor) {
+        data_p = bif->data + widthstep*y;
+        for (x=0; x<bif->width; x+=factor, res_p+=bif->channels, 
data_p+=factor*bif->channels)
+            VMOVEN(res_p,data_p, bif->channels);
+    }
+
+    bif->width = (int) bif->width/factor;
+    bif->height = (int) bif->height/factor;
+    bif->data = bu_realloc(bif->data, (size_t) 
(bif->width*bif->height*bif->channels), "under_sample : Reallocation");
+
+    return;
+}
+
 /*
  * 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