aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Bowyer <adrian@reprappro.com>2016-09-11 13:55:35 +0100
committerAdrian Bowyer <adrian@reprappro.com>2016-09-11 13:55:35 +0100
commit167b7f402f605ff0b6eb34adee4609cec8d4b95d (patch)
treea40a58d653ac51a85a3b9eea5c591d050131a2aa
parentbd60a59ed62498d68c014364db8446f1e09e1d18 (diff)
Working version. Mirror filter replaced by Reichardt.
Need to adjust the filter time constants.
-rw-r--r--Filters/.~lock.low-and-high.ods#2
-rw-r--r--Filters/low-and-high.odsbin48627 -> 48696 bytes
-rw-r--r--src/.deps/camorama-filter-mirror.Po19
-rwxr-xr-xsrc/camoramabin348272 -> 349384 bytes
-rw-r--r--src/camorama-filter-mirror.c120
-rw-r--r--src/camorama-filter-mirror.c~122
-rw-r--r--src/camorama-filter-mirror.obin24904 -> 27656 bytes
7 files changed, 173 insertions, 90 deletions
diff --git a/Filters/.~lock.low-and-high.ods# b/Filters/.~lock.low-and-high.ods#
index 9501736..f234b92 100644
--- a/Filters/.~lock.low-and-high.ods#
+++ b/Filters/.~lock.low-and-high.ods#
@@ -1 +1 @@
-,ensab,BigZoo,10.09.2016 15:16,file:///home/ensab/.config/libreoffice/4; \ No newline at end of file
+,ensab,BigZoo,11.09.2016 10:58,file:///home/ensab/.config/libreoffice/4; \ No newline at end of file
diff --git a/Filters/low-and-high.ods b/Filters/low-and-high.ods
index cb7eb50..600ad6e 100644
--- a/Filters/low-and-high.ods
+++ b/Filters/low-and-high.ods
Binary files differ
diff --git a/src/.deps/camorama-filter-mirror.Po b/src/.deps/camorama-filter-mirror.Po
index ca53bc7..afc4279 100644
--- a/src/.deps/camorama-filter-mirror.Po
+++ b/src/.deps/camorama-filter-mirror.Po
@@ -127,7 +127,12 @@ camorama-filter-mirror.o: camorama-filter-mirror.c \
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
/usr/include/x86_64-linux-gnu/bits/stdio.h \
- /usr/include/x86_64-linux-gnu/bits/stdio2.h
+ /usr/include/x86_64-linux-gnu/bits/stdio2.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h
/usr/include/stdc-predef.h:
@@ -450,3 +455,15 @@ filter.h:
/usr/include/x86_64-linux-gnu/bits/stdio.h:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
diff --git a/src/camorama b/src/camorama
index 7d3e2dc..790f30f 100755
--- a/src/camorama
+++ b/src/camorama
Binary files differ
diff --git a/src/camorama-filter-mirror.c b/src/camorama-filter-mirror.c
index 28e2e4c..a9bbd67 100644
--- a/src/camorama-filter-mirror.c
+++ b/src/camorama-filter-mirror.c
@@ -30,6 +30,7 @@
#include <glib/gi18n.h>
#include <stdio.h>
+#include <stdlib.h>
/* GType stuff for CamoramaFilterMirror */
typedef struct _CamoramaFilter CamoramaFilterMirror;
@@ -40,57 +41,89 @@ G_DEFINE_TYPE(CamoramaFilterMirror, camorama_filter_mirror, CAMORAMA_TYPE_FILTER
static void
camorama_filter_mirror_init(CamoramaFilterMirror* self) {}
-static char start = 1;
+static gint oldWidth = -1;
+static gint oldHeight = -1;
+static gint oldDepth = -1;
-static long *lastSignal;
-static long *lastHigh;
-static long *lastHighThenLow;
-static long *output;
+static long *lastSignal = 0;
+static long *lastHigh = 0;
+static long *lastHighThenLow = 0;
+static long *output = 0;
-static int lowPassTC = 10;
-static int highPassTC = 3;
+static int lowPassTC = 1;
+static int highPassTC = 10;
static int count = 0;
-static void
-camorama_filter_mirror_filter(CamoramaFilter* filter, guchar *image, gint width, gint height, gint depth)
+char debug = 1;
+
+static void MaybeNewMemory(gint width, gint height, gint depth)
{
- gint x, y, z, row_length, row, column, thisPixel, thisXY, thatXY, memory;
+ long needed, i, memory;
- long signal, thisHigh, thisHighThenLow, thatHigh, thatHighThenLow, thatSignal, newValue, max, min, scale;
+ if(width == oldWidth && height == oldHeight && depth == oldDepth)
+ return;
- if(start)
- {
+ if(lastSignal)
+ free(lastSignal);
+ if(lastHigh)
+ free(lastHigh);
+ if(lastHighThenLow)
+ free(lastHighThenLow);
+ if(output)
+ free(output);
+ if(debug)
printf("\n\nwidth: %d, height: %d, depth: %d\n\n", width, height, depth);
- memory = (5 + (width+1)*(height+1))*sizeof(long);
- lastSignal = (long *)malloc(memory);
- if (!lastSignal)
- {
- printf("ERROR: Cannot malloc image memory 1\n");
- return;
- }
- lastHigh = (long *)malloc(memory);
- if (!lastHigh)
- {
- printf("ERROR: Cannot malloc image memory 2\n");
- return;
- }
- lastHighThenLow = (long *)malloc(memory);
- if (!lastHighThenLow)
- {
- printf("ERROR: Cannot malloc image memory 3\n");
- return;
- }
- output = (long *)malloc(memory);
- if (!output)
- {
- printf("ERROR: Cannot malloc image memory 3\n");
- return;
- }
+
+ needed = 5 + (width+1)*(height+1);
+ memory = needed*sizeof(long);
+ lastSignal = (long *)malloc(memory);
+ if (!lastSignal)
+ {
+ printf("ERROR: Cannot malloc image memory for lastSignal\n");
+ return;
+ }
+ lastHigh = (long *)malloc(memory);
+ if (!lastHigh)
+ {
+ printf("ERROR: Cannot malloc image memory for lastHigh\n");
+ return;
+ }
+ lastHighThenLow = (long *)malloc(memory);
+ if (!lastHighThenLow)
+ {
+ printf("ERROR: Cannot malloc image memory for lastHighThenLow\n");
+ return;
+ }
+ output = (long *)malloc(memory);
+ if (!output)
+ {
+ printf("ERROR: Cannot malloc image memory for output\n");
+ return;
+ }
+ for(i=0; i < needed; i++)
+ {
+ lastSignal[i] = 127;
+ lastHigh[i] = 127;
+ lastHighThenLow[i] = 127;
}
- start = 0;
+ oldWidth = width;
+ oldHeight = height;
+ oldDepth = depth;
+}
+
+
+static void
+camorama_filter_mirror_filter(CamoramaFilter* filter, guchar *image, gint width, gint height, gint depth)
+{
+ gint x, y, z, row_length, row, column, thisPixel, thisXY, thatXY;
+
+ long signal, thisHigh, thisHighThenLow, thatHigh, thatHighThenLow, thatSignal, newValue, max, min, scale;
+
+ MaybeNewMemory(width, height, depth);
+
max = LONG_MIN;
min = LONG_MAX;
thatSignal = 0;
@@ -123,13 +156,12 @@ camorama_filter_mirror_filter(CamoramaFilter* filter, guchar *image, gint width,
thatHighThenLow = (thatHigh + lastHighThenLow[thatXY]*lowPassTC)/(lowPassTC + 1);
newValue = thisHighThenLow*thatHigh - thatHighThenLow*thisHigh;
+ output[thisXY] = newValue;
if(newValue > max)
max = newValue;
if(newValue < min)
- min = newValue;
-
- output[thisXY] = newValue;
+ min = newValue;
// Remember for next time
@@ -140,7 +172,7 @@ camorama_filter_mirror_filter(CamoramaFilter* filter, guchar *image, gint width,
}
}
count++;
- if(!(count%50))
+ if(debug && !(count%50))
{
printf("\nmax: %ld, min: %ld\n", max, min);
}
@@ -157,7 +189,7 @@ camorama_filter_mirror_filter(CamoramaFilter* filter, guchar *image, gint width,
column = x*depth;
thisPixel = row + column;
thisXY = y*width+x;
- signal = (output[thisXY]*255)/scale - min;
+ signal = ((output[thisXY] - min)*255)/scale;
if(signal > 255)
signal = 255;
if(signal < 0)
diff --git a/src/camorama-filter-mirror.c~ b/src/camorama-filter-mirror.c~
index 7bd14f9..8ee7c4c 100644
--- a/src/camorama-filter-mirror.c~
+++ b/src/camorama-filter-mirror.c~
@@ -30,6 +30,7 @@
#include <glib/gi18n.h>
#include <stdio.h>
+#include <stdlib.h>
/* GType stuff for CamoramaFilterMirror */
typedef struct _CamoramaFilter CamoramaFilterMirror;
@@ -40,57 +41,89 @@ G_DEFINE_TYPE(CamoramaFilterMirror, camorama_filter_mirror, CAMORAMA_TYPE_FILTER
static void
camorama_filter_mirror_init(CamoramaFilterMirror* self) {}
-static char start = 1;
+static gint oldWidth = -1;
+static gint oldHeight = -1;
+static gint oldDepth = -1;
-static long *lastSignal;
-static long *lastHigh;
-static long *lastHighThenLow;
-static long *output;
+static long *lastSignal = 0;
+static long *lastHigh = 0;
+static long *lastHighThenLow = 0;
+static long *output = 0;
-static int lowPassTC = 10;
-static int highPassTC = 3;
+static int lowPassTC = 4;
+static int highPassTC = 10;
static int count = 0;
-static void
-camorama_filter_mirror_filter(CamoramaFilter* filter, guchar *image, gint width, gint height, gint depth)
+char debug = 1;
+
+static void MaybeNewMemory(gint width, gint height, gint depth)
{
- gint x, y, z, row_length, row, column, thisPixel, thisXY, thatXY, memory;
+ long needed, i, memory;
- long signal, thisHigh, thisHighThenLow, thatHigh, thatHighThenLow, thatSignal, newValue, max, min, scale;
+ if(width == oldWidth && height == oldHeight && depth == oldDepth)
+ return;
- if(start)
- {
+ if(lastSignal)
+ free(lastSignal);
+ if(lastHigh)
+ free(lastHigh);
+ if(lastHighThenLow)
+ free(lastHighThenLow);
+ if(output)
+ free(output);
+ if(debug)
printf("\n\nwidth: %d, height: %d, depth: %d\n\n", width, height, depth);
- memory = (5 + (width+1)*(height+1))*sizeof(long);
- lastSignal = (long *)malloc(memory);
- if (!lastSignal)
- {
- printf("ERROR: Cannot malloc image memory 1\n");
- return;
- }
- lastHigh = (long *)malloc(memory);
- if (!lastHigh)
- {
- printf("ERROR: Cannot malloc image memory 2\n");
- return;
- }
- lastHighThenLow = (long *)malloc(memory);
- if (!lastHighThenLow)
- {
- printf("ERROR: Cannot malloc image memory 3\n");
- return;
- }
- output = (long *)malloc(memory);
- if (!output)
- {
- printf("ERROR: Cannot malloc image memory 3\n");
- return;
- }
+
+ needed = 5 + (width+1)*(height+1);
+ memory = needed*sizeof(long);
+ lastSignal = (long *)malloc(memory);
+ if (!lastSignal)
+ {
+ printf("ERROR: Cannot malloc image memory for lastSignal\n");
+ return;
+ }
+ lastHigh = (long *)malloc(memory);
+ if (!lastHigh)
+ {
+ printf("ERROR: Cannot malloc image memory for lastHigh\n");
+ return;
+ }
+ lastHighThenLow = (long *)malloc(memory);
+ if (!lastHighThenLow)
+ {
+ printf("ERROR: Cannot malloc image memory for lastHighThenLow\n");
+ return;
+ }
+ output = (long *)malloc(memory);
+ if (!output)
+ {
+ printf("ERROR: Cannot malloc image memory for output\n");
+ return;
+ }
+ for(i=0; i < needed; i++)
+ {
+ lastSignal[i] = 127;
+ lastHigh[i] = 127;
+ lastHighThenLow[i] = 127;
}
- start = 0;
+ oldWidth = width;
+ oldHeight = height;
+ oldDepth = depth;
+}
+
+
+static void
+camorama_filter_mirror_filter(CamoramaFilter* filter, guchar *image, gint width, gint height, gint depth)
+{
+ gint x, y, z, row_length, row, column, thisPixel, thisXY, thatXY;
+
+ long signal, thisHigh, thisHighThenLow, thatHigh, thatHighThenLow, thatSignal, newValue, max, min, scale;
+
+ MaybeNewMemory(width, height, depth);
+
max = LONG_MIN;
min = LONG_MAX;
thatSignal = 0;
@@ -123,13 +156,12 @@ camorama_filter_mirror_filter(CamoramaFilter* filter, guchar *image, gint width,
thatHighThenLow = (thatHigh + lastHighThenLow[thatXY]*lowPassTC)/(lowPassTC + 1);
newValue = thisHighThenLow*thatHigh - thatHighThenLow*thisHigh;
+ output[thisXY] = newValue;
if(newValue > max)
max = newValue;
if(newValue < min)
- min = newValue;
-
- output[thisXY] = newValue;
+ min = newValue;
// Remember for next time
@@ -140,12 +172,14 @@ camorama_filter_mirror_filter(CamoramaFilter* filter, guchar *image, gint width,
}
}
count++;
- if(!(count%50))
+ if(debug && !(count%50))
{
printf("\nmax: %ld, min: %ld\n", max, min);
}
scale = max - min;
+ if(scale == 0)
+ scale = 1;
for(y = 0; y < height; y++)
{
@@ -155,7 +189,7 @@ camorama_filter_mirror_filter(CamoramaFilter* filter, guchar *image, gint width,
column = x*depth;
thisPixel = row + column;
thisXY = y*width+x;
- signal = (output[thisXY]*255)/scale - min;
+ signal = ((output[thisXY] - min)*255)/scale;
if(signal > 255)
signal = 255;
if(signal < 0)
diff --git a/src/camorama-filter-mirror.o b/src/camorama-filter-mirror.o
index f5fdf94..e480339 100644
--- a/src/camorama-filter-mirror.o
+++ b/src/camorama-filter-mirror.o
Binary files differ

Privacy Policy