Revision: 56433
          http://sourceforge.net/p/brlcad/code/56433
Author:   mohitdaga
Date:     2013-08-01 19:07:28 +0000 (Thu, 01 Aug 2013)
Log Message:
-----------
Add icv_saturate function. This changes the saturation of image pixels.

Modified Paths:
--------------
    brlcad/trunk/include/icv.h
    brlcad/trunk/src/libicv/operations.c

Modified: brlcad/trunk/include/icv.h
===================================================================
--- brlcad/trunk/include/icv.h  2013-08-01 18:57:28 UTC (rev 56432)
+++ brlcad/trunk/include/icv.h  2013-08-01 19:07:28 UTC (rev 56433)
@@ -428,7 +428,18 @@
  */
 icv_image_t *icv_divides(icv_image_t *img1, icv_image_t *img2);
 
+/**
+ * Change the saturation of image pixels.  If sat is
+ * set to 0.0 the result will be monochromatic, if sat is made
+ * 1.0, the color will not change, if sat is made greater than 1.0,
+ * the amount of color is increased.
+ *
+ * @param img RGB Image to be saturated.
+ * @param sat Saturation value.
+ */
+int icv_saturate(icv_image_t* img, double sat);
 
+
 typedef enum {
     ICV_FILTER_LOW_PASS,
     ICV_FILTER_LAPLACIAN,

Modified: brlcad/trunk/src/libicv/operations.c
===================================================================
--- brlcad/trunk/src/libicv/operations.c        2013-08-01 18:57:28 UTC (rev 
56432)
+++ brlcad/trunk/src/libicv/operations.c        2013-08-01 19:07:28 UTC (rev 
56433)
@@ -225,6 +225,45 @@
     return out_img;
 }
 
+int icv_saturate(icv_image_t* img, double sat)
+{
+    double *data;
+    double bw;                 /* monochrome intensity */
+    double rwgt, gwgt, bwgt;
+    double rt, gt, bt;
+    long size;
+
+    if (img == NULL) {
+       bu_log("icv_saturate : Trying to Saturate a Null img");
+       return -1;
+    }
+
+    if (img->color_space != ICV_COLOR_SPACE_RGB) {
+       bu_log("icv_saturate : Saturates only RGB Images");
+       return -1;
+    }
+    fprintf(stderr, "saturation value is %lf\n", sat);
+    data = img->data;
+    size = img->width*img->height;
+    rwgt = 0.31*(1.0-sat);
+    gwgt = 0.61*(1.0-sat);
+    bwgt = 0.08*(1.0-sat);
+    while(size-- > 0) {
+       rt = *data;
+       gt = *(data+1);
+       bt = *(data+2);
+       bw = (rwgt*rt + gwgt*gt + bwgt*bt);
+       rt = bw + sat*rt;
+       gt = bw + sat*gt;
+       bt = bw + sat*bt;
+       *data++ = rt;
+       *data++ = gt;
+       *data++ = bt;
+    }
+    icv_sanitize(img);
+    return 0;
+}
+
 /*
  * 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