Skip to main content

A small package to make funky video, images, and real-time video

Project description

FunkyCam

This is a simple package with one class, Funk, that allows you to recolor images by "luminance" of each pixel and also extract and thicken edges. The final product is a cartoon-like version of the original image or video. Like this:

Image

and this:

Alt Text

To install this package just use:

pip install funkycam

Examples are given in the "examples" folder to demonstrate how to use this package with a webcam, image files, and video files. But, to use this class all you need to do is:

import cv2
from funkycam.funkycam import Funk

img = cv2.imread('example.jpg')

funk = Funk()
funky_img = funk.funkify(img)

Note: The code expects images that are read using cv2 which means they are in BGR format. If you read with other packages, images are often in RGB format. It may still work fine, but the calculations will be incorrect. Thus, the channels will need to be flipped. This can be accomplished on an np array with array slicing:

img_flipped = img[:,:,::-1] # flips third dim

Customizing the Output

To select colors, there are 3 options:

  1. Use the seaborn color_palettes or matplotlib colormaps (https://matplotlib.org/stable/tutorials/colors/colormaps.html).
  2. Manually input RGB colors in a list of lists. Resolution is 8 bits: 0-255 each color.
  3. Specify "random_colors=True".

If you can't find colors you like, I recommend randomly generating colors and recording the colors that look good. The colors are printed every time it runs, but you can also access them from the Funk object with "funk.colors".

You can also specify the block size and blur value for finding edges, and blur value when finding colors. Increasing the block size seems to increase the thickness of the edges. Increasing blur values will reduce detail in the edges and colors, i.e. fewer edges and larger splotches of colors. These values depend a lot on the resolution of the image or video. NOTE: The block size and blur values must be odd numbers.

Other Notes

The luminance calculation is not real luminance, it is simplified so that it can recolor video in "real-time" (depends on image quality and number of colors chosen).

Turns out this method is a little bit like "cel-shading", a commonly used shader algorithm.

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

funkycam-0.0.6-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file funkycam-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: funkycam-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for funkycam-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 203b3d72c7b4e5b30ac95467d8d64e576668e77f92330af140368c3ccf3fa6ca
MD5 c9f4666adc4f188d44dc4fe983582943
BLAKE2b-256 ad85bc3ad5214ee5f3086a2ad0d50d24bb18292eb97aa5a24816ab0b18d898a4

See more details on using hashes here.

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