raw图G通道

import numpy as np
import matplotlib.pyplot as plt


def extract_g_channel_info(raw_path, width, height, bit_depth=12, bayer_pattern='RGGB'):
    """
    从拜耳阵列RAW图中提取G通道信息
    :return: 原始数组、G通道掩码、最大亮度值
    """
    # 读取RAW数据并解析为数组
    dtype = np.uint16
    with open(raw_path, 'rb') as f:
        raw_data = f.read()
    raw_array = np.frombuffer(raw_data, dtype=dtype).reshape(height, width)

    # 修正位深(去除无效高位)
    max_value = (1 << bit_depth) - 1
    raw_array = np.clip(raw_array, 0, max_value)

    # 创建G通道掩码(True表示该位置是G通道)
    g_mask = np.zeros((height, width), dtype=bool)

    # 根据拜耳阵列模式标记G通道位置
    if bayer_pattern == 'RGGB':
        # G通道位置:(偶数行, 奇数列)(奇数行, 偶数列)
        g_mask[::2, 1::2] = True  # 偶数行,奇数列
        g_mask[1::2, ::2] = True  # 奇数行,偶数列
    elif bayer_pattern == 'BGGR':
        # G通道位置:
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值