Skip to main content

colormask is a library to mask image based on colors.

Project description

colormask

PyPI PyPI PyPI PyPI Telegram

colormask is a Python app to mask image based on based on colors in Python.

Build Coverage
Master Travis (.com) master Codecov master
Development Travis (.com) development Codecov development

Input with green square RGBA mode PNG:

Output, masked green to red:

Requirements

  • Python 3.5 and onwards
  • Pillow

How to Use It

At first, you need to define a source and target color:

from colormask.color import RGBColor

source = RGBColor(0, 255, 0)  # green
target = RGBColor(255, 0, 0)  # red

Then, you need to create a mask based on these source and target colors:

from colormask.color import Mask

mask = Mask(source, target)

# pack all masks into a set
masks = {mask}

Now, you can mask the green to red, by using mask_image function:

from colormask import mask_image

# get an instance of an Image
# assuming you have one called "image"
mask_image(image, masks)
image.show()  # see image

Project details


Download files

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

Files for colormask, version 0.1.0a1
Filename, size File type Python version Upload date Hashes
Filename, size colormask-0.1.0a1.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page