diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-05-25 11:08:24 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-05-25 11:10:18 +0200 |
commit | b90d1b6bf846a97b260e01f0799f39ffb439ea6d (patch) | |
tree | f8905c05bc925598f2385f835a30527fc89517b7 | |
parent | 4b524e3026d5b1efedaf83e730d3e21cc924dc3b (diff) | |
download | cv-b90d1b6bf846a97b260e01f0799f39ffb439ea6d.tar.gz cv-b90d1b6bf846a97b260e01f0799f39ffb439ea6d.tar.bz2 cv-b90d1b6bf846a97b260e01f0799f39ffb439ea6d.zip |
cvg: Add Sobel filter
-rw-r--r-- | cvg.c | 24 | ||||
-rw-r--r-- | cvg.ui | 1 |
2 files changed, 25 insertions, 0 deletions
@@ -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); @@ -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"/> |