作者:gnuhpc
出處:http://www.cnblogs.com/gnuhpc/
#include "cv.h"
#include "highgui.h"
#include <iostream.h>
void main()
{
IplImage *src_img =cvLoadImage("lena.jpg",-1);//讀入圖像
IplImage *dst_img;
cout<<"******************************"<<endl<<endl;
cout<<"The information"<<endl<<endl;
cout<<"Size:"<<src_img->nSize<<endl;//這個結構體的大小
cout<<"ID:"<<src_img->ID<<endl;//版本
cout<<"Channels:"<<src_img->nChannels<<endl;//圖像通道數
cout<<"Dataorder:"<<src_img->dataOrder<<endl;//交叉存取顏色通道
cout<<"Original:"<<src_img->origin<<endl; //圖像數據分布結果
cout<<"Depth:"<<src_img->depth<<endl;//圖像色深
cout<<"Width"<<src_img->width<<endl;//圖像寬度像素
cout<<"Height"<<src_img->height<<endl;//圖像高度像素
cout<<"ROI:"<<src_img->roi<<endl;//未指定ROI區域指針
cout<<"WidthStep"<<src_img->widthStep<<endl;//排列的圖像行大小
cout<<"ImageSize"<<src_img->imageSize<<endl;//圖像數據大小
/*輸出圖像的一塊RGB值*/
for (int i=0;i<200;i+=3)
{
cout<<(int)(uchar)src_img->imageData[i];//Blue
cout<<",";
cout<<(int)(uchar)src_img->imageData[i+1];//Green
cout<<",";
cout<<(int)(uchar)src_img->imageData[i+2]<<endl;//Red
}
dst_img=cvCreateImage(cvSize(src_img->width,src_img->height),
src_img->depth,3);
cvConvertImage(src_img,dst_img,CV_CVTIMG_FLIP);//倒置圖像
cvNamedWindow("lena.jpg",CV_WINDOW_AUTOSIZE);
cvNamedWindow("lenaflip.jpg",CV_WINDOW_AUTOSIZE);
cvShowImage("lena.jpg",src_img);
cvShowImage("lenaflip.jpg",dst_img);
cvWaitKey(0);
cvReleaseImage(&src_img);
cvReleaseImage(&dst_img);
}
