Skip to content

Effects

effects

Image processing effects.

Functions:

XYZ_to_xyY

XYZ_to_xyY(image: ndarray, eps: float = 1e-08)

Converts from CIE XYZ to xyY.

add_canvas

add_canvas(
    image: ndarray,
    canvas_mode: CANVAS_MODES,
    canvas_scale: float = 1.0,
    canvas_ratio: float = 1.0,
)

Adds a background canvas to an image.

apply_grain

apply_grain(
    rgb: ndarray,
    stock: FilmSpectral,
    scale: float,
    grain_size_mm: float = 0.01,
    grain_sigma: float = 0.4,
    bw_grain: bool = False,
    adx: bool = True,
)

Applies a grain filter to an image.

blur_horizontal_masked

blur_horizontal_masked(image: ndarray, kernel: ndarray, blur_mask: ndarray)

Horizontal blur with a mask.

blur_vertical_masked

blur_vertical_masked(image: ndarray, kernel: ndarray, blur_mask: ndarray)

Vertical blur with a mask.

burn

burn(
    image: ndarray,
    negative_film: FilmSpectral,
    highlight_burn: float,
    burn_scale: float,
)

Simulates highlight burning, which is a darkroom printing technique to reduce the contrast and brightness of highlights. Similar to modern local tone-mapping techniques.

chroma_nr_filter

chroma_nr_filter(image: ndarray, size: int = 0)

A simple chroma noise reduction filter by blurring only color channels.

compute_kernel_from_function

compute_kernel_from_function(func, kernel_size_mm, pixel_size_mm)

Computes a convolution kernel from a mtf function.

crop_image

crop_image(rgb: ndarray, zoom=1, aspect=1.5, flip=False) -> ndarray

Crops rgb data to aspect ratio.

down_up_blur

down_up_blur(image: ndarray, scale: int = 50, func: Callable | None = None)

Blur by downsampling and then upsampling. Very fast on CPU compared to accurate blur filters.

exponential_blur_kernel

exponential_blur_kernel(size)

Compute an exponential blur kernel for halation.

film_sharpness

film_sharpness(
    rgb: ndarray,
    stock: FilmSpectral,
    scale: float,
    sharpening_strength,
    sharpening_sigma,
)

Apply the sharpness and micro-contrast of a film stock ot an image.

gaussian_blur_separable_masked

gaussian_blur_separable_masked(image, kernel, blur_channels)

image: (H, W, C) float32 kernel: 1D Gaussian kernel blur_channels: iterable of booleans, length C

gaussian_kernel_1d

gaussian_kernel_1d(size: int, sigma: float) -> ndarray

A fast 1D gaussian kernel.

halation

halation(
    rgb: ndarray,
    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,
) -> ndarray

A halation image processing effect.

lens_correction

lens_correction(
    rgb: ndarray, metadata: dict, cam: None | str, lens: None | str
) -> ndarray

Apply lens correction using lensfunpy.

mtf_curve

mtf_curve(logf, vals)

Turn mtf values into an interpolated function on log space.

mtf_kernel cached

mtf_kernel(
    stock: FilmSpectral,
    scale,
    sharpening_strength: float = 0.0,
    sharpening_sigma: float = 1.0,
)

Cache a mtf convolution kernel.

rotate

rotate(rgb: ndarray, degrees: float) -> ndarray

Rotate an image by a specified angle in degrees.

xyY_to_XYZ

xyY_to_XYZ(image: ndarray, eps: float = 1e-08)

Converts from CIE xyY to XYZ.