
在opencv里用Mat直接改写函数void LogEnhance(IplImage* img, IplImage* dst)
可不可以直接把voidLogEnhance(IplImage*img,IplImage*dst)括号内的类型定义改为Mat类型?总之,不想用IPL麻烦死了,求助大神们vo...
可不可以直接把void LogEnhance(IplImage* img, IplImage* dst) 括号内的类型定义改为Mat类型?总之,不想用IPL麻烦死了,求助大神们
void LogEnhance(IplImage* img, IplImage* dst)
{
// 由于oldPixel:[1,256],则可以先保存一个查找表
uchar lut[256] ={0};
double temp = 255/log(256);
for ( int i =0; i<255; i++)
{
lut[i] = (uchar)(temp* log(i+1)+0.5);
}
for( int row =0; row <img->height; row++)
{
uchar *data = (uchar*)img->imageData+ row* img->widthStep;
uchar *dstData = (uchar*)dst->imageData+ row* dst->widthStep;
for ( int col = 0; col<img->width; col++)
{
for( int k=0; k<img->nChannels; k++)
{
uchar t1 = data[col*img->nChannels+k];
dstData[col*img->nChannels+k] = lut[t1];
}
}
}
} 展开
void LogEnhance(IplImage* img, IplImage* dst)
{
// 由于oldPixel:[1,256],则可以先保存一个查找表
uchar lut[256] ={0};
double temp = 255/log(256);
for ( int i =0; i<255; i++)
{
lut[i] = (uchar)(temp* log(i+1)+0.5);
}
for( int row =0; row <img->height; row++)
{
uchar *data = (uchar*)img->imageData+ row* img->widthStep;
uchar *dstData = (uchar*)dst->imageData+ row* dst->widthStep;
for ( int col = 0; col<img->width; col++)
{
for( int k=0; k<img->nChannels; k++)
{
uchar t1 = data[col*img->nChannels+k];
dstData[col*img->nChannels+k] = lut[t1];
}
}
}
} 展开
展开全部
CvImage( IplImage* img )可以将IplImage转换为CvImage。 CvImage类中 protected: IplImage* image; // 实际影象 int* refcount; // 引用计数 IplImage* image由于是protected. 可以在OpenCVcxcoresrccximage.cpp里添加一个方法
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询