获取图像 opencv 中每个通道的对比度 python
Get contrast for each channel in an image opencv python
如何计算图像中每个通道的对比度?
因为它们有很多对比定义 there
- 网络栏对比
- 迈克尔逊对比
- RMS 对比度
我需要计算这些对比。
from PIL import Image
import numpy as np
from numpy import mean, sqrt, square
im = Image.open("leaf.jpg") # Image file name
pixels = list(im.getdata())
width, height = im.size
pixels = np.asarray([pixels[i * width:(i + 1) * width] for i in range(height)], dtype=int)
ch_1 = pixels[:,:,0]
ch_2 = pixels[:,:,1]
ch_3 = pixels[:,:,2]
rms_of_ch1 = sqrt(mean(square(ch_1)))
rms_of_ch2 = sqrt(mean(square(ch_2)))
rms_of_ch3 = sqrt(mean(square(ch_3)))
如何计算图像中每个通道的对比度? 因为它们有很多对比定义 there
- 网络栏对比
- 迈克尔逊对比
- RMS 对比度
我需要计算这些对比。
from PIL import Image
import numpy as np
from numpy import mean, sqrt, square
im = Image.open("leaf.jpg") # Image file name
pixels = list(im.getdata())
width, height = im.size
pixels = np.asarray([pixels[i * width:(i + 1) * width] for i in range(height)], dtype=int)
ch_1 = pixels[:,:,0]
ch_2 = pixels[:,:,1]
ch_3 = pixels[:,:,2]
rms_of_ch1 = sqrt(mean(square(ch_1)))
rms_of_ch2 = sqrt(mean(square(ch_2)))
rms_of_ch3 = sqrt(mean(square(ch_3)))