Gaussian

Overview

The Gaussian Blur sample demonstrates how to apply Gaussian smoothing to images using CV-CUDA.

Usage

Basic Usage

Apply Gaussian blur with default parameters:

python3 gaussian.py -i input.jpg

The output will be saved as cvcuda/.cache/cat_blurred.jpg with a 9×9 kernel and sigma=1.5.

Custom Output Path

Specify the output file:

python3 gaussian.py -i image.jpg -o blurred.jpg

Command-Line Arguments

Argument

Short Form

Default

Description

--input

-i

tabby_tiger_cat.jpg

Input image file path

--output

-o

cvcuda/.cache/cat_blurred.jpg

Output image file path

Implementation

Complete Code

The entire sample is remarkably concise:

args: argparse.Namespace = parse_image_args("cat_blurred.jpg")
# docs_tag: begin_read_image
input_image: cvcuda.Tensor = read_image(args.input)
# docs_tag: end_read_image

# docs_tag: begin_gaussian_blur
# 1. Perform a gaussian blur on the image
output_image: cvcuda.Tensor = cvcuda.gaussian(
    input_image,
    (9, 9),
    (1.5, 1.5),
)
write_image(output_image, args.output)
# docs_tag: end_gaussian_blur

That’s it! Just three key steps:

  1. Load the image from disk

  2. Apply Gaussian blur

  3. Save the result

Expected Output

The output shows the image with Gaussian blur applied, smoothing the image while preserving overall structure:

../../_images/tabby_tiger_cat.jpg

Original Input Image

../../_images/cat_blurred.jpg

Output: Gaussian Blurred

CV-CUDA Operators Used

Operator

Purpose

cvcuda.gaussian()

Apply Gaussian blur with specified kernel and sigma

Common Utilities Used

See Also