nvidia.dali.fn.experimental.debayer#
- nvidia.dali.fn.experimental.debayer(__input, /, *, algorithm='bilinear_npp', blue_position, bytes_per_sample_hint=[0], preserve=False, device=None, name=None)#
执行图像去马赛克/去拜耳操作。
使用指定的颜色滤镜阵列将单通道图像转换为 RGB 图像。
支持的输入类型为
uint8_t
和uint16_t
。输入图像必须是 2D 张量 (HW
) 或 3D 张量 (HWC
),其中通道数为 1。该操作符支持图像序列/类视频输入(布局FHW
)。例如,以下代码段展示了图像序列批次的去拜耳操作
def bayered_sequence(sample_info): # some actual source of video inputs with corresponding pattern # as opencv-style string video, bayer_pattern = get_sequence(sample_info) if bayer_pattern == "bggr": blue_position = [0, 0] elif bayer_pattern == "gbrg": blue_position = [0, 1] elif bayer_pattern == "grbg": blue_position = [1, 0] else: assert bayer_pattern == "rggb" blue_position = [1, 1] return video, np.array(blue_position, dtype=np.int32) @pipeline_def def debayer_pipeline(): bayered_sequences, blue_positions = fn.external_source( source=bayered_sequence, batch=False, num_outputs=2, layout=["FHW", None]) # note the "FHW" layout, for plain images it would be "HW" debayered_sequences = fn.experimental.debayer( bayered_sequences.gpu(), blue_position=blue_positions) return debayered_sequences
此操作符允许序列输入。
- 支持的后端
‘gpu’
- 参数:
__input¶ (TensorList ('HW', 'HWC', 'FHW', 'FHWC')) – 操作符的输入。
- 关键字参数:
algorithm¶ (str, optional, default = ‘bilinear_npp’) –
用于推断任何给定像素的缺失颜色的算法。目前仅支持
bilinear_npp
。bilinear_npp
算法使用双线性插值来推断红色和蓝色值。对于绿色值,使用具有色度相关的双线性插值,如 NPP 文档 中所述。
blue_position¶ (int 或 int 列表或 TensorList of int) –
颜色滤镜阵列/拜耳瓦片的布局。
2x2 拜耳瓦片中蓝色值的位置。支持的值对应于以下 OpenCV 拜耳布局
(0, 0)
-BG
/BGGR
(0, 1)
-GB
/GBRG
(1, 0)
-GR
/GRBG
(1, 1)
-RG
/RGGB
该参数遵循 OpenCV 的约定,指的是从传感器矩阵的第二行和第二列开始的 2x2 瓦片。
例如,
(0, 0)
/BG
/BGGR
对应于以下传感器矩阵R
G
R
G
R
G
B
G
B
G
R
G
R
G
R
G
B
G
B
G
支持
per-frame
输入。bytes_per_sample_hint¶ (int 或 int 列表, optional, default = [0]) –
每个样本的输出大小提示(以字节为单位)。
如果指定,则驻留在 GPU 或页锁定主机内存中的操作符输出将被预先分配,以适应此大小的样本批次。
preserve¶ (bool, optional, default = False) – 阻止操作符从图中移除,即使其输出未使用。