Preprocess image using LARCOTM algorithm

1. 這個是算法描述 ...

2.本文引用自:

LARCOTM algorithm

如有侵權,請聯繫我在刪除...

import cv2
from cv2.ximgproc import guidedFilter
import numpy as np

def larcotm(filepath, strength=0):
    """Preprocess image using LARCOTM algorithm

    Locally Adaptive Rank-Constrained Optimal Tone Mapping
    https://dl.acm.org/citation.cfm?id=3243123.3225219

    Args:
        filepath: path to input image
        strength: strength of applied LARCOTM algorithm
    
    Returns:
        OpenCV image processed by LARCOTM algorithm
    """
    img_bgr = cv2.imread(filepath, flags=cv2.IMREAD_COLOR)  # BGR
    
    img = np.float32(img_bgr) / 255.
    src = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    if strength == 0:
        gmean = np.mean(src) * 255
        gstre = np.minimum(
            np.maximum((25 - gmean) * 5, 50),
            100
        )
        strength = gstre
    
    log_min 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章