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);