nvidia.dali.fn.experimental.debayer#
- nvidia.dali.fn.experimental.debayer(
- __input,
- /,
- *,
- blue_position,
- algorithm='bilinear_npp',
- bytes_per_sample_hint=[0],
- preserve=False,
- seed=-1,
- device=None,
- name=None,
- Performs image demosaicing/debayering. - Converts single-channel image to RGB using specified color filter array. - The supported input types are - uint8_tand- uint16_t. The input images must be 2D tensors (- HW) or 3D tensors (- HWC) where the number of channels is 1. The operator supports sequence of images/video-like inputs (layout- FHW).- For example, the following snippet presents debayering of batch of image sequences: - 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 - This operator allows sequence inputs. - Supported backends
- ‘gpu’ 
 
 - Parameters:
- __input (TensorList ('HW', 'HWC', 'FHW', 'FHWC')) – Input to the operator. 
- Keyword Arguments:
- blue_position (int or list of int or TensorList of int) – - The layout of color filter array/bayer tile. - A position of the blue value in the 2x2 bayer tile. The supported values correspond to the following OpenCV bayer layouts: - (0, 0)-- BG/- BGGR
- (0, 1)-- GB/- GBRG
- (1, 0)-- GR/- GRBG
- (1, 1)-- RG/- RGGB
 - The argument follows OpenCV’s convention of referring to a 2x2 tile that starts in the second row and column of the sensors’ matrix. - For example, the - (0, 0)/- BG/- BGGRcorresponds to the following matrix of sensors:- R - G - R - G - R - G - B - G - B - G - R - G - R - G - R - G - B - G - B - G - Supports - per-frameinputs.
- algorithm (str, optional, default = ‘bilinear_npp’) – - The algorithm to be used when inferring missing colours for any given pixel. Currently only - bilinear_nppis supported.- The - bilinear_nppalgorithm uses bilinear interpolation to infer red and blue values. For green values a bilinear interpolation with chroma correlation is used as explained in NPP documentation.
 
- bytes_per_sample_hint (int or list of int, optional, default = [0]) – - Output size hint, in bytes per sample. - If specified, the operator’s outputs residing in GPU or page-locked host memory will be preallocated to accommodate a batch of samples of this size. 
- preserve (bool, optional, default = False) – Prevents the operator from being removed from the graph even if its outputs are not used. 
- seed (int, optional, default = -1) – - Random seed. - If not provided, it will be populated based on the global seed of the pipeline.