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, 可选, 默认 = ‘bilinear_npp’) –
用于推断任何给定像素的缺失颜色的算法。目前仅支持
bilinear_npp
。bilinear_npp
算法使用双线性插值来推断红色和蓝色值。对于绿色值,使用具有色度相关的双线性插值,如 NPP 文档中所述。
blue_position¶ (int 或 int 列表或 int 的 TensorList) –
彩色滤光片阵列/拜耳瓦片的布局。
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 列表,可选,默认 = [0]) –
输出大小提示,以每样本字节数为单位。
如果指定,则算子位于 GPU 或页锁定主机内存中的输出将被预先分配,以容纳此大小的样本批次。
preserve¶ (bool, 可选, 默认 = False) – 即使算子的输出未使用,也阻止从图中删除该算子。