Skip to main content

Color Image with Few Colors from an image with Labeled Objects

Project description

Brief Description

fewColors allows to create a color image from an image with labeled objects so that adjacent objects have different colors while using the fewest colors possible.

image

result

Image with labeled objects (background=0, objects=1, 2…).

Color image with the fewest colors possible.

Installation

The fewColors project is published on the Python Package Index (PyPI) at: https://pypi.org/project/few-colors. It requires version 3.8, or newer, of the interpreter. It should be installable from Python distribution platforms or Integrated Development Environments (IDEs). Otherwise, it can be installed from a command-line console:

  • For all users, after acquiring administrative rights:
    • First installation: pip install few-colors

    • Installation update: pip install --upgrade few-colors

  • For the current user (no administrative rights required):
    • First installation: pip install --user few-colors

    • Installation update: pip install --user --upgrade few-colors

Documentation

After installation, the few-colors and few-colors-gui commands should be available from a command-line console.

The usage help for few-colors is obtained with few-colors --help (see output below). The accepted file formats for the input labeled image are the image formats read by imageio, and the NPY and NPZ Numpy formats. (See note below for the reason to use Numpy formats.) A labeled image or Numpy array must have the background labeled with zero, with the objects labeled consecutively from 1. The accepted image formats for the output color image are the image formats written by imageio.

Usage Help:

usage: few-colors [-h] file file

Convert a labeled image or a labeled Numpy array into a minimally colored image

positional arguments:
  file        Input labeled image or Numpy array and Output minimally colored image (pass input first)

optional arguments:
  -h, --help  show this help message and exit

The command few-colors-gui can be launched with or without an argument as an initial image. If no argument is passed, a file browser opens to select an image. The color version is immediately displayed. It is then possible to change the image, change the object colors (individually or collectively; Press the ? button for help), and save the color image. There is no close button. The window can simply be closed using the appropriate window manager button or keyboard shortcut.

Thanks

The project is developed with PyCharm Community.

The development relies on several open-source packages (see install_requires in setup.py).

The code is formatted by Black, The Uncompromising Code Formatter.

The imports are ordered by isortyour imports, so you don’t have to.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

few_colors-2021.2-py3-none-any.whl (11.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page