Skip to content

An application that maps colors in an image to corresponding availible colors, and makes a flat 3d model from each color

Notifications You must be signed in to change notification settings

TheStrgamer/Marching-Image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Marching Image

Convert images into one or more flat 3D models (STL files) using a modified marching squares–style algorithm.

This tool is primarily intended for logos and simple graphics, but can also be used with more complex images by mapping additional colors.

For most images the model will be pretty complex, so it is reccomended to preprocces the model in programs like blender. I reccomend the decimate modifier to reduce face cound without removing too many details.


Features

  • Image to flat 3D model (STL) conversion
  • Color-based shape extraction
  • Modified marching squares algorithm
  • Export single or multiple colors
  • Frontend GUI (TypeScript)
  • C++ backend (Docker-ready)

Intended use

  • Logos and icons
  • Flat relief-style 3D models
  • Rapid STL generation from images
  • 3D printable models
  • Geometry extraction experiments

Installation

git clone https://github.com/TheStrgamer/Marching-Image.git
cd Marching-Image

How to run with docker

For running both frontend and backend it is reccomended to use docker Make sure docker is running and use this command

docker compose up --build

How to run frontend

This application can be run with frontend only, to run it, use the following commands

cd frontend/colormap
npm install
npm run dev

How to run backend (Linux)

To run the backend on linux, you need the following requirements

  • CMake
  • g++
  • OpenCV (with PNG support)
  • Boost
  • Asio
  • nlohmann-json

can be installed with these commands if you use the apt package manager

sudo apt update
sudo apt install -y \
  cmake \
  g++ \
  make \
  libopencv-dev \
  libboost-all-dev \
  libasio-dev \
  nlohmann-json3-dev \
  git

To run the backend, use

cd backend
git clone https://github.com/CrowCpp/crow.git external/crow

mkdir -p build
cd build
cmake ..
make
./Colormap

How it works

The image is processed one color at a time. A binary matrix is created for each color:

1 → pixel matches the selected color

0 → pixel does not match

A marching squares–inspired lookup table determines vertex placement. Faces are generated to create flat 3D geometry

The result is exported as an STL file

For more information on standard marching squares, see: https://en.wikipedia.org/wiki/Marching_squares

Example with c++ logo

The logo mapped in the application

cpp_logo

The resulting model in blender

cpp_logo_model

Example with smaller shape

The shape mapped in the application

cpp_logo

The resulting model in blender

cpp_logo_model

Example of more complex image

For more complex images, more colors might be needed to make it look good Here is an example with an image of me.

cpp_logo

The resulting model in blender, with colors

cpp_logo_model

About

An application that maps colors in an image to corresponding availible colors, and makes a flat 3d model from each color

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published