Python Image Handling Libraries

Introduction
Image Processing is the process of analyzing and controlling a digital image first and foremost aimed at improving its quality or for takeout some information from it which could then be put to some use. Common tasks in image processing co…


This content originally appeared on DEV Community and was authored by Mansoor Ahmed

Introduction
Image Processing is the process of analyzing and controlling a digital image first and foremost aimed at improving its quality or for takeout some information from it which could then be put to some use. Common tasks in image processing comprise;

Showing images
Basic manipulations similar to cropping, flipping, rotating etc.
Image Splitting up
Grouping and feature drawing out
Image rebuilding and Image recognition
Python develops a suitable choice for such Image processing tasks. This is because of its emergent reputation as a scientific programming language and the allowed ease of use of various State of the Art Image Processing tools in its ecosystem.

Description
Best image processing and manipulation techniques may be carried out successfully using two libraries:

Python Imaging Library (PIL)
Open Source Computer Vision (OpenCV)
Python Imaging Library (PIL)
The Python Imaging Library (PIL) delivers overall image handling and many valuable simple image operations like resizing, cropping, rotating, color change and abundant more. This is one of the essential libraries for image manipulation in Python. There’s a keenly-developed fork of PIL called Pillow. This is an informal to install, runs on all most important operating systems, and supports Python 3. The library covers simple image processing functionality, together with point operations, filtering by a set of integral convolution kernels, and color space changes.

How to install Pillow?
We’ll have to install Pillow’s prerequisites before installing Pillow. Find out the instructions for platform in the Pillow installation instructions.

Next, it’s open:

$ pip install Pillow
Example

from PIL import Image, ImageFilter

Read image

im = Image.open( 'image.jpg' )

Display image

im.show()

Applying a filter to the image

im_sharp = im.filter( ImageFilter.SHARPEN )

Saving the filtered image to a new file

im_sharp.save( 'image_sharpened.jpg', 'JPEG' )

Splitting the image into its respective bands, i.e. Red, Green,

and Blue for RGB

r,g,b = im_sharp.split()

Viewing EXIF data embedded in image

exif_data = im._getexif()

exif_data
Open Source Computer Vision (OpenCV)
Open Source Computer Vision, usually known as OpenCV, is a more innovative image handling and processing software than PIL. It has been applied in a number of languages and widely used libraries for computer vision applications. OpenCV-Python is not only fast in the meantime the background contains of code written in C or C++ .This is similarly informal to code and deploy because of the Python wrapper in foreground. This brands it an unlimited select to perform computationally concentrated computer vision programs.

How to install Open Source Computer Vision?
By using the cv2 and NumPy modules in Python, we can implement image processing. The installation instructions for OpenCV would guide us over and done with configuring the project for ourselves.

NumPy may be downloaded from the Python Package Index(PyPI):

$ pip install numpy
Example

import cv2

Read Image

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

Display Image

cv2.imshow('image',img)

cv2.waitKey(0)

cv2.destroyAllWindows()

Applying Grayscale filter to image

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

Saving filtered image to new file

cv2.imwrite('graytest.jpg',gray)
Python Image Handling Libraries
Some Other Image Manipulation Tools
Scikit-image
Scikit-image is an open source Python package. It do work with NumPy arrays. It implements algorithms and utilities to be used in research, education, and industry applications. It’s a reasonably simple and easy library, even for those that are new Python’s ecosystem. The code is high-quality, peer-reviewed, and written by a lively community of volunteers.

NumPy
NumPy is one among the core libraries in Python programming. It gives support for arrays. A picture is actually a typical NumPy array containing pixels of knowledge points. Consequently, by using basic NumPy operations, similar slicing, masking, and fancy indexing, we’ll modify the pixel values of a picture. The image is often loaded using skimage and displayed using Matplotlib.

SciPy
SciPy is a different of Python’s core scientific modules. It can be used for simple image handling and processing tasks. Particularly, the submodule scipy.ndimage (in SciPy v1.1.0) delivers functions operating on n-dimensional NumPy arrays. The package now comprises;

Functions for linear and non-linear filtering,
B-spline interpolation,
Binary morphology
Object measurements.
SimpleCV
SimpleCV is one more open source framework for building computer vision applications. It deals access to many high-powered computer vision libraries like OpenCV, but without having to understand about bit depths, file formats, color spaces, etc. A few points in favor of SimpleCV are:

Even beginning programmers may write machine vision tests
Video files, images, Cameras, and video streams are all interoperable
Mahotas
Mahotas is one more computer vision and image processing library for Python. It covers old-style image processing functions like filtering and morphological operations, similarly for example more modern computer vision functions for feature computation. That is including interest point detection and native descriptors. The interface is in Python that is acceptable for fast development. However the algorithms are implemented in C++ and tuned for speed. Mahotas’ library is speedy with minimalistic code and even minimum dependencies.
For more details visit:https://www.technologiesinindustry4.com/2021/07/python-image-handling-libraries.html


This content originally appeared on DEV Community and was authored by Mansoor Ahmed


Print Share Comment Cite Upload Translate Updates
APA

Mansoor Ahmed | Sciencx (2021-08-01T18:39:56+00:00) Python Image Handling Libraries. Retrieved from https://www.scien.cx/2021/08/01/python-image-handling-libraries/

MLA
" » Python Image Handling Libraries." Mansoor Ahmed | Sciencx - Sunday August 1, 2021, https://www.scien.cx/2021/08/01/python-image-handling-libraries/
HARVARD
Mansoor Ahmed | Sciencx Sunday August 1, 2021 » Python Image Handling Libraries., viewed ,<https://www.scien.cx/2021/08/01/python-image-handling-libraries/>
VANCOUVER
Mansoor Ahmed | Sciencx - » Python Image Handling Libraries. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/08/01/python-image-handling-libraries/
CHICAGO
" » Python Image Handling Libraries." Mansoor Ahmed | Sciencx - Accessed . https://www.scien.cx/2021/08/01/python-image-handling-libraries/
IEEE
" » Python Image Handling Libraries." Mansoor Ahmed | Sciencx [Online]. Available: https://www.scien.cx/2021/08/01/python-image-handling-libraries/. [Accessed: ]
rf:citation
» Python Image Handling Libraries | Mansoor Ahmed | Sciencx | https://www.scien.cx/2021/08/01/python-image-handling-libraries/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.