Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - 10 Python image editing tool
10 Python image editing tool
These Python tools mentioned below provide simple and direct methods to edit images and manipulate the underlying data of images.

-Parul Pandi

Today's world is full of data, and image data is a very important part of it. But only by processing and analyzing, improving the image quality and extracting effective information can these image data be used.

Common image processing operations include displaying images and basic image operations, such as cropping, flipping and rotating; Image segmentation, classification and feature extraction; Image restoration; And image recognition and so on. As an increasingly popular scientific programming language, Python is the best choice for these image processing operations. At the same time, there are many excellent image processing tools in Python ecosystem that can be used for free.

The following will introduce 10 Python libraries that can be used for image processing tasks. These libraries provide simple and direct methods for editing images and viewing the underlying data of images.

Scikit-image is an open source Python tool combined with NumPy array, which implements algorithms and applications that can be used in research, education and industrial applications. Even for beginners who have just come into contact with Python ecosystem, this library is simple enough to use. At the same time, its code quality is also very high, because it was developed by an active volunteer community and passed peer review.

Scikit-image is well documented and contains a wealth of use cases.

You can use it by importing skimage, and most functions can be found in its sub-modules.

Image filtering:

Use the match_template () method to realize template matching:

You can see more related examples on the display page.

NumPy provides array support and is the core library of Python programming. The essence of an image is actually a standard NumPy array containing pixel data points, so you can edit the image from the pixel level through some bmaskic NumPy operations (such as slicing, masking, fancy indexing, etc.). ). Images stored through NumPy arrays can also be loaded through skimage and displayed using matplotlib.

NumPy's official document provides a complete code document and resource list.

Mask an image with NumPy:

Like NumPy, SciPy is the core scientific computing module of Python, and it can also be used for basic operation and processing of images. Especially the scipy.ndimage submodule in SciPy v 1. 1.0 provides functions running on n-dimensional NumPy arrays. SciPy also provides linear and nonlinear filtering, binary morphology, B-spline interpolation, object measurement and other functions.

The complete list of functions of scipy.ndimage can be found in the official document.

Use Gaussian filter to blur the image;

PIL (Python Imaging Library) is a free Python programming library, which supports opening, editing and saving image files in various formats. However, after 2009, PIL stopped issuing new versions. Fortunately, PIL also has a branch, Pillow, which is being actively developed. Its installation process is simpler than PIL, and it supports most mainstream operating systems as well as Python 3. Pillow contains basic image processing functions, including pixel operation, filtering with built-in convolution kernel, color space conversion and so on.

Pillow's official documentation provides an example of how to install Pillow and explains each module in its own code base.

Using the image filtering module in the pillow to realize image enhancement;

Open source computer vision library is one of the most widely used libraries in the field of computer vision, and OpenCV-Python is the Python API of OpenCV. OpenCV-Python runs very fast, thanks to its background code written in C/C++, and because it is encapsulated in Python, it is not difficult to call and deploy. These advantages make OpenCV-Python a good choice for computing-intensive computer vision applications.

It is best to read the document OpenCV2-Python-Guide before you start.

Using pyramid fusion in OpenCV-Python to fuse apples and oranges;

SimpleCV is an open source computer vision framework. It supports some high-performance computer vision libraries, including OpenCV, and does not need to understand concepts such as bit depth, file format and color space, so the learning curve of SimpleCV is much smoother than that of OpenCV, just as its slogan says, "Make computer vision simpler". The advantages of SimpleCV are:

The official documents are easy to understand and are accompanied by a large number of learning cases.

This document contains installation introduction, examples and some introductory tutorials for Mahotas.

Mahotas strives to realize functions with a small amount of code. For example, this game of finding Wally:

ITK (Insight Segmentation and Registration Toolkit) is an open source cross-platform toolkit, which provides common image analysis functions for developers, while SimpleITK is a simplified layer based on ITK, aiming at promoting the application of ITK in rapid prototyping design, education and interpretation language. SimpleITK, as an image analysis toolkit, also has a large number of components, which can support conventional functions such as filtering, image segmentation and image registration. Although SimpleITK is written in C++, it also supports most programming languages, including Python.

Jupyter notebook has many use cases to show the application of SimpleITK in education and scientific research. Through these use cases, we can see how SimpleITK uses Python and R to realize interactive image analysis.

Using Python+SimpleITK to realize the registration process of CT/MR images;

Pgmagick is a GraphicsMagick library encapsulated in Python. GraphicsMagick is generally regarded as the Swiss army knife in the field of image processing, because its powerful and efficient toolkit supports reading and writing up to 88 mainstream image files, including DPX, GIF, JPEG, JPEG-2000, PNG, PDF, PNM, TIFF and so on.

There are related installation instructions, dependency lists and detailed instructions in pgmagick's GitHub warehouse.

Image scaling:

Edge extraction:

Cairo is a two-dimensional graphics library for drawing vector diagrams, while Pycairo is a set of Python bindings for Cairo. The advantage of vector graphics is that it will not lose the clarity of the image in the process of resizing. You can use PyCairo to call the related commands of Cairo in Python.

Pycairo's GitHub repository provides detailed instructions for installation and use, as well as a brief introduction to Pycairo's getting started guide.

Draw line segments, basic graphics and radial gradients with Pycairo:

These are some useful image processing libraries in Python. Whether you have heard of them or not, it is worth trying and getting to know them.

Through:/article/19/3/python-image-manipulation-tools

Author: Parul Pandey Title: lujun9972 Translator: HankChow Proofreading: wxy