一、说明
Lens Shading Correction
1.定位网格位置为55
2.要进行拆分4通道,减OB
3.ROIROI的区域大小
二、计算说明
import logging
import numpy as np
import img_raw
import cv2
logger = logging.getLogger()
logging.basicConfig(level=logging.INFO)
def LSC_select_region(image,region_size=10):
# 将RAW10转换为RAW8,用于画图,这个拆分后,中心就会不一样
raw_data_8bit = (image / 4).astype(np.uint8)
# 1. 将Bayer转换为RGB
img_rgb = cv2.cvtColor(raw_data_8bit, cv2.COLOR_BAYER_BG2RGB)
ls=[]
#网格5*5,固定坐标
grid=[128,384,640,896,1152]
for x in grid:
for y in grid:
# 定义区域的边界
start_x = max(x - region_size//2, 0) # 确保不超出图像左边界
start_y = max(y - region_size//2, 0) # 确保不超出图像上边界
end_x = min(x + region_size//2, image.shape[1] - 1) # 确保不超出图像右边界
end_y = min(y + region_size//2, image.shape[0] - 1) # 确保不超出图像下边界
# 提取区域
roi = image[start_y:end_y, start_x:end_x]
cv2.rectangle(img_rgb, (start_x, start_y), (end_x,end_y), (0, 0, 255),5)
avg=np.mean(roi)
logging.info(f"-----坐标{x,y}的平均值为{avg}")
ls.append(avg)
# 显示提取的区域
cv2.namedWindow(‘CC’, cv2.WINDOW_NORMAL)
cv2.imshow(‘CC’, img_rgb)
cv2.waitKey(0)
cv2.destroyAllWindows()
return ls