Skip to content

brainwave-sh/mosaic

Repository files navigation

Mosaic Logo Mosaic Logo

An image processing library in Mojo

Language Badge GitHub License Badge CodeQL

OverviewInstallationExamplesDocumentationAcknowledgements

Overview

Description

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.

Principles

  1. Easy to use
  2. Type-safe, memory-safe
  3. Performant

Features

  • 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)

Installation

Prerequisites

  • Pixi (the Mojo environment and package manager)

Using the pixi cli

pixi add mosaic-mojo

After installation

The pixi.toml file should include the Modular community channel and the Mosaic dependency:

[project]
channels = ["https://repo.prefix.dev/modular-community"]

[dependencies]
mosaic-mojo = "*"

Examples

Prerequisites

Clone the repo and build Mosaic:

git clone git@github.com:brainwave-sh/mosaic.git
cd mosaic
pixi run build

Running an example

After building, run an example file from the examples/ directory like so:

cd examples
pixi run mojo load_image.mojo

Load image

Save image

Scale image

Resize image

Slice image

  • Slices the top half of an image
  • Image slices are mutable views into the underlying image data
  • Source: examples/slice_image.mojo

Rotate image

Flip image

Pad image

Convert type

Convert color space

Convert color space as type

Blur image

Detect edges

Unsharp mask

Picture in picture

Extract channel

Fourier transform

Inverse Fourier transform

High-pass filter

Documentation

Docs are available at brainwave.sh/mosaic

Acknowledgements

Mosaic makes use of vendored libraries to help with image codecs and FFTs, many thanks to:

Releases

No releases published

Contributors