def retinex_shadow_removal(image, retinex_type): with open('config.json', 'r') as f: config = json.load(f) if retinex_type == 'automatedMSRCR': return retinex.automatedMSRCR(image, config['sigma_list']) elif retinex_type == 'MSRCRP': return retinex.MSRCP(image, config['sigma_list'], config['low_clip'], config['high_clip']) elif retinex_type == 'MSRCR': return retinex.MSRCR(image, config['sigma_list'], config['G'], config['b'], config['alpha'], config['beta'], config['low_clip'], config['high_clip']) else: return image
exit() # 读入自定义参数 with open('config.json', 'r') as f: config = json.load(f) # 遍历读入的图像 for img_name in img_list: if img_name == '.gitkeep': continue # 读入图像 img = cv2.imread(os.path.join(data_path, img_name)) img_histogram = coloredHistoEqual(img) img_gamma = adjust_gamma(img) # 多尺度Retinex带色彩恢复 img_msrcr = retinex.MSRCR(img, config['sigma_list'], config['G'], config['b'], config['alpha'], config['beta'], config['low_clip'], config['high_clip']) img_amsrcr = retinex.automatedMSRCR(img, config['sigma_list']) # MSR with chromaticity preservation img_msrcp = retinex.MSRCP(img, config['sigma_list'], config['low_clip'], config['high_clip']) # 实验结果 shape = img.shape cv2.imshow('Image', img) cv2.imshow('retinex', img_msrcr) cv2.imshow('Histogram equalization', img_histogram) cv2.imshow('Gamma Correction', img_gamma) cv2.imshow('Automated retinex', img_amsrcr) cv2.imshow('MSRCP', img_msrcp)
import json import retinex data_path = 'data' # size = 3 img = cv2.imread('timg.jpg') img_ssr_re = retinex.singleScaleRetinex(img, 15) img_ssr_cl = retinex.colorRestoration(img, 125.0, 46.0) img_ssr = 5 * (img_ssr_re * img_ssr_cl + 25) cv2.imshow('ssr', img_ssr) img_msrcr = retinex.MSRCR( img, 80, 5.0, 25.0, 125.0, 46.0, 0.01, 0.99 ) # cv2.imshow('MSRCR retinex', img_msrcr) shape = img.shape # cv2.imshow('Image', img) cv2.waitKey()