1 #include"head.h" 2 //cvResize() 3 /*int main() 4 { 5 IplImage *img = cvLoadImage("e:/picture/Wife4.jpg"); 6 7 IplImage *big_img = cvCreateImage(cvSize(500, 600), img->depth,img->nChannels); 8 cvResize(img, big_img); 9 cvNamedWindow("big"); 10 cvNamedWindow("img"); 11 cvShowImage("img",img); 12 cvShowImage("big", big_img); 13 cvWaitKey(0); 14 cvReleaseImage(&img); 15 cvReleaseImage(&big_img); 16 cvDestroyWindow("big"); 17 return 0; 18 } 19 20 */ 21 //cvCvtColor() 22 //cvRectangle() 23 //cvPutText() 24 /*int main() 25 { 26 IplImage *img = cvLoadImage("e:/picture/Wife1.jpg"); 27 IplImage *big_img = cvCreateImage(cvSize(400, 500), img->depth, img->nChannels);//set to 1 channel 28 IplImage *gray_big_img = cvCreateImage(cvSize(400, 500), img->depth, 3); 29 cvResize(img, big_img); 30 cvCvtColor(big_img,gray_big_img,CV_RGB2BGR);//change into single channel image 31 //cvRectangle(gray_big_img,cvPoint(130,50),cvPoint(330,280),cvScalarAll(190),5,5);//draw a retangle 32 CvFont font = cvFont(3.5,5); 33 CvFont font2 = cvFont(2.0,3);//define font style 34 cvPutText(gray_big_img,"Dear",cvPoint(150,400),&font,cvScalar(0)); 35 cvPutText(gray_big_img,"WangXinYu",cvPoint(120,450),&font2,cvScalar(150,200,50));//input english letters into the picture 36 cvSetImageROI(gray_big_img,cvRect(130,50,200,230)); 37 cvAddS(gray_big_img,cvScalar(255,0255,0),gray_big_img); 38 cvResetImageROI(gray_big_img);//set interest rigion 39 //cvFlip(gray_big_img,gray_big_img,1);//image will circle around the x or y 40 cvDiv(gray_big_img,big_img,big_img); 41 cvNamedWindow("Grayimg"); 42 cvNamedWindow("Bigimg"); 43 cvShowImage("Bigimg",big_img); 44 cvShowImage("Grayimg",gray_big_img); 45 cvWaitKey(0); 46 cvReleaseImage(&big_img); 47 cvReleaseImage(&gray_big_img); 48 cvDestroyAllWindows(); 49 50 return 0; 51 52 }*/ 53 //cvSplit and cvMerge 54 int main() 55 { 56 IplImage *getimg = cvLoadImage("e:/picture/4.jpg"); 57 int depth = getimg->depth; 58 IplImage *img = cvCreateImage(cvSize(400,500),depth,getimg->nChannels); 59 cvResize(getimg,img); 60 CvSize size = cvGetSize(img); 61 IplImage *way1 = cvCreateImage(size,depth,1); 62 IplImage *way2 = cvCreateImage(size, depth, 1); 63 IplImage *way3 = cvCreateImage(size, depth, 1); 64 IplImage *merge = cvCreateImage(size,depth,3); 65 cvSplit(img,way1,way2,way3,NULL); 66 cvMerge(way1, way2, way3, NULL, merge); 67 cvNamedWindow("img"); 68 cvNamedWindow("way1"); 69 cvNamedWindow("way2"); 70 cvNamedWindow("way3"); 71 cvNamedWindow("merge"); 72 cvShowImage("img",img); 73 cvShowImage("way1",way1); 74 cvShowImage("way2", way2); 75 cvShowImage("way3", way3); 76 cvShowImage("merge",merge); 77 cvWaitKey(0); 78 cvReleaseImage(&img); 79 cvReleaseImage(&way1); 80 cvReleaseImage(&way2); 81 cvReleaseImage(&way3); 82 cvReleaseImage(&merge); 83 cvDestroyAllWindows(); 84 return 0; 85 86 }
时间: 2024-10-22 15:57:12