Wednesday, October 7, 2009

Sobel edge detection in Images using Open CV

// Sobel Edge

#include "stdafx.h"

#include <cv.h>

#include <cxcore.h>

#include <highgui.h>

int _tmain(int argc, _TCHAR* argv[])

{

int dx,dy,apertureSize;

IplImage *img = cvLoadImage("c:\\lena.png");

IplImage *img1 = cvCloneImage(img);

dx=1; dy=0; apertureSize=3;

cvSobel(img,img1,dx,dy,apertureSize);

cvNamedWindow("SobelEdge",1);

cvShowImage("SobelEdge",img1);

cvWaitKey();

return 0;

}

// Sobel Edge

#include "stdafx.h"

#include <cv.h>

#include <cxcore.h>

#include <highgui.h>

int _tmain(int argc, _TCHAR* argv[])

{

int dx,dy,apertureSize;

IplImage *img = cvLoadImage("c:\\lena.png");

IplImage *img1 = cvCloneImage(img);

dx=1; dy=0; apertureSize=3;

cvSobel(img,img1,dx,dy,apertureSize);

cvNamedWindow("SobelEdge",1);

cvShowImage("SobelEdge",img1);

cvWaitKey();

return 0;

}

1 comment:

Bharghavi said...

Sir,
I need to know how to compute the Gradient of every pixel in a block.