Overview • Installation • Examples • Documentation • Acknowledgements
Mosaic is a cross-platform (macOS and linux) image processing library for prototyping and production.
By transparently leveraging hardware acceleration, Mosaic is built specifically for heterogenous compute: CPUs, GPUs, and more in the future.
It can unify image processing workflows into one language that runs on any hardware.
- Easy to use
- Type-safe, memory-safe
- Performant
- Image representation
- Image file encoding and decoding
- Data type specification (at compile time)
- Color space specification (at compile time)
- Image transformation
- Filtering
- Geometric transforms
- Fourier transforms
- Visualization (currently only macOS)
- Native image rendering
- Hardware acceleration
- Parallelization and SIMD on CPUs
- GPU acceleration when available (coming soon)
- Pixi (the Mojo environment and package manager)
pixi add mosaic-mojoThe pixi.toml file should include the Modular community channel and the Mosaic dependency:
[project]
channels = ["https://repo.prefix.dev/modular-community"]
[dependencies]
mosaic-mojo = "*"Clone the repo and build Mosaic:
git clone git@github.com:brainwave-sh/mosaic.git
cd mosaic
pixi run buildAfter building, run an example file from the examples/ directory like so:
cd examples
pixi run mojo load_image.mojo- Loads an image file and displays it in the visualizer
- Source: examples/load_image.mojo
- Saves an image to a file
- Source: examples/save_image.mojo
- Scales an image to half size using bilinear interpolation
- Source: examples/scale_image.mojo
- Resizes an image to double its width, stretching it in the process
- Source: examples/resize_image.mojo
- Slices the top half of an image
- Image slices are mutable views into the underlying image data
- Source: examples/slice_image.mojo
- Rotates an image by 90° clockwise
- Source: examples/rotate_image.mojo
- Flips an image vertically
- Source: examples/flip_image.mojo
- Pads an image with zeros
- Source: examples/pad_image.mojo
- Starting with a
uint8image, explicitly converts it tofloat64 - Source: examples/convert_type.mojo
- Converts an RGB image to greyscale
- Source: examples/convert_color_space.mojo
- Converts a
float64RGB image touint8greyscale in one method - Source: examples/convert_as_type.mojo
- Blurs an image using the built-in Gaussian kernel and reflected border handling
- Source: examples/blur_image.mojo
- Detects edges in an image by smoothing and applying a custom Laplacian kernel
- Source: examples/detect_edges.mojo
- Applies unsharp masking and image stacking to visualize the results
- Source: examples/unsharp_mask.mojo
- Captures a sub-rect of an image and copies it to the top left corner
- Source: examples/picture_in_picture.mojo
- Extracts the green channel of an RGB image
- Source: examples/extract_channel.mojo
- Calculates the spectrum of an image using the Fourier transform
- Source: examples/fourier_transform.mojo
- Recreates an image from a previously calculated spectrum
- Source: examples/inverse_fourier_transform.mojo
- Applies a high-pass filter by discarding low frequencies in the spectrum
- Source: examples/high_pass_filter.mojo
Docs are available at brainwave.sh/mosaic
Mosaic makes use of vendored libraries to help with image codecs and FFTs, many thanks to:

















