Initial----Python Digital image processing-: Environment Installation and configuration

Source: Internet
Author: User
Tags python script

When it comes to digital image processing programming, perhaps most people will think of MATLAB, but MATLAB has its own shortcomings:

1, not open source, the price is expensive

2, the software capacity is large. Generally more than 3G, high version even up to 5G or more.

3, can only do research, not easily converted into software.

Therefore, we use the Python scripting language here to do digital image processing.

To use Python, you must first install Python, which is typically 2.7 or more, and is easy to install, whether it's on a Windows system or a Linux system.

To use Python for various development and scientific calculations, you will also need to install the corresponding package. This is very similar to MATLAB, but Matlab is called the Toolbox, and Python is called a library or a package. Based on the Python scripting language development of Digital Image processing package, in fact, many, such as Pil,pillow, OpenCV, Scikit-image and so on.

Compared to these packages, PIL and pillow only provide the most basic digital image processing, the function is limited, OPENCV is actually a C + + library, just provides the Python interface, the update speed is very slow. Until now Python has grown to version 3.5, while OPENCV only supports Python version 2.7; Scikit-image is a scipy-based image processing package that handles images as a numpy array, just like Matlab, so We finally chose scikit-image for digital image processing.

One, the required installation package

Because Scikit-image is based on scipy, installing NumPy and scipy is sure. To display the picture, you also need to install the Matplotlib package, combined, the required packages are:

Comparison, installation is very cumbersome, especially scipy, on Windows Basic installation is not on.

But don't be afraid, we choose an integrated installation environment on the line, it is recommended Anaconda, it put the above required packages are integrated together, so we actually only need to install Anaconda software on the line, and nothing else to pretend.

Second, download and install Anaconda

First to https://www.continuum.io/downloads download Anaconda, now the version has python2.7 version and python3.5 version, download the corresponding version, the corresponding system anaconda, It is actually a sh script file, about 280M or so.

This series takes windows7+python3.5 as an example, so we download the version in the Red box:

Name is: Anaconda3-2.4.1-windows-x86_64.exe

is an executable exe file, the download is complete, the direct double-click can be installed.

At the time of installation, suppose we install the D packing directory, such as:

and select all two options to write the installation path to the environment variable.

Then wait for the installation to complete.

When the installation is complete, open a command prompt for Windows:

Input Conda list can query now which libraries are installed, commonly used NumPy, scipy is listed among them. If you still have what package is not installed on, you can run

Conda Install * * * for installation. (* * * for the name of the package required)

If a package version is not up-to-date, you can update it by running Conda update.

Three, simple test

Anaconda comes with an editor Spyder that we can use later to write code.

Spyder.exe placed in the installation directory Scripts inside, as mine is D:/anaconda3/scripts/spyder.exe, directly double-click to run. We can right-click to send to the desktop shortcut, it is more convenient to run later.

We simply write a program to test the success of the installation, which is used to open a picture and display it. First prepare a picture, then open the Spyder, and write the following code:

From skimage import ioimg=io.imread (' d:/dog.jpg ') io.imshow (IMG)

Change the d:/dog.jpg to your picture location

Then click on the green triangle in the toolbar above to run, and finally show



If the "Ipython console" in the lower right corner shows a picture, the installation of our operating environment is successful.

We can select "Variable Explorer" in the upper right corner to view picture information, such as

We can save this program, note that the Python script file has a suffix called py.

Iv. Sub-modules of the Skimage package

The full name of the

Skimage package is Scikit-image scikit (Toolkit for scipy), which is scipy.ndimage is extended to provide more image processing capabilities. It was written by the Python language and developed and maintained by the SCIPY community. The Skimage package consists of many sub-modules, each of which provides different functions. The main sub-modules are listed as follows:

Sub-module name Main implementation functions
Io Read, save, and display pictures or videos
Data Provide some test pictures and sample data
Color Color Space Transformation
Filters Image enhancement, edge detection, sorting filters, automatic thresholds, etc.
Draw Operates on basic drawing on numpy arrays, including lines, rectangles, circles, and text
Transform Geometric transformations or other transformations, such as rotation, stretching, and radon transformations
Morphology Morphological operations, such as opening and closing operations, skeleton extraction, etc.
Exposure Image intensity adjustment, such as brightness adjustment, histogram equalization, etc.
Feature Feature detection and extraction, etc.
Measure Measurement of image properties, such as similarity or contours
Segmentation Image segmentation
Restoration Image recovery
Util General functions

When using some image manipulation functions, you need to import the corresponding sub-modules, if you need to import multiple sub-modules, separated by commas, such as:

From Skimage import Io,data,color

Initial----Python Digital image processing-: Environment Installation and configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.