总结最近项目中常用的图像增强方法:
非锐化模板的处理步骤:
1. 高斯低通滤波图像
2. 从原图像减去模糊图像(产生的差值图像称为模板)
3. 将模板加到原图像上
高提升滤波的处理步骤:
1. 模糊原图像
2. 从原图像减去模糊图像(产生的差值图像称为模板)
3. 将模板加到原图像上
cv::Mat srcMat = imread("ImageEnhancement\\0_dust.bmp");
cv::Mat grayMat = srcMat.clone();
if (grayMat.channels() != 1) cvtColor(grayMat, grayMat, cv::COLOR_BGR2GRAY);
cv::Mat blurMat;
GaussianBlur(grayMat, blurMat, cv::Size(15, 15), 3);
//扩展四周边界确保傅里叶变换结果
const int fillSize = 100;
Mat imgGrayEx;
cv::copyMakeBorder(blurMat, imgGrayEx, fillSize, fillSize, fillSize, fillSize, cv::BORDER_DEFAULT);
//傅里叶低通滤波获取背景,可公开参数低通值
cv::Mat lpf3 = m_conFunCls.GaussianLPFilter(imgGrayEx.rows, imgGrayEx.cols, 20, false, CV_32F);
cv::Mat imgFreqBluredEx3 = m_conFunCls.GaussFreqBlur(imgGrayEx, lpf3, CV_32FC1);
imgFreqBluredEx3 = imgFreqBluredEx3(cv::Rect(fillSize, fillSize, blurMat.cols, blurMat.rows));
imgFreqBluredEx3.convertTo(imgFreqBluredEx3, CV_8UC1);
//非锐化模板
cv::Mat mask = grayMat - blurMat;
//非锐化遮蔽
cv::Mat dstMat = grayMat + mask;
//高提升滤波
cv::Mat dstMat2 = grayMat + 4.5*mask;
//非锐化模板(高斯低通滤波模板)
cv::Mat gmask = grayMat - imgFreqBluredEx3;
//非锐化遮蔽(高斯低通滤波模板)
cv::Mat gdstMat = grayMat + mask;
//高提升滤波(高斯低通滤波模板)
cv::Mat gdstMat2 = grayMat + 4.5*mask;
高频强调滤波的处理步骤:
1. 获取高斯高通滤波图像
2. 将模板加到原图像上
3. 更一般的公式为:
示例:高斯高通滤波参数D= 40;高频强调滤波参数k1 = 0.5, k2 = 0.75;
c d
图1 (a)胸部X射线图像 (b)高斯高通滤波后结果 (c)相同滤波器下强调滤波器结果 (d)直方图均衡后的结果
cv::Mat srcMat = imread("ImageEnhancement\\Fig0459(a)(orig_chest_xray).tif");
//cv::Mat srcMat = imread("ImageEnhancement\\1_whiteinpaint.bmp");
cv::Mat grayMat = srcMat.clone();
if (grayMat.channels() != 1) cvtColor(grayMat, grayMat, cv::COLOR_BGR2GRAY);
cv::Mat blurMat;
GaussianBlur(grayMat, blurMat, cv::Size(15, 15), 3);
//扩展四周边界确保傅里叶变换结果
const int fillSize = 50;
Mat imgGrayEx;
cv::copyMakeBorder(blurMat, imgGrayEx, fillSize, fillSize, fillSize, fillSize, cv::BORDER_DEFAULT);
//傅里叶高通滤波获取背景,可公开参数低通值
cv::Mat lpf3 = m_conFunCls.GaussianHPFilter(imgGrayEx.rows, imgGrayEx.cols, 40, false, CV_32F);
cv::Mat imgFreqBluredEx3 = m_conFunCls.GaussFreqBlur(imgGrayEx, lpf3, CV_32FC1);
imgFreqBluredEx3 = imgFreqBluredEx3(cv::Rect(fillSize, fillSize, blurMat.cols, blurMat.rows));
imgFreqBluredEx3.convertTo(imgFreqBluredEx3, CV_8UC1);
cv::Mat dstMat = 0.5*grayMat + 0.75*imgFreqBluredEx3;
cv::Mat dstMat2;
equalizeHist(dstMat, dstMat2);