Revision: 56429
          http://sourceforge.net/p/brlcad/code/56429
Author:   mohitdaga
Date:     2013-08-01 18:41:42 +0000 (Thu, 01 Aug 2013)
Log Message:
-----------
Add routines which performs operations with contant.

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:40:22 UTC (rev 56428)
+++ brlcad/trunk/include/icv.h  2013-08-01 18:41:42 UTC (rev 56429)
@@ -372,6 +372,28 @@
  */
 void icv_add_val(icv_image_t* img, double val);
 
+/**
+ * This multiplies a double value to all the pixels of the image.
+ * Also if the flag ICV_OPERATIONS_MODE is set this doesnt santizes
+ * the image.
+ */
+void icv_multiply_val(icv_image_t* img, double val);
+
+/**
+ * This divides a double value to all the pixels of the image.
+ * Also if the flag ICV_OPERATIONS_MODE is set this doesnt santizes
+ * the image.
+ */
+void icv_divide_val(icv_image_t* img, double val);
+
+/**
+ * This raises all the pixels of the image to an exponential power.
+ * Also if the flag ICV_OPERATIONS_MODE is set this doesnt santizes
+ * the image.
+ */
+void icv_pow_val(icv_image_t* img, double val);
+
+
 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:40:22 UTC (rev 
56428)
+++ brlcad/trunk/src/libicv/operations.c        2013-08-01 18:41:42 UTC (rev 
56429)
@@ -65,6 +65,61 @@
        icv_sanitize(img);
 }
 
+void icv_multiply_val(icv_image_t* img, double val)
+{
+    double *data = NULL;
+    size_t size;
+    
+    data = img->data;
+    
+    for (size = img->width*img->height*img->channels; size>0; size--) {
+        *data *= val;
+         data++;
+    }
+    if((img->flags && ICV_OPERATIONS_MODE))
+        img->flags&=(!ICV_SANITIZED);
+    else
+        icv_sanitize(img);
+}
+
+void icv_divide_val(icv_image_t* img, double val)
+{
+    double *data = NULL;
+    size_t size;
+    
+    data = img->data;
+    
+    /* Since data is double dividing by 0 will result in INF and -INF */
+    
+    for (size = img->width*img->height*img->channels; size>0; size--) {
+        *data /= val;
+         data++;
+     }
+
+    if((img->flags && ICV_OPERATIONS_MODE))
+        img->flags&=(!ICV_SANITIZED);
+    else
+        icv_sanitize(img);
+}
+
+void icv_pow_val(icv_image_t* img, double val)
+{
+    double *data = NULL;
+    size_t size;
+    
+    data = img->data;
+    
+    for (size = img->width*img->height*img->channels; size>0; size--) {
+        *data = pow(*data,val);
+         data++;
+    }
+    
+    if((img->flags && ICV_OPERATIONS_MODE))
+        img->flags&=(!ICV_SANITIZED);
+    else
+        icv_sanitize(img);
+}
+
 /*
  * 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