如何解决360 图像中对比度受限的自适应直方图均衡化
我目前正在应用 Contrast Limited Adaptive Histogram Equalization 算法和一种算法来执行照片降噪。
我的问题是我正在处理 360 度全景照片。由于加入照片时对比度会在边缘处产生不同的值,因此边缘线非常明显。我怎样才能减轻那条线?我应该进行哪些更改,使其不明显并且算法得到一致应用?
原始照片:
对比有限自适应直方图均衡化的代码
# CLAHE (Contrast Limited Adaptive Histogram Equalization)
clahe = cv2.createCLAHE(clipLimit=1.,tileGridSize=(6,6))
lab = cv2.cvtColor(image,cv2.COLOR_BGR2LAB) # convert from BGR to LAB color space
l,a,b = cv2.split(lab) # split on 3 different channels
l2 = clahe.apply(l) # apply CLAHE to the L-channel
lab = cv2.merge((l2,b)) # merge channels
img2 = cv2.cvtColor(lab,cv2.COLOR_LAB2BGR) # convert from LAB to BGR
结果:
360 执行:
这是非常臭名昭著的分隔线,因为它没有考虑到照片是稍后加入的。我能做什么?
解决方法
这是 C++ 的答案,您可以轻松地将其转换为 python/numpy。 这个想法是在执行 CLAHE 之前使用边界区域并在之后裁剪图像。
也许你可以大大减少边框的大小:
int main()
{
cv::Mat img = cv::imread("C:/data/SO_360.jpg");
int borderSize = img.cols / 4;
// make image that can have some border region
cv::Mat borderImage = cv::Mat(cv::Size(img.cols + 2 * borderSize,img.rows),img.type());
// posX,posY,width,height of the subimages
cv::Rect leftBorderRegion = cv::Rect(0,borderSize,borderImage.rows);
cv::Rect rightBorderRegion = cv::Rect(borderImage.cols - borderSize,borderImage.rows);
cv::Rect imgRegion = cv::Rect(borderSize,img.cols,borderImage.rows);
// original image regions to copy:
cv::Rect left = cv::Rect(0,borderImage.rows);
cv::Rect right = cv::Rect(img.cols - borderSize,img.rows);
cv::Rect full = cv::Rect(0,img.rows);
// perform copying to subimage (left part of the img goes to right part of the border image):
img(left).copyTo(borderImage(rightBorderRegion));
img(right).copyTo(borderImage(leftBorderRegion));
img.copyTo(borderImage(imgRegion));
cv::imwrite("SO_360_border.jpg",borderImage);
//# CLAHE(Contrast Limited Adaptive Histogram Equalization)
//clahe = cv2.createCLAHE(clipLimit = 1.,tileGridSize = (6,6))
// apply the CLAHE algorithm to the L channel
cv::Ptr<cv::CLAHE> clahe = cv::createCLAHE();
clahe->setClipLimit(1);
clahe->setTilesGridSize(cv::Size(6,6));
cv::Mat lab;
cv::cvtColor(borderImage,lab,cv::COLOR_BGR2Lab); // # convert from BGR to LAB color space
std::vector<cv::Mat> labChannels; //l,a,b = cv2.split(lab) # split on 3 different channels
cv::split(lab,labChannels);
//l2 = clahe.apply(l) # apply CLAHE to the L - channel
cv::Mat dst;
clahe->apply(labChannels[0],dst);
labChannels[0] = dst;
//lab = cv2.merge((l2,b)) # merge channels
cv::merge(labChannels,lab);
//img2 = cv2.cvtColor(lab,cv2.COLOR_LAB2BGR) # convert from LAB to BGR
cv::cvtColor(lab,dst,cv::COLOR_Lab2BGR);
cv::imwrite("SO_360_border_clahe.jpg",dst);
// to crop the image after performing clahe:
cv::Mat cropped = dst(imgRegion).clone();
cv::imwrite("SO_360_clahe.jpg",cropped);
}
图片: 输入您的原始帖子。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。