cvCanny
#include "cv.h"
#include "highgui.h"
//Canny只能接受灰階圖(單通道)
IplImage *doCanny( IplImage *in, double low ,double top , double s)
{
IplImage *out = cvCreateImage(cvGetSize(in), in->depth , in->nChannels);
cvCanny(in , out , low , top ,s);
//cvCanny(原圖,輸出圖,控制邊緣連接,控制邊緣的初始分割
return out;
}
int main()
{
IplImage *i = cvLoadImage("picture.jpg");
cvNamedWindow("oringe", 1);
cvShowImage("oringe" , i);
//需創造一個相同條件之影像格式,通道更改為單通道
IplImage *to_gray =cvCreateImage(cvGetSize(i) ,i->depth ,1);
//cvCreateImage( CvSize size, int depth, int channels );
//更改色度,採色變灰階
cvCvtColor(i ,to_gray ,CV_BGR2GRAY);
//cvCvtColor(欲轉換圖檔 , 接受轉換後圖檔 ,轉換類別)
//進行二值化
IplImage *Canny =doCanny(to_gray ,10, 100, 3);
cvNamedWindow("Canny" , 1);
cvShowImage("Canny" , Canny);
cvWaitKey(0);
cvReleaseImage(&i);
cvReleaseImage(&Canny);
cvDestroyWindow("Canny");
cvDestroyWindow("oringe");
}
#include "highgui.h"
//Canny只能接受灰階圖(單通道)
IplImage *doCanny( IplImage *in, double low ,double top , double s)
{
IplImage *out = cvCreateImage(cvGetSize(in), in->depth , in->nChannels);
cvCanny(in , out , low , top ,s);
//cvCanny(原圖,輸出圖,控制邊緣連接,控制邊緣的初始分割
return out;
}
int main()
{
IplImage *i = cvLoadImage("picture.jpg");
cvNamedWindow("oringe", 1);
cvShowImage("oringe" , i);
//需創造一個相同條件之影像格式,通道更改為單通道
IplImage *to_gray =cvCreateImage(cvGetSize(i) ,i->depth ,1);
//cvCreateImage( CvSize size, int depth, int channels );
//更改色度,採色變灰階
cvCvtColor(i ,to_gray ,CV_BGR2GRAY);
//cvCvtColor(欲轉換圖檔 , 接受轉換後圖檔 ,轉換類別)
//進行二值化
IplImage *Canny =doCanny(to_gray ,10, 100, 3);
cvNamedWindow("Canny" , 1);
cvShowImage("Canny" , Canny);
cvWaitKey(0);
cvReleaseImage(&i);
cvReleaseImage(&Canny);
cvDestroyWindow("Canny");
cvDestroyWindow("oringe");
}
留言
張貼留言