Created
November 11, 2013 19:14
-
-
Save sumit4iit/7418664 to your computer and use it in GitHub Desktop.
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; | |
// sobel_operator | |
Mat sobelX = ( Mat_<float>(3,3)<< | |
-1,0,1, | |
-2,0,2, | |
-1,0,1) ; | |
Mat sobelY = ( Mat_<float>(3,3)<< | |
1,2,1, | |
0,0,0, | |
-1,-2,-1); | |
// Calling filter2D | |
filter2D(src,destX,ddepth,sobelX,anchor,delta,BORDER_DEFAULT); | |
filter2D(src,destY,ddepth,sobelY,anchor,delta,BORDER_DEFAULT); | |
namedWindow("original",CV_WINDOW_AUTOSIZE); | |
namedWindow("sobelX",CV_WINDOW_AUTOSIZE); | |
namedWindow("sobelY",CV_WINDOW_AUTOSIZE); | |
namedWindow("sobelX+Y",CV_WINDOW_AUTOSIZE); | |
imshow("sobelX",destX); | |
imshow("sobelY",destY); | |
imshow("sobelX+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