Revision: 56432
          http://sourceforge.net/p/brlcad/code/56432
Author:   mohitdaga
Date:     2013-08-01 18:57:28 +0000 (Thu, 01 Aug 2013)
Log Message:
-----------
Add functions which performs operations between two images.

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:51:52 UTC (rev 56431)
+++ brlcad/trunk/include/icv.h  2013-08-01 18:57:28 UTC (rev 56432)
@@ -393,7 +393,42 @@
  */
 void icv_pow_val(icv_image_t* img, double val);
 
+/**
+ * This routine adds pixel value of one image to pixel value of
+ * other pixel and inserts in the same index of the output image.
+ *
+ * Also it sanitizes the image.
+ */
+icv_image_t *icv_add(icv_image_t *img1, icv_image_t *img2);
 
+/**
+ * This routine substracts pixel value of one image from pixel value
+ * of other pixel and inserts the result at the same index of the
+ * output image.
+ *
+ * Also it sanitizes the image.
+ */
+icv_image_t *icv_sub(icv_image_t *img1, icv_image_t *img2);
+
+/**
+ * This routine multiplies pixel value of one image to pixel value of
+ * other pixel and inserts the result at the same index of the
+ * output image.
+ *
+ * Also it sanitizes the image.
+ */
+icv_image_t *icv_multiply(icv_image_t *img1, icv_image_t *img2);
+
+/**
+ * This routine divides pixel value of one image from pixel value of
+ * other pixel and inserts the result at the same index of the
+ * output image.
+ *
+ * Also it sanitizes the image.
+ */
+icv_image_t *icv_divides(icv_image_t *img1, icv_image_t *img2);
+
+
 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:51:52 UTC (rev 
56431)
+++ brlcad/trunk/src/libicv/operations.c        2013-08-01 18:57:28 UTC (rev 
56432)
@@ -120,6 +120,111 @@
        icv_sanitize(img);
 }
 
+icv_image_t *icv_add(icv_image_t *img1, icv_image_t *img2)
+{
+    double *data1, *data2, *out_data;
+    size_t size;
+    icv_image_t *out_img;
+
+    if ((img1->width == img2->width) && (img1->height == img2->height) && 
(img1->channels == img2->channels)) {
+       bu_log("icv_add : Image Parameters not Equal");
+       return NULL;
+    }
+
+    data1 =img1->data;
+    data2 =img2->data;
+
+    out_img = icv_create(img1->width, img1->height, img1->color_space);
+
+    out_data = out_img->data;
+
+    for (size = img1->width*img1->height*img1->channels; size>0; size--)
+       *out_data++ = *data1++ + *data2++;
+
+    icv_sanitize(out_img);
+
+    return out_img;
+}
+
+icv_image_t *icv_sub(icv_image_t *img1, icv_image_t *img2)
+{
+    double *data1, *data2, *out_data;
+    size_t size;
+    icv_image_t *out_img;
+
+    if ((img1->width == img2->width) && (img1->height == img2->height) && 
(img1->channels == img2->channels)) {
+       bu_log("icv_add : Image Parameters not Equal");
+       return NULL;
+    }
+
+    data1 =img1->data;
+    data2 =img2->data;
+
+    out_img = icv_create(img1->width, img1->height, img1->color_space);
+
+    out_data = out_img->data;
+
+    for (size = img1->width*img1->height*img1->channels; size>0; size--)
+       *out_data++ = *data1++ - *data2++;
+
+    icv_sanitize(out_img);
+
+    return out_img;
+}
+
+icv_image_t *icv_multiply(icv_image_t *img1, icv_image_t *img2)
+{
+    double *data1, *data2, *out_data;
+    size_t size;
+    icv_image_t *out_img;
+
+    if ((img1->width == img2->width) && (img1->height == img2->height) && 
(img1->channels == img2->channels)) {
+       bu_log("icv_add : Image Parameters not Equal");
+       return NULL;
+    }
+
+    data1 =img1->data;
+    data2 =img2->data;
+
+    out_img = icv_create(img1->width, img1->height, img1->color_space);
+
+    out_data = out_img->data;
+
+    for (size = img1->width*img1->height*img1->channels; size>0; size--)
+       *out_data++ = *data1++ * *data2++;
+
+    icv_sanitize(out_img);
+
+    return out_img;
+}
+
+
+icv_image_t *icv_divide(icv_image_t *img1, icv_image_t *img2)
+{
+    double *data1, *data2, *out_data;
+    size_t size;
+    icv_image_t *out_img;
+
+    if ((img1->width == img2->width) && (img1->height == img2->height) && 
(img1->channels == img2->channels)) {
+       bu_log("icv_add : Image Parameters not Equal");
+       return NULL;
+    }
+
+    data1 =img1->data;
+    data2 =img2->data;
+
+    out_img = icv_create(img1->width, img1->height, img1->color_space);
+
+    out_data = out_img->data;
+
+    for (size = img1->width*img1->height*img1->channels; size>0; size--)
+       *out_data++ = *data1++ / *data2++;
+
+    icv_sanitize(out_img);
+
+    return out_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