Overview
Provides fundamental image operations including creation, destruction, sampling, cropping, and distance transforms. Supports multiple image formats with different data types.Types
StitchPoint
Represents a 2D point in image space.Horizontal coordinate
Vertical coordinate
StitchRect
Represents a rectangular region in image space.Left edge x-coordinate
Top edge y-coordinate
Rectangle width in pixels
Rectangle height in pixels
ImageType
Enumeration of image data types.Functions
create_image
Loads an image from a file.Path to the image file (typically JPEG)
Loaded image structure with allocated data buffer
Example
create_empty_image
Creates an empty image with allocated buffer.Image width in pixels
Image height in pixels
Number of color channels (typically 1 for grayscale, 3 for RGB)
Newly allocated empty image (unsigned char data)
create_empty_image_s
Creates an empty short integer image.Image width in pixels
Image height in pixels
Number of color channels
Newly allocated empty image (short data)
create_empty_image_f
Creates an empty floating-point image.Image width in pixels
Image height in pixels
Number of color channels
Newly allocated empty image (float data)
destroy_image
Frees memory allocated for an unsigned char image.Pointer to image to destroy
Always call this to prevent memory leaks after you’re done with an Image.
destroy_image_s
Frees memory allocated for a short integer image.Pointer to short image to destroy
destroy_image_f
Frees memory allocated for a floating-point image.Pointer to float image to destroy
upsample
Upsamples an unsigned char image by a given factor.Pointer to source image
Scale factor (e.g., 2.0 doubles dimensions)
Newly allocated upsampled image
The returned image has new dimensions: width × upsample_factor and height × upsample_factor.
upsample_image_s
Upsamples a short integer image.Pointer to source short image
Scale factor
Newly allocated upsampled short image
upsample_image_f
Upsamples a floating-point image.Pointer to source float image
Scale factor
Newly allocated upsampled float image
downsample
Downsamples an unsigned char image by factor of 2.Pointer to source image
Newly allocated downsampled image (half dimensions)
Uses Gaussian smoothing before downsampling to prevent aliasing.
downsample_s
Downsamples a short integer image by factor of 2.Pointer to source short image
Newly allocated downsampled short image
downsample_f
Downsamples a floating-point image by factor of 2.Pointer to source float image
Newly allocated downsampled float image
crop_image
Crops an image in-place by removing borders.Pointer to image to crop (modified in-place)
Number of pixels to remove from top
Number of pixels to remove from bottom
Number of pixels to remove from left
Number of pixels to remove from right
This modifies the image structure in-place. The original data buffer is freed and replaced.
Example
distance_transform
Applies distance transform to a mask image.Pointer to binary mask image (modified in-place)
Converts binary mask to distance field where each pixel’s value represents distance to nearest zero pixel. Useful for creating smooth blending weights.
Example
create_image_mask
Creates a horizontal gradient mask for blending.Mask width in pixels
Mask height in pixels
Gradient transition range as fraction of width (0.0-1.0)
Value for left side (0 or 1)
Value for right side (0 or 1)
Grayscale gradient mask image
Creates a horizontal gradient from left to right. The
range parameter controls the width of the transition zone.Example
save_image
Saves an image to disk as JPEG.Pointer to image to save
Output file path
1 on success, 0 on failure
Example
image_size
Calculates total size in bytes of an unsigned char image.Pointer to image
Total bytes (width × height × channels)
image_size_s
Calculates total size in bytes of a short image.Pointer to short image
Total bytes (width × height × channels × sizeof(short))
image_size_f
Calculates total size in bytes of a float image.Pointer to float image
Total bytes (width × height × channels × sizeof(float))