OpenCV Mat类函数


基于OpenCV的数字图像处理技术大大提升了视觉开发的效率,在各种处理技术的实现上,诸如:图像增强、图像分割、图像编码与压缩等,都要使用到C++语言中的Mat类及其类函数,本文就OpenCV中Mat类中的常用类函数进行了总结,便于日后学习与运用。


CvImage::CvImage

bool CvImage::CvImage();
bool CvImage::CvImage(CvSize size, int depth, int channels);
bool CvImage::CvImage(IplImage* pIplImg);
bool CvImage::CvImage(const CvImage& cvImg);
bool CvImage::CvImage(const char* filename, const char* imgname=0, int color=-1);
bool CvImage::CvImage(CvFileStorage* fs, const char* mapname, const char* imgname);
bool CvImage::CvImage(CvFileStorage* fs, const char* seqname, int idx);

默认构造函数,创建一个图像。影象对应的数据在析构的时候自动被释放。

size -图像大小

depth- 像素深度

channels- 通道数

pIplImg

IplImage结构影象

cvImg

CvImage - 对象的引用

filename- 文件名字

imgname- 图片的别名

color

暂无

fs

暂无

mapname

暂无

seqname 存储队列的名字

idx  数据存储中的索引


CvImage::~CvImage

CvImage::~CvImage();

析构函数。


CvImage::clone

CvImage CvImage::clone();  //生成当前影象的一个copy。

CvImage::create

void CvImage::create(CvSize size, int depth, int channels);  //创建一个影象。

size-图像大小

depth-像素深度

channels-通道数


CvImage::release

void CvImage::release();   //释放一个打开的影象。

CvImage::clear

void CvImage::clear();

释放一个打开的影象。和release功能相同。


CvImage::attach

void CvImage::attach(IplImage* img, bool use_refcount=true);

//将一个影象和当前对象绑定。如果使用引用计数,则引用计数增加1。 当引用计数减少到0的时候释放img对应的内存。

img-图像数据

use_refcount-是否使用引用计数


CvImage::detach

void CvImage::detach();

取消当前对象绑定的数据。如果使用引用计数,则引用计数减少1。 当引用计数减少到0的时候释放img对应的内存。


CvImage::load

bool CvImage::load(const char* filename, const char* imgname=0, int color=-1);

暂无。


CvImage::read

bool CvImage::read(CvFileStorage* fs, const char* mapname, const char* imgname );
bool CvImage::read(CvFileStorage* fs, const char* seqname, int idx);

暂无。


CvImage::save

void CvImage::save(const char* filename, const char* imgname);

暂无。


CvImage::write

void CvImage::write(CvFileStorage* fs, const char* imgname);

暂无。


CvImage::show

void CvImage::show(const char* window_name);

在指定窗口中显示图像。

window_name

窗口的名字。


CvImage::is_valid

bool CvImage::is_valid();

当前对象是否已经帮定了有效的影象。是返回true,否返回false。


CvImage::width

int CvImage::width()const;

//返回影象的宽度。没有影象的话返回0。


CvImage::height

int CvImage::height()const;

返回影象的高度。没有影象的话返回0。


CvImage::size

CvSize CvImage::size()const;

返回影象的尺寸。没有影象的话返回cvSize(0,0)。


CvImage::roi_size

CvSize CvImage::roi_size()const;

返回影象的ROI区域大小。没有影象的话返回cvSize(0,0)。


CvImage::roi

CvRect CvImage::roi()const;

返回影象的ROI区域。没有影象的话返回cvRect(0,0,0,0)。


CvImage::coi

int CvImage::coi()const;

返回影象的COI。没有影象的话返回0。


CvImage::set_roi

void CvImage::set_roi(CvRect roi);

设置影象的ROI。

roi

ROI区域。


CvImage::reset_roi

void CvImage::reset_roi();

重置影象的ROI。


CvImage::set_coi

void CvImage::set_coi();

返回影象的COI。


CvImage::depth

int CvImage::depth();

返回像素的深度。没有影象的话返回0。


CvImage::channels

int CvImage::channels();

返回影象通道数。没有影象的话返回0。


CvImage::pix_size

int CvImage::pix_size();

返回影象像素的大小。值等于像素深度乘以通道数。


CvImage::data

uchar* CvImage::data();
const uchar* CvImage::data()const;

获取对应对应的影象数据地址。没有影象的话返回NULL。


CvImage::step

int CvImage::step()const;

返回IplImage::widthStep,没有影象的话返回0。


CvImage::origin

int CvImage::origin()const;

返回影象结构。0-顶—左结构,1-底—左结构 (Windows bitmaps 风格)。


CvImage::roi_row

uchar* CvImage::roi_row(int y);
const uchar* CvImage::roi_row(int y)const;

返回第y行数据。没有影象的话返回NULL。

y

影象行数。


运算符重载

operator const IplImage* ();
operator IplImage* ();
CvImage& operator=(const CvImage& img);

猜你喜欢

转载自blog.csdn.net/hhaowang/article/details/86561915