Revision: 57841
          http://sourceforge.net/p/brlcad/code/57841
Author:   mohitdaga
Date:     2013-09-23 18:56:13 +0000 (Mon, 23 Sep 2013)
Log Message:
-----------
Add test utility for operations.c

Modified Paths:
--------------
    brlcad/trunk/src/libicv/tests/CMakeLists.txt

Added Paths:
-----------
    brlcad/trunk/src/libicv/tests/icv_operations.c

Modified: brlcad/trunk/src/libicv/tests/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libicv/tests/CMakeLists.txt        2013-09-23 18:43:18 UTC 
(rev 57840)
+++ brlcad/trunk/src/libicv/tests/CMakeLists.txt        2013-09-23 18:56:13 UTC 
(rev 57841)
@@ -6,6 +6,7 @@
 BRLCAD_ADDEXEC(tester_icv_size_up icv_size_up.c libicv libbu NO_INSTALL)
 BRLCAD_ADDEXEC(tester_icv_size_down icv_size_down.c libicv libbu NO_INSTALL)
 BRLCAD_ADDEXEC(tester_icv_saturate icv_saturate.c libicv libbu NO_INSTALL)
+BRLCAD_ADDEXEC(tester_icv_operations icv_operations.c libicv libbu NO_INSTALL)
 
 # Local Variables:
 # tab-width: 8

Added: brlcad/trunk/src/libicv/tests/icv_operations.c
===================================================================
--- brlcad/trunk/src/libicv/tests/icv_operations.c                              
(rev 0)
+++ brlcad/trunk/src/libicv/tests/icv_operations.c      2013-09-23 18:56:13 UTC 
(rev 57841)
@@ -0,0 +1,151 @@
+/*                I C V _ O P E R A T I O N S . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2013 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file icv_operations.c
+ *
+ * Tester function for icv_operations.
+ *
+ */
+
+#include "common.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "bio.h"
+#include "bu.h"
+#include "icv.h"
+
+void usage()
+{
+    bu_log("\
+            [-h] [ -O +|-|/|* ]\n\
+           [-b -p -d -m] \n\
+           [-o out_file]  file_1 file_2 > [out_file]\n");
+
+    bu_log("#Image Options\n\
+           \t -b for bw image\n\
+           \t -d for dpix image\n\
+           \t -m for b image\n\
+           \t -p for pix image\n");
+
+}
+
+int main(int argc, char* argv[])
+{
+    char *out_file = NULL;
+    char *in_file1 = NULL, *in_file2 = NULL;
+    char c;
+    int inx=0, iny=0;
+    char *operation = NULL;
+    icv_image_t *bif1, *bif2, *out_bif;
+    ICV_IMAGE_FORMAT format=ICV_IMAGE_AUTO;
+
+
+    if (argc<2) {
+       usage();
+       return 1;
+    }
+
+    while ((c = bu_getopt(argc, argv, "O:o:bpdmh?")) != -1) {
+       switch (c) {
+           case 'o':
+               out_file = bu_optarg;
+               break;
+           case 'O' :
+               operation = bu_optarg;
+               break;
+           case 'b' :
+               format = ICV_IMAGE_BW;
+               break;
+           case 'p' :
+               format = ICV_IMAGE_PIX;
+               break;
+           case 'd' :
+               format = ICV_IMAGE_DPIX;
+               break;
+           case 'm' :
+               format = ICV_IMAGE_PPM;
+               break;
+           case 'h':
+           default:
+               usage();
+               return 1;
+
+       }
+    }
+    if (bu_optind <= argc) {
+       in_file1 = argv[bu_optind];
+       bu_optind++;
+    }
+    else {
+        usage();
+        return 1;
+    }
+    
+    if (bu_optind <= argc) {
+       in_file2 = argv[bu_optind];
+    }
+    else {
+        usage();
+        return 1;
+    } 
+
+    bif1 = icv_read(in_file1, format, inx, iny);
+    bif2 = icv_read(in_file2, format, inx, iny);
+
+    if( bif1 == NULL || bif2 == NULL ) {
+        bu_log("Error loading the image.\n");
+        return 1;
+    }
+
+    if(BU_STR_EQUAL(operation, "+"))    
+        out_bif = icv_add(bif1, bif1);
+    else if(BU_STR_EQUAL(operation, "-"))    
+        out_bif = icv_sub(bif1, bif2);
+    else if(BU_STR_EQUAL(operation, "/"))    
+        out_bif = icv_multiply(bif1, bif2);
+    else if(BU_STR_EQUAL(operation, "*"))    
+        out_bif = icv_divide(bif1, bif2);
+    else {
+        bu_log("Using Default operation (+)");
+        out_bif = icv_add(bif1, bif2);
+    }
+
+    if(!out_bif) {
+        bu_log("Error in Operations\n");
+    }
+
+    icv_write(out_bif,out_file, format);
+    icv_destroy(bif1);
+    icv_destroy(bif2);
+    icv_destroy(out_bif);
+
+    return 0;
+}
+
+/*
+ * Local Variables:
+ * tab-width: 8
+ * mode: C
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */


Property changes on: brlcad/trunk/src/libicv/tests/icv_operations.c
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to