All Projects → letmaik → Lensfunpy

letmaik / Lensfunpy

Licence: mit
📷 Lens distortion correction for Python, a wrapper for lensfun

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Lensfunpy

Ldbm Image Background Remover
Remove image background automatically
Stars: ✭ 72 (-13.25%)
Mutual labels:  image-processing
Imgflo
Node-based image processing with GEGL and Flowhub
Stars: ✭ 75 (-9.64%)
Mutual labels:  image-processing
Phimpme Ios
Phimp.me - Photo Image Editor and Sharing App. Phimp.me is a Photo App for iOS that aims to replace proprietary photo applications. It offers features such as taking photos, adding filters, editing images and uploading them to social networks.
Stars: ✭ 79 (-4.82%)
Mutual labels:  image-processing
Coursera Specializations
Solutions to assignments of Coursera Specializations - Deep learning, Machine learning, Algorithms & Data Structures, Image Processing and Python For Everybody
Stars: ✭ 72 (-13.25%)
Mutual labels:  image-processing
Dcv
Computer Vision Library for D Programming Language
Stars: ✭ 74 (-10.84%)
Mutual labels:  image-processing
Uploadcare Php
PHP API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
Stars: ✭ 77 (-7.23%)
Mutual labels:  image-processing
Gobrot
Mandelbrot image renderer in Go
Stars: ✭ 70 (-15.66%)
Mutual labels:  image-processing
Data processor
数据algorithm & 分析算法
Stars: ✭ 83 (+0%)
Mutual labels:  image-processing
Simple Deflicker
A lightweight and easy to use tool for deflickering timelapse image sequences.
Stars: ✭ 75 (-9.64%)
Mutual labels:  image-processing
Oiio
Reading, writing, and processing images in a wide variety of file formats, using a format-agnostic API, aimed at VFX applications.
Stars: ✭ 1,216 (+1365.06%)
Mutual labels:  image-processing
Simpleimage
A PHP class that makes working with images as simple as possible.
Stars: ✭ 1,184 (+1326.51%)
Mutual labels:  image-processing
Pixlab
PixLab Resources & Sample Set
Stars: ✭ 74 (-10.84%)
Mutual labels:  image-processing
Mcwnnm Iccv2017
Multi-channel Weighted Nuclear Norm Minimization for Real Color Image Denoising, ICCV 2017.
Stars: ✭ 78 (-6.02%)
Mutual labels:  image-processing
Imageviewer
HDR, PFM, DDS, KTX, EXR, PNG, JPG, BMP image viewer and manipulator
Stars: ✭ 71 (-14.46%)
Mutual labels:  image-processing
Raster
An image processing library for Rust
Stars: ✭ 79 (-4.82%)
Mutual labels:  image-processing
Skrop
Image transformation service using libvips, based on Skipper.
Stars: ✭ 71 (-14.46%)
Mutual labels:  image-processing
Pyscenedetect
🎥 Python and OpenCV-based scene cut/transition detection program & library.
Stars: ✭ 1,203 (+1349.4%)
Mutual labels:  image-processing
X Ray Classification
X-ray Images (Chest images) analysis and anomaly detection using Transfer learning with inception v2
Stars: ✭ 83 (+0%)
Mutual labels:  image-processing
Litiv
C++ implementation pool for computer vision R&D projects.
Stars: ✭ 82 (-1.2%)
Mutual labels:  image-processing
Dipdemo
All the algorithms in the book "Digital Image Processing and Machine Vision" C++ code; test under VS2013, use MFC as the interactive interface to realize the operation of the input image, covering all the basic image processing algorithms, it is worth learning!
Stars: ✭ 78 (-6.02%)
Mutual labels:  image-processing

lensfunpy

lensfunpy is an easy-to-use Python wrapper for the lensfun_ library.

API Documentation <https://letmaik.github.io/lensfunpy/api/>_

Sample code

How to find cameras and lenses:

.. code-block:: python

import lensfunpy

cam_maker = 'NIKON CORPORATION'
cam_model = 'NIKON D3S'
lens_maker = 'Nikon'
lens_model = 'Nikkor 28mm f/2.8D AF'

db = lensfunpy.Database()
cam = db.find_cameras(cam_maker, cam_model)[0]
lens = db.find_lenses(cam, lens_maker, lens_model)[0]

print(cam)
# Camera(Maker: NIKON CORPORATION; Model: NIKON D3S; Variant: ; 
#        Mount: Nikon F AF; Crop Factor: 1.0; Score: 0)

print(lens)
# Lens(Maker: Nikon; Model: Nikkor 28mm f/2.8D AF; Type: RECTILINEAR;
#      Focal: 28.0-28.0; Aperture: 2.79999995232-2.79999995232; 
#      Crop factor: 1.0; Score: 110)    

How to correct lens distortion:

.. code-block:: python

import cv2 # OpenCV library

focal_length = 28.0
aperture = 1.4
distance = 10
image_path = '/path/to/image.tiff'
undistorted_image_path = '/path/to/image_undist.tiff'

im = cv2.imread(image_path)
height, width = im.shape[0], im.shape[1]

mod = lensfunpy.Modifier(lens, cam.crop_factor, width, height)
mod.initialize(focal_length, aperture, distance)

undist_coords = mod.apply_geometry_distortion()
im_undistorted = cv2.remap(im, undist_coords, None, cv2.INTER_LANCZOS4)
cv2.imwrite(undistorted_image_path, im_undistorted)

It is also possible to apply the correction via SciPy <http://www.scipy.org>_ instead of OpenCV. The lensfunpy.util <https://letmaik.github.io/lensfunpy/api/lensfunpy.util.html>_ module contains convenience functions for RGB images which handle both OpenCV and SciPy.

How to correct lens vignetting:

.. code-block:: python

import lensfunpy
import imageio

db = lensfun.Database()
cam = db.find_cameras('NIKON CORPORATION', 'NIKON D3S')[0]
lens = db.find_lenses(cam, 'Nikon', 'Nikkor AF 20mm f/2.8D')[0]

img = imageio.imread('/path/to/image.tiff')

focal_length = 20
aperture = 4
distance = 10
width = img.shape[1]
height = img.shape[0]

mod = lensfun.Modifier(lens, cam.crop_factor, width, height)
mod.initialize(focal_length, aperture, distance)

did_apply = mod.apply_color_modification(img)
if did_apply:
    imageio.imwrite('corrected.tiff', img)
else:
    print('vignetting not corrected, calibration data missing?')

Installation

Binary wheels for Linux, macOS, and Windows are provided for Python 3.5 - 3.8. These can be installed with a simple pip install lensfunpy. Currently, Linux and macOS wheels are only available as 64 bit versions.

Installation from source on Linux/macOS

If you have the need to use a specific lensfun version or you can't use the provided binary wheels then follow the steps in this section to build lensfunpy from source.

First, install the lensfun_ library on your system.

On Ubuntu, you can get (an outdated) version with:

.. code-block:: sh

sudo apt-get install liblensfun-dev

Or install the latest developer version from the Git repository:

.. code-block:: sh

git clone https://github.com/lensfun/lensfun
cd lensfun
cmake .
sudo make install

After that, install lensfunpy using:

.. code-block:: sh

git clone https://github.com/letmaik/lensfunpy
cd lensfunpy
pip install numpy cython
pip install .

On Linux, if you get the error "ImportError: liblensfun.so.0: cannot open shared object file: No such file or directory" when trying to use lensfunpy, then do the following:

.. code-block:: sh

echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/99local.conf
sudo ldconfig

The lensfun library is installed in /usr/local/lib when compiled from source, and apparently this folder is not searched for libraries by default in some Linux distributions. Note that on some systems the installation path may be slightly different, such as /usr/local/lib/x86_64-linux-gnu or /usr/local/lib64.

NumPy Dependency

lensfunpy depends on NumPy. The minimum supported NumPy version depends on your Python version:

========== ========= Python numpy


3.5 >= 1.9 3.6 >= 1.11 3.7 >= 1.14 3.8 >= 1.17 ========== =========

.. _lensfun: https://lensfun.github.io/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].