*****************/ #include <cv.h> #include <highgui.h> int main() { char* filePath ="D:/圖片庫/Lena.jpg"; IplImage* srcImg = cvLoadImage(filePath); IplImage* greyImg = cvCreateImage(cvGetSize(srcImg), srcImg->depth, 1); IplImage* cannyImg = cvCreateImage(cvGetSize(greyImg), srcImg->depth, 1); CvSize dstSize; dstSize.width = srcImg->width *3.0; dstSize.height = srcImg->height; IplImage* dstImg = cvCreateImage(dstSize, srcImg->depth, srcImg->nChannels); cvZero(dstImg); cvConvertImage(srcImg, greyImg); cvCanny(greyImg, cannyImg, 150, 100); //---------------------------------- //載入原圖像到目標圖像 cvSetImageROI(dstImg, cvRect(0, 0, srcImg->width, srcImg->height)); cvCopy(srcImg, dstImg); cvResetImageROI(dstImg); //載入灰度圖像到目標圖像 cvSetImageROI(dstImg, cvRect(srcImg->width, 0, srcImg->width, srcImg->height)); dstImg->nChannels =1; cvCopy(greyImg, dstImg); cvResetImageROI(dstImg); //載入邊緣檢測圖像到目標圖像 cvSetImageROI(dstImg, cvRect((srcImg->width) *2.0, 0, srcImg->width, srcImg->height)); dstImg->nChannels =1; cvCopy(cannyImg, dstImg); cvResetImageROI(dstImg); //--------------------------------------- cvNamedWindow("dstImg"); cvShowImage("dstImg", dstImg); cvWaitKey(0); cvReleaseImage(&srcImg); cvReleaseImage(&greyImg); cvReleaseImage(&cannyImg); cvReleaseImage(&dstImg); cvDestroyWindow("dstImg"); return0;