retinex算法求亮度分量python代码
时间: 2023-03-27 10:01:54 浏览: 116
retinex算法代码
以下是 retinex 算法求亮度分量的 Python 代码:
```python
import cv2
import numpy as np
def retinex(img, sigma_list):
retinex_img = np.zeros_like(img)
for sigma in sigma_list:
img_blur = cv2.GaussianBlur(img, (, ), sigma)
img_blur = np.where(img_blur == , .1, img_blur)
retinex = np.log10(img) - np.log10(img_blur)
retinex_img += retinex
retinex_img = retinex_img / len(sigma_list)
return retinex_img
img = cv2.imread('image.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
sigma_list = [15, 80, 250]
retinex_img = retinex(img, sigma_list)
cv2.imwrite('retinex.jpg', retinex_img)
```
希望能对您有所帮助。
阅读全文