Skip to content

GPU Processor

gpu_processor

The main GPU processing implementation.

Classes:

  • GpuProcessor

    The main GPU processing implementation.

  • GpuTexture

    Wrapper for GPU texture to make usage easier.

GpuProcessor

GpuProcessor(cameras, lenses)

The main GPU processing implementation.

Methods:

extract_image_data_cpu

extract_image_data_cpu(
    src,
    cam=None,
    lens=None,
    lens_correction=True,
    frame_width=36,
    frame_height=24,
    rotation=0.0,
    zoom=1.0,
    rotate_times=0,
    flip=False,
    resolution=None,
    half_size=True,
    cache=True,
    chroma_nr=0,
    max_scale=400.0,
    canvas_mode="No",
    canvas_scale=1.0,
    canvas_ratio=1.0,
    **kwargs,
)

PHASE 1: Pure CPU Workload. Modifies NO instance states.

generate_histogram

generate_histogram(source_tex)

Executes the complete multi-pass pipeline chain to draw the output histogram.

load_density_curve

load_density_curve(
    negative_film: FilmSpectral,
    push_pull: float | int,
    color_masking: float | None = None,
)

Create 1D LUT for the films HD-curve.

load_grain

load_grain(
    negative_film: FilmSpectral,
    scale: float,
    grain_size_mm: float = 0.01,
    grain_sigma: float = 0.4,
    bw_grain: bool = False,
)

Set up grain parameters and kernel and upload them to the GPU.

load_halation_kernel

load_halation_kernel(
    scale: float,
    halation_size: float = 1.0,
    halation_red_factor: float = 1.0,
    halation_green_factor: float = 0.4,
    halation_blue_factor: float = 0.0,
    halation_intensity: float = 1.0,
    bw: bool = False,
)

Create halation kernel and upload it to the GPU.

load_highlight_burn

load_highlight_burn(
    negative_film: FilmSpectral, highlight_burn: float, burn_scale: float
)

Create highlight burn parameters and upload them to the GPU.

load_image_texture

load_image_texture(
    src: str,
    cam: str | None,
    lens: str | None,
    lens_correction: bool,
    frame_width: int | float,
    frame_height: int | float,
    rotation: float,
    zoom: float,
    rotate_times: int,
    flip: bool,
    resolution: None | tuple[int, int] = None,
    half_size: bool = True,
    cache: bool = True,
    chroma_nr: int = 0,
    max_scale: float | None = None,
    canvas_mode: CANVAS_MODES = "No",
    canvas_scale: float = 1.0,
    canvas_ratio: float = 1.0,
)

Load the image, perform pre-processing and upload to GPU.

load_input_lut

load_input_lut(
    negative_film: FilmSpectral,
    exp_kelvin: float | int,
    tint: float | int,
    exp_comp: float | int,
)

Create the 2D input LUT and upload it to the GPU.

load_mtf_kernel

load_mtf_kernel(
    negative_film: FilmSpectral,
    scale: float,
    sharpening_strength: float,
    sharpening_sigma: float,
)

Create MTF-kernel and upload to GPU.

load_output_lut

load_output_lut(
    negative_film: FilmSpectral,
    print_film: FilmSpectral | None = None,
    red_light: float = 0.0,
    green_light: float = 0.0,
    blue_light: float = 0.0,
    projector_kelvin: int = 6500,
    shadow_comp: float = 0.0,
    sat_adjust: float = 1.0,
    gamma_func: GAMMA_KEYS = "sRGB",
    inversion_gamma: float = 4.0,
    idealized_curve: bool = False,
    inversion: bool = False,
    white_balance: bool = False,
    white_clip: bool = False,
    icc_transform=None,
    color_masking: float | None = None,
)

Create the 3D output LUT.

load_raw_image

load_raw_image(src, cam=None, lens=None, half_size: bool = True)

Load an image and apply lens correction.

load_raw_image_cached cached

load_raw_image_cached(src, cam=None, lens=None, half_size: bool = True)

Load images and cache previous requests.

prepare_gpu_textures

prepare_gpu_textures(cpu_payload)

PHASE 2: GPU Stateful Allocation & Upload.

process

process(
    src: str,
    negative_film: FilmSpectral,
    grain_size: float,
    grain_sigma: float,
    dst_texture=None,
    histogram_texture=None,
    lens_correction: bool = True,
    print_film: FilmSpectral | None = None,
    exp_comp: float = 0.0,
    red_light: float = 0.0,
    green_light: float = 0.0,
    blue_light: float = 0.0,
    projector_kelvin: int = 6500,
    shadow_comp: float = 0.0,
    sat_adjust: float = 1.0,
    gamma_func: GAMMA_KEYS = "sRGB",
    exp_kelvin: int = 6500,
    tint: float = 0.0,
    inversion_gamma: float = 4.0,
    idealized_curve: bool = False,
    inversion: bool = False,
    push_pull: float = 0.0,
    white_balance: bool = False,
    white_clip: bool = False,
    icc_transform=None,
    resolution: None | tuple[int, int] = None,
    frame_width: int | float = 36,
    frame_height: int | float = 24,
    rotation: float = 0.0,
    zoom: float = 1.0,
    rotate_times: int = 0,
    flip: bool = False,
    cam: str | None = None,
    lens: str | None = None,
    canvas_mode: CANVAS_MODES = "No",
    canvas_scale: float = 1.0,
    canvas_ratio: float = 1.0,
    halation_intensity: float = 1.0,
    halation: bool = True,
    halation_size: float = 1.0,
    halation_green_factor: float = 0.4,
    sharpness: bool = True,
    sharpening_strength: float = 0.0,
    sharpening_sigma: float = 1.0,
    chroma_nr: int = 0,
    grain: int = 2,
    highlight_burn: float = 0.0,
    burn_scale: float = 50.0,
    half_size: bool = True,
    cache: bool = True,
    color_masking: float | None = None,
    **kwargs,
)

Main function to load and process an image.

process_preloaded

process_preloaded(
    cpu_payload: dict,
    negative_film: FilmSpectral,
    grain_size: float,
    grain_sigma: float,
    dst_texture=None,
    histogram_texture=None,
    print_film: FilmSpectral | None = None,
    exp_comp: float = 0.0,
    red_light: float = 0.0,
    green_light: float = 0.0,
    blue_light: float = 0.0,
    projector_kelvin: int = 6500,
    shadow_comp: float = 0.0,
    sat_adjust: float = 1.0,
    gamma_func: GAMMA_KEYS = "sRGB",
    exp_kelvin: int = 6500,
    tint: float = 0.0,
    inversion_gamma: float = 4.0,
    idealized_curve: bool = False,
    inversion: bool = False,
    push_pull: float = 0.0,
    white_balance: bool = False,
    white_clip: bool = False,
    icc_transform=None,
    frame_width: int | float = 36,
    frame_height: int | float = 24,
    halation_intensity: float = 1.0,
    halation: bool = True,
    halation_size: float = 1.0,
    halation_green_factor: float = 0.4,
    sharpness: bool = True,
    sharpening_strength: float = 0.0,
    sharpening_sigma: float = 1.0,
    grain: int = 2,
    highlight_burn: float = 0.0,
    burn_scale: float = 50.0,
    color_masking: float | None = None,
    **_,
)

Main function to process an image using pre-loaded CPU data.

GpuTexture

GpuTexture(device, size, format=rgba16float)

Wrapper for GPU texture to make usage easier.

Methods:

  • upload

    Upload RGBA float texture.

upload

upload(queue, data: ndarray)

Upload RGBA float texture.