27 lines
748 B
Python
27 lines
748 B
Python
|
# -*- coding:utf-8 -*-
|
||
|
# @Author len
|
||
|
# @Create 2023/10/27 17:36
|
||
|
|
||
|
import cv2
|
||
|
import numpy as np
|
||
|
|
||
|
# 读取图像
|
||
|
image = cv2.imread('./240624/img_2.png')
|
||
|
|
||
|
# 将图像从BGR转换为HSV色彩空间
|
||
|
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
|
||
|
|
||
|
# 获取H, S, V通道的像素值
|
||
|
h, s, v = cv2.split(hsv)
|
||
|
|
||
|
# 获取每个通道的最小和最大像素值
|
||
|
h_min, h_max = np.min(h), np.max(h)
|
||
|
s_min, s_max = np.min(s), np.max(s)
|
||
|
v_min, v_max = np.min(v), np.max(v)
|
||
|
|
||
|
print(f"Hue range: {h_min} - {h_max}")
|
||
|
print(f"Saturation range: {s_min} - {s_max}")
|
||
|
print(f"Value range: {v_min} - {v_max}")
|
||
|
|
||
|
print("{}, {}, {}, {}, {}, {}".format(h_min, h_max, s_min, s_max, v_min, v_max))
|
||
|
print("{}, {}, {} \t {}, {}, {}".format(h_min, s_min, v_min, h_max, s_max, v_max))
|