gpt4 book ai didi

image - 360 度图像中的对比度受限自适应直方图均衡

转载 作者:行者123 更新时间:2023-12-02 16:12:32 25 4
gpt4 key购买 nike

我目前正在应用对比度受限自适应直方图均衡算法和一种算法来执行照片降噪。

我的问题是我正在处理 360 度全景照片。当我加入照片时,对比度在边缘产生不同的值,因此边缘线非常明显。我怎样才能减轻那条线?我应该进行哪些更改才能使其不引人注意并始终如一地应用算法?

原始照片:

Original Photo

对比有限自适应直方图均衡的代码

    # 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, a, b)) # merge channels
img2 = cv2.cvtColor(lab, cv2.COLOR_LAB2BGR) # convert from LAB to BGR

结果:

Reusult

360 执行:

360 deformed

这是非常臭名昭著的分隔线,因为它没有考虑到稍后加入照片。我能做什么?

最佳答案

这是 C++ 的答案,您可以轻松地将其转换为 python/numpy。这个想法是在执行 CLAHE 之前使用边界区域并在之后裁剪图像。

这些是原始图像中的子图像区域: enter image description here

它们将被复制到图像的左/右,如下所示: enter image description here

也许你可以大大减小边框的大小:

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, 0, borderSize, borderImage.rows);
cv::Rect rightBorderRegion = cv::Rect(borderImage.cols - borderSize, 0, borderSize, borderImage.rows);
cv::Rect imgRegion = cv::Rect(borderSize, 0, img.cols, borderImage.rows);

// original image regions to copy:
cv::Rect left = cv::Rect(0, 0, borderSize, borderImage.rows);
cv::Rect right = cv::Rect(img.cols - borderSize, 0, borderSize, img.rows);
cv::Rect full = cv::Rect(0, 0, img.cols, 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, a, 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);
}

图像:按照您的原始帖子输入。

创建边框后: enter image description here

执行 CLAHE 后(带边框): enter image description here

裁剪 CLAHE-border-image 后: enter image description here

关于image - 360 度图像中的对比度受限自适应直方图均衡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67634460/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com