用Python进行RU计算

一、说明

Relative Uniformity的计算步骤:

  1. RAW转Y进行计算
  2. 按照公式要求进行点位的计算
  3. 然后按照每个半径下值进行结果的判断

下图只是一个示例,

二、上代码

只上部分代码,请理解,有疑问可以沟通

import cv2

import numpy as np

import img_raw

for seq in range(ringNums):

r = (seq + 1.5) * ringSpacing

numSquares = 8 * (seq + 1)

for m in range(numSquares):

tempAngle = 2 * np.pi * m / numSquares

m_x = np.cos(tempAngle)

m_y = np.sin(tempAngle)

temppts_x = int(nImageWidth / 2 + r * m_x - blockSize // 2)

temppts_y = int(nImageHeight / 2 + r * m_y - blockSize // 2)

if 0 <= temppts_x < nImageWidth - blockSize and 0 <= temppts_y < nImageHeight - blockSize:

block = img[temppts_y:temppts_y + blockSize, temppts_x:temppts_x + blockSize]

rings_blockMeanY[seq].append(np.mean(block))

#= 绘制ROI(如果需要)

cv2.rectangle(rgb_image, (temppts_x, temppts_y), (temppts_x + blockSize, temppts_y + blockSize), (0,0,0), 5)

#将RAW10转换为RAW8,用于画图

raw_data_8bit = (img1 / 4).astype(np.uint8)

rgb_image = cv2.cvtColor(raw_data_8bit, cv2.COLOR_BAYER_BG2RGB)

cv2.namedWindow('RU', cv2.WINDOW_NORMAL)

cv2.imshow('RU', rgb_image)

cv2.waitKey(0)

cv2.destroyAllWindows()

相关推荐
AI探索者5 小时前
LangGraph StateGraph 实战:状态机聊天机器人构建指南
python
AI探索者5 小时前
LangGraph 入门:构建带记忆功能的天气查询 Agent
python
FishCoderh6 小时前
Python自动化办公实战:批量重命名文件,告别手动操作
python
躺平大鹅6 小时前
Python函数入门详解(定义+调用+参数)
python
曲幽7 小时前
我用FastAPI接ollama大模型,差点被asyncio整崩溃(附对话窗口实战)
python·fastapi·web·async·httpx·asyncio·ollama
两万五千个小时11 小时前
落地实现 Anthropic Multi-Agent Research System
人工智能·python·架构
哈里谢顿13 小时前
Python 高并发服务限流终极方案:从原理到生产落地(2026 实战指南)
python
用户8356290780511 天前
无需 Office:Python 批量转换 PPT 为图片
后端·python
markfeng81 天前
Python+Django+H5+MySQL项目搭建
python·django
GinoWi1 天前
Chapter 2 - Python中的变量和简单的数据类型
python