Revision: 57247
http://sourceforge.net/p/brlcad/code/57247
Author: mohitdaga
Date: 2013-08-28 22:51:41 +0000 (Wed, 28 Aug 2013)
Log Message:
-----------
Incorporate usage of offset flag and kern division flag in bwfilter code. This
was left in the initial commit.
Modified Paths:
--------------
brlcad/trunk/src/util/bwfilter.c
Modified: brlcad/trunk/src/util/bwfilter.c
===================================================================
--- brlcad/trunk/src/util/bwfilter.c 2013-08-28 22:45:52 UTC (rev 57246)
+++ brlcad/trunk/src/util/bwfilter.c 2013-08-28 22:51:41 UTC (rev 57247)
@@ -33,6 +33,7 @@
#include "bu.h"
#include "icv.h"
+#include "vmath.h"
/* The filter kernels */
struct kernels {
@@ -55,8 +56,8 @@
int kerndiv;
int kernoffset;
int *kern;
-double kerndiv_diff, kernoffset_diff;
ICV_FILTER filter_type;
+int kernel_index;
int inx = 512;
int iny = 512; /* Default Width */
int verbose = 0;
@@ -81,29 +82,21 @@
void
select_filter(char *str)
{
- int i;
-
- i = 0;
- while (kernel[i].name != NULL) {
- if (bu_strncmp(str, kernel[i].uname, strlen(kernel[i].uname)) == 0)
+ kernel_index = 0;
+ while (kernel[kernel_index].name != NULL) {
+ if (bu_strncmp(str, kernel[kernel_index].uname,
strlen(kernel[kernel_index].uname)) == 0)
break;
- i++;
+ kernel_index++;
}
- if (kernel[i].name == NULL) {
+ if (kernel[kernel_index].name == NULL) {
/* No match, output list and exit */
fprintf(stderr, "Unrecognized filter type \"%s\"\n", str);
dousage();
bu_exit (3, NULL);
}
- kern = kernel[i].kern;
- filter_type = kernel[i].filter;
- /* Have a match, set up that kernel */
- if (dflag == 1)
- if(kernel[i].filter != ICV_FILTER_NULL)
- kerndiv_diff = kerndiv/kernel[i].kerndiv;
- if (oflag == 1)
- kernoffset_diff = ICV_CONV_8BIT(kernoffset -
kernel[i].kernoffset)/(double) kerndiv;
+ kern = kernel[kernel_index].kern;
+ filter_type = kernel[kernel_index].filter;
}
void
@@ -135,6 +128,10 @@
case 'd':
dflag++;
kerndiv = atoi(bu_optarg);
+ if(ZERO(kerndiv)) {
+ bu_log("Bad argument for kerndiv\n");
+ return 1;
+ }
break;
case 'O':
oflag++;
@@ -197,7 +194,22 @@
return 1;
icv_filter(img, filter_type);
+
+ /* Correct the image as per the input offset and */
+ if(oflag | dflag) {
+ icv_add_val(img, -ICV_CONV_8BIT(kernel[kernel_index].kernoffset));
+ if(dflag) {
+ if(ZERO(kerndiv))
+ icv_multiply_val(img,
ICV_CONV_8BIT(kernel[kernel_index].kerndiv/kerndiv));
+ }
+
+ if(oflag)
+ icv_add_val(img, ICV_CONV_8BIT(kernoffset));
+ else
+ icv_add_val(img, ICV_CONV_8BIT(kernel[kernel_index].kernoffset));
+ }
+
if (verbose) {
for (x = 0; x < 11; x++)
bu_log("kern[%d] = %d\n", x, kern[x]);
@@ -210,7 +222,7 @@
}
bu_free(min_d, "max value");
bu_free(max_d, "min values");
-
+
icv_write(img, out_file, ICV_IMAGE_BW);
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits