aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-01-21 17:59:14 +0100
committerThomas White <taw@physics.org>2010-01-21 17:59:14 +0100
commit6dce1ed57b186dee37795eed14dce46b82bd4d3e (patch)
tree9a6c0f4fa51961f75088da0ed21e5abd980852ca
parentfc2135e792d169830300878780e4bae774f13463 (diff)
Icky noise filter
-rw-r--r--src/filters.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/filters.c b/src/filters.c
index 235d2822..adb291ba 100644
--- a/src/filters.c
+++ b/src/filters.c
@@ -80,6 +80,40 @@ static void clean_panel(struct image *image, int sx, int sy)
}
+static void noise_filter(struct image *image)
+{
+ int x, y;
+
+ for ( x=0; x<image->width; x++ ) {
+ for ( y=0; y<image->height; y++ ) {
+
+ int dx, dy;
+ int val = image->data[x+image->width*y];
+
+ if ( (x==1) || (x==image->width-1)
+ || (y==1) || (y==image->height-1) ) {
+ if ( val < 0 ) val = 0;
+ }
+
+ for ( dx=-1; dx<=+1; dx++ ) {
+ for ( dy=-1; dy<=+1; dy++ ) {
+
+ int val2;
+
+ val2 = image->data[(x+dx)+image->width*(y+dy)];
+
+ if ( val2 < 0 ) val = 0;
+
+ }
+ }
+
+ image->data[x+image->width*y] = val;
+
+ }
+ }
+}
+
+
/* Pre-processing to make life easier */
void clean_image(struct image *image)
{
@@ -94,4 +128,6 @@ void clean_image(struct image *image)
}
}
+
+ noise_filter(image);
}