OpenCV注意事项(持续更新)

1.

    读取存储图像从文件中载入图像:   IplImage* img = cvLoadImage(fileName);Supported image formats: BMP, DIB, JPEG, JPG, JPE, PNG, PBM, PGM, PPM, SR, RAS, TIFF, TIF

    载入图像默认转为3通道彩色图像. 如果不是,则需加flag:

    img=cvLoadImage(fileName,flag);
    flag: >0 载入图像转为三通道彩色图像
          =0 载入图像转为单通道灰度图像
          <0 不转换载入图像(通道数与图像文件相同).

2.

Adaptive Thresholding

    There are two main approaches to finding the threshold: (i) theChow and Kaneko approach and (ii)local thresholding. The assumption behind both methods is that smaller image regions are more likely to have approximately uniform illumination, thus being more suitable for thresholding.

 

  自适应阈值化的重要思想是:越小的图像区域就越近似一致。

 

3.

    关于多通道浮点型图像(假设图像数据采用4字节(32位)行对齐方式)的访问问题, 在OpenCV编程简介中,给出了这样一种访问方式:

IplImage* img  = cvCreateImage(cvSize(640,480),IPL_DEPTH_32F,3);
int height     = img->height;
int width      = img->width;
int step       = img->widthStep;
int channels   = img->nChannels;
float * data    = (float *)img->imageData;
data[i*step+j*channels+k] = 111;

 这种访问方式明显是错误的,错在step的确定,这里的img->widthstep = width * channels * sizeof(float),而我们的data数组是float型的,所以* sizeof(float)是完完全全多余的,正确的方式应该为:int step = img->widthStep/sizeof(float);

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值