#include <highgui.h>
#include <cv.h>
#include <iostream.h>
void main()
{
IplImage* src_img=cvLoadImage("zjut.jpg",1); //读入一幅图像
IplImage* dst_img;
//一下为显示读入图像的一些信息
cout<<"★★★★★★★★★★★★★★★★★★★★★★"<<endl<<endl;
cout<<" 1.jpg的图像信息"<<endl<<endl;
cout<<"★★★★★★★★★★★★★★★★★★★★★★"<<endl<<endl;
// IplImage该结构体的大小:112字节
cout<<" Img's size: "<<src_img->nSize<<endl;
//版本ID :0
cout<<" Img's ID: "<<src_img->ID<<endl;
// 显示读入图像信道数:3
cout<<"Img's channel's nums: "<<src_img->nChannels<<endl;
//像素的位深度: 8
cout<<" Img's depth: "<<src_img->depth<<endl;
//0 - 交叉存取颜色信道,
cout<<" Img's dataOrder: "<<src_img->dataOrder<<endl;
//0 - 图像数据分布结果:顶-左结构
cout<<" Img's origin: "<<src_img->origin<<endl;
//图像宽像素数:400
cout<<" Img's width: "<<src_img->width<<endl;
//图像高度像素数:600
cout<<" Img's height: "<<src_img->height<<endl;
// 未指定ROI区域指针为空:0x00000000:
cout<<" Img's ROI: "<<src_img->roi<<endl;
//排列的图像行大小:1200
cout<<" Img's widthStep: "<<src_img->widthStep<<endl;
// 图像数据大小(在交叉存取格式下imageSize=image->height*image->widthStep),单位字节
cout<<" Img'imageSize: "<<src_img->imageSize<<endl;
//输出图像一个像素对应的RGB值。
for(int i=0; i<200; i=i+3)
{
cout<<(int)(uchar)src_img->imageData[i] <<" " //Blue
<<(int)(uchar)src_img->imageData[i+1]<<" " //Green
<<(int)(uchar)src_img->imageData[i+2]<<" " //Red
<<endl;
}
dst_img=cvCreateImage( cvSize(src_img->width,
src_img->height ),
src_img->depth, 3 );
//dst_img 是src_img的倒置图像
cvConvertImage(src_img,dst_img,CV_CVTIMG_FLIP);
cvNamedWindow("1.jpg",CV_WINDOW_AUTOSIZE);
cvNamedWindow("2.jpg",CV_WINDOW_AUTOSIZE);
cvShowImage("1.jpg",src_img); //显示图像
cvShowImage("2.jpg",dst_img);
cvWaitKey(0);
cvReleaseImage(&src_img); //释放图像
cvReleaseImage(&dst_img);
}