Skip to main content

A library with efficient implementations for various image processing methods.

Project description

filterkit

This library contains optimized implementations for various methods/algorithms in the following domains of image processing:

  • Convolutions (linear time/constant time methods for any kernel)
  • Dithering (assorted constant time dithering methods for any kernel)
  • Smoothing (sliding histogram/rank based filters and constant time median filtering)
  • Blending (image compositing and assorted blend modes)
  • Quantization (includes various techniques)
  • Transforms (implementations for basic geometric transforms)
  • Miscellaneous (collection of random, interesting filters)

Additionally, the library provides some useful helper methods when working images/matrices in filterkit.tools.

Installation

pip install filterkit 

Please note that this will install pillow, numba, and numpy as well as any additional packages needed by these. As numba needs a specific version of numpy for itself, it will attempt to remove any existing version of numpy before it installs the version of numpy it is compatible with. For this reason, it is highly recommended to only install filterkit in a virtual environment, so as not to interfere with any global installations of these libraries.

Importing

For image processing methods,

import filterkit.core

For accessing additional helper functions,

import filterkit.tools

Example Usage

from filterkit.core import convolution as conv
from filterkit.core import dithering as dither
from filterkit.tools import kernel_gen
from PIL import Image

image = Image.open("image.png")

# Convolution
result = conv.apply_convolution(image, kernel_gen.gaussian_kernel(11), separable=True)
result.show()

# Dithering
result = dither.apply_dithering(image, style=1, kernel=((0, 0, 0, 0, 0), (0, 0, 0, 0, 0), (0, 0, 0, 0.25, 0.125), 
                                                     (0.0625, 0.125, 0.25, 0.125, 0.0625), (0, 0, 0, 0, 0)), 
                                              palette=[(8, 24, 32), (52, 104, 86), (136, 192, 112), (224, 248, 208)])
result.show()

Requirements

Notes

filterkit uses:

  • Pillow for opening/saving images
  • Numpy for handling image matrices
  • Numba for fast/parallelized array indexing/traversal operations

When using a core method directly, the image is expeected to be in numpy's ndarray format, as well as any other matrices/palettes/kernels passed alongside.

Each module that can be accessed from filterkit.core comes with its own 'apply_function' method, which can be used to directly apply the selected function from the module to a given image after specifying the function's id in the corresponding style or method parameter and any other parameters, without needing to ensure the parameters are in the correct format or have been preprocessed correctly. This is because majority of the core functions use Numba for speeding up processing, and the function parameters must be of a specific type and structure/shape.


As of now, filterkit is a work in progress, and further refinements/documentation will be produced in the future.

Author: Farhan Zia (mfarhan@mun.ca)
Code is currently hosted at https://github.com/mfarhanz/filterkit

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

If you're not sure about the file name format, learn more about wheel file names.

filterkit-0.1.3-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file filterkit-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: filterkit-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 41.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.6

File hashes

Hashes for filterkit-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7b77955f182cc0f7fd4a9128b568bcbc494942a268d9daf35aca5723ff324f93
MD5 c0f1555b97fe99b76a49456603561382
BLAKE2b-256 6fe902899d8e37879472e265f2155ad45b999302bd71fc8feec26d9643f84559

See more details on using hashes here.

Supported by

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