A minimal and fast image library for Python and C++.
Lycon is a small subset of optimized image operations derived from OpenCV.
Current set of features include:
- Reading and writing JPEG and PNG images
- Fast SIMD optimized image resizing
- Zero-copy interop with NumPy whenever possible
Tested on:
- Linux (Ubuntu 14.04) with Python
2.7.6and3.5.2. - macOS (Sierra, 10.12) with Python
2.7.11and3.5.1.
pip install lycon
Native extension dependencies:
- CMake 2.8 or newer
- C++ toolchain
- LibJPEG
- LibPNG
Single-line command for installing all dependencies:
sudo apt-get install cmake build-essential libjpeg-dev libpng-dev
When working within an Anaconda Python distribution, it is recommended to use the latest cmake version (3.6 or newer). Older versions can lead to a mismatch between the libpng and libjpeg headers used to build Lycon (usually the system headers), and the linked library (which may be preempted by the Anaconda-scoped version). To install the latest cmake version:
conda install cmake
import lycon
# Load an image as a numpy array
img = lycon.load('mittens.jpg')
# Resize the image using bicubic interpolation
resized = lycon.resize(img, width=256, height=512, interpolation=lycon.Interpolation.CUBIC)
# Crop the image (like any regular numpy array)
cropped = resized[:100, :200]
# Save the image
lycon.save('cropped-mittens.png', cropped)Compared to other image processing libraries (OpenCV, pillow, scikit-image), Lycon offers a very limited set of operations. Intended usages include data loaders for deep learning, mass image resizing, etc.
- Drastically smaller (at the cost of drastically fewer features)
- Python module installable via
pip - Images use the more common
RGBordering (vs OpenCV'sBGR)
However, if you already have OpenCV installed, Lycon's advantages are minimal.
- Faster
- First-class NumPy support
- Full support for floating point images
- Drastically faster
- The table below lists execution time (in seconds), averaged across 10 runs
- The multiplier next to the time is the relative slowdown compared to Lycon
- Blank cells indicate that the operation is not supported by the library
- All operations performed on a 16k (15360 x 8640) RGB image
- Tests performed on Ubuntu 14.04 running on an Intel Core i7 (Skylake)
- OpenCV
3.2+ (master: a85b4b5), Pillow4.0.0, skimage0.12.3, Python2.7.3 - OpenCV can potentially achieve better performance with GPU implementations and proprietary libraries like Intel IPP
- All code derived from the OpenCV project is licensed under the 3-clause BSD License.
- All Lycon-specific modifications are licensed under the MIT license.
See LICENSE for further details.
