Last active
December 28, 2015 01:09
-
-
Save sumit4iit/7418590 to your computer and use it in GitHub Desktop.
prewitt_operator_edge_detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* eyeExtract.cpp | |
* | |
* Created on: Nov 10, 2013 | |
* Author: sumit4iit | |
*/ | |
#include<iostream> | |
#include "cv.h" | |
#include "highgui.h" | |
#include <cstring> | |
using namespace cv; | |
using namespace std; | |
int main() | |
{ | |
string path = "res/download.jpg"; | |
Mat src = imread(path,CV_LOAD_IMAGE_GRAYSCALE); | |
if(!src.data) | |
{ | |
cout<<"fail\n"; | |
return -1; | |
} | |
Mat destX,destY; | |
Point anchor = Point(-1,-1); | |
double delta = 0; | |
int ddepth = -1; | |
// Prewitt_operator | |
Mat prewittX = ( Mat_<float>(3,3)<< | |
-1,0,1, | |
-1,0,1, | |
-1,0,1) ; | |
Mat prewittY = ( Mat_<float>(3,3)<< | |
1,1,1, | |
0,0,0, | |
-1,-1,-1); | |
// Calling filter2D | |
filter2D(src,destX,ddepth,prewittX,anchor,delta,BORDER_DEFAULT); | |
filter2D(src,destY,ddepth,prewittY,anchor,delta,BORDER_DEFAULT); | |
namedWindow("original",CV_WINDOW_AUTOSIZE); | |
namedWindow("prewittX",CV_WINDOW_AUTOSIZE); | |
namedWindow("prewittY",CV_WINDOW_AUTOSIZE); | |
namedWindow("prewittX+Y",CV_WINDOW_AUTOSIZE); | |
imshow("prewittX",destX); | |
imshow("prewittY",destY); | |
imshow("prewittX+Y",destX+destY); | |
imshow("original",src); | |
waitKey(0); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment