簡體   English   中英

360 度圖像中的對比度受限自適應直方圖均衡

[英]Contrast Limited Adaptive Histogram Equalization in 360 images

我目前正在應用對比度受限自適應直方圖均衡算法和算法來執行照片去噪。

我的問題是我正在使用 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, a, b))  # merge channels
    img2 = cv2.cvtColor(lab, cv2.COLOR_LAB2BGR)  # convert from LAB to BGR

結果:

結果

360 執行:

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, 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);
}

圖片:輸入您的原始帖子。

創建邊框后: 在此處輸入圖像描述

執行 CLAHE(帶邊框)后: 在此處輸入圖像描述

裁剪 CLAHE-border-image 后: 在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM