summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2012-05-25 11:08:24 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2012-05-25 11:10:18 +0200
commitb90d1b6bf846a97b260e01f0799f39ffb439ea6d (patch)
treef8905c05bc925598f2385f835a30527fc89517b7
parent4b524e3026d5b1efedaf83e730d3e21cc924dc3b (diff)
downloadcv-b90d1b6bf846a97b260e01f0799f39ffb439ea6d.zip
cv-b90d1b6bf846a97b260e01f0799f39ffb439ea6d.tar.gz
cv-b90d1b6bf846a97b260e01f0799f39ffb439ea6d.tar.bz2
cvg: Add Sobel filter
-rw-r--r--cvg.c24
-rw-r--r--cvg.ui1
2 files changed, 25 insertions, 0 deletions
diff --git a/cvg.c b/cvg.c
index 42c02f4..1d43aba 100644
--- a/cvg.c
+++ b/cvg.c
@@ -260,6 +260,28 @@ gauss_filter(struct cvg *cvg, IplImage *image)
}
static IplImage *
+sobel_filter(struct cvg *cvg, IplImage *image)
+{
+ IplImage *out, *tmp, *tmp2, *gray;
+
+ gray = cvCreateImage(cvGetSize(image), IPL_DEPTH_8U, 1);
+ tmp = cvCreateImage(cvGetSize(image), IPL_DEPTH_16S, 1);
+ tmp2 = cvCreateImage(cvGetSize(image), IPL_DEPTH_8U, 1);
+ out = cvCreateImage(cvGetSize(image), image->depth, image->nChannels);
+
+ cvCvtColor(image, gray, CV_BGR2GRAY);
+ cvSobel(gray, tmp, 0, 1, 3);
+ cvConvertScaleAbs(tmp, tmp2, 1, 0);
+ cvCvtColor(tmp2, out, CV_GRAY2BGR);
+
+ cvReleaseImage(&gray);
+ cvReleaseImage(&tmp);
+ cvReleaseImage(&tmp2);
+
+ return out;
+}
+
+static IplImage *
good_features_to_track(struct cvg *cvg, IplImage *image)
{
IplImage *output, *gray_frame, *eig_image, *temp_image;
@@ -326,6 +348,8 @@ method_set(GtkComboBox *widget, gpointer userdata)
cvg->filter = good_features_to_track;
else if (strcmp(text, "Pass-Through") == 0)
cvg->filter = pass_through_filter;
+ else if (strcmp(text, "Sobel") == 0)
+ cvg->filter = sobel_filter;
else if (strcmp(text, "Hide") == 0)
cvg->filter = hide_filter;
update_right_drawing_area(cvg);
diff --git a/cvg.ui b/cvg.ui
index 0a821cd..d4ac453 100644
--- a/cvg.ui
+++ b/cvg.ui
@@ -84,6 +84,7 @@
<item>Hide</item>
<item>Gauss</item>
<item>GoodFeaturesToTrack</item>
+ <item>Sobel</item>
<item>Pass-Through</item>
</items>
<signal name="changed" handler="method_set" swapped="no"/>