import numpy as np
import matplotlib.pyplot as plt
def read_raw(file_name, bits_num, row, col):
"""
从HiRawImage获取rawData
参数:
file_name (str): HiRawImage的路径
bits_num (int): 原始图像的位数
row (int): 原始图像的行数
col (int): 原始图像的列数
返回:
np.ndarray: 原始图像数据的矩阵
"""
# 格式精度
if bits_num == 8:
print('bits: 8')
dtype = np.uint8
elif bits_num in [10, 12, 16]:
print(f'bits: {bits_num}')
dtype = np.uint16
else:
raise ValueError("Unsupported bits_num. Only 8, 10, 12, 16 are supported.")
# 读取文件数据
with open(file_name, 'rb') as file:
data = np.fromfile(file, dtype=dtype, count=row * col)
# 处理数据
raw_data = data.reshape((col, row)).T
return raw_data
def show(org_data, cor_data, bits_num, mean_value):
"""
数据可视化
参数:
org_data (np.ndarray): 原始图像数据
cor_data (np.ndarray): 校正后的图像数据
bits_num (int): 位深度
ISP——BLC(Black Level Correction) (python重构),挑战一天一更新
于 2024-07-20 17:07:29 首次发布