以下是用LUT实现的直方图均衡算法函数,请填空完成/*输入参数:unsigned char *img8位灰度图像位图数据首地址int count图像像素个数输出参数:unsigned char *img8位灰度图像位图数据首地址功能:8位灰度图像的直方图均衡化*/void Equalize(unsigned char *img,int count){int i;unsigned char *p = img;//统计直方图int hist[256];memset(hist,0,256*sizeof(int));for(i = 0; i < count; i++){hist[*p++]++;}//计算映射关系unsigned char LUT[256];int H = 0;for(i = 0; i < 256;i++){H += ___________;LUT[i] = 255 * H / ___________;}//逐点替换for(i = 0; i < count; i++){*img = LUT[_______];img++;}}
查看答案
以下是用LUT实现的自动对比度调整算法,请填空完成。/*输入参数:unsigned char *img8位灰度图像位图数据首地址int count图像像素个数输出参数:unsigned char *img8位灰度图像位图数据首地址功能:8位灰度图像的自动对比度增强*/void AutoContrast(unsigned char *img,int count){//求取图像中的最小像素值和最大像素值int grayLow = 255, grayHigh = 0;int i;unsigned char *p = img;for(i = 0; i < count; i++){if(*p < grayLow) grayLow = *p;if(*p > grayHigh) grayHigh = *p;p++;}if(grayHigh - grayLow == 0)return;//图像中的灰度值均相等,无法进行自动对比度调整unsigned char LUT[256];for(i = 0; i < 256;i++){LUT[i] = (i - _____________) *255/ ( grayHigh - grayLow );}//自动对比度映射p = img;for(i = 0; i < count; i++){*p++ =________________;}}
以下是二维高斯滤波器的xy分离实现形式。请填空。*输入参数:const unsigned char *src_data输入的8位灰度图像位图数据首地址int cols 像素列数int rows 像素行数double sigma 标准差输出参数:unsigned char *dst_data高斯滤波后的8位灰度图像位图数据首地址功能:8位灰度图像的二维高斯滤波*/void GaussianFilter(const unsigned char *src_data, unsigned char *dst_data,int cols,int rows,double sigma){int i,j,m,n;float sum=0;int center = (int)(3 * sigma);//3sigma原理int length = ____________;float* kernel = new float[length];double sigma2 = sigma*sigma;//由高斯公式计算滤波系数for(i = 0;i
图像几何变换一般包括两个步骤:空间变换和____________________
以下程序用OpenCV读入一幅彩色图像并显示。#include #include #include using namespace cv;using namespace std;int main( int argc, char** argv ){______________ image;image = ______________ (argv[1], CV_LOAD_IMAGE_COLOR);namedWindow( "Display window",CV_WINDOW_AUTOSIZE );_____________( "Display window", image );waitKey(0);return 0;}