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:
and this:
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:
- Use the seaborn color_palettes or matplotlib colormaps (https://matplotlib.org/stable/tutorials/colors/colormaps.html).
- Manually input RGB colors in a list of lists. Resolution is 8 bits: 0-255 each color.
- 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 line size, blur value for finding edges, and blur value when finding colors. Generally, increasing blur values will reduce detail in the edges and colors, i.e. fewer edges and larger splotches of colors. NOTE: The line 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file funkycam-0.0.5.tar.gz
.
File metadata
- Download URL: funkycam-0.0.5.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b21e99443f5ae794530b2b694295f22e4e5b68f0e42eef396bcae26def087cf2 |
|
MD5 | eba73b4ae5b2ebed7e1138ebea1841da |
|
BLAKE2b-256 | c278e29127cd8cce3b6b231cb8f522a002074cd5a69bf6121643dc6a9fcd59e8 |
File details
Details for the file funkycam-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: funkycam-0.0.5-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e372bb53568bdb08727b707ccb7cb080283fd9aefe17f49b2e838e430976def |
|
MD5 | 3727ad502c5f9aa9afedbc5a25defab7 |
|
BLAKE2b-256 | aaeb331636e0cf8c9a9eaab3e1ce99f0a542f26a648cbe788e6d5d20982230c8 |