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:
Python >= 2.6Numpy >= 1.6.1Cython >= 0.21Six >=1.4scipy >=0.9matplotlib >= 1.1.0NetworkX >= 1.8Pillow >= 1.7.8dask[array] >= 0.5.0
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 expands the scipy.ndimage and provides 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 below:
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
The above is a small part of the introduction of Windows on the installation of Anaconda and Python tutorial detailed, I hope that we have some help, if you have any questions please give me a message, small series will promptly reply to everyone. Thank you very much for the support of the Scripting House website!
Articles you may be interested in:
- Open source package and environment Management System Anaconda installation and use
- Anaconda Multi-Environment Multi-version Python configuration operation method
- Installation and simple use of anaconda under Windows
- How to use and configure the Anaconda of Python learning
Detailed tutorial on installing Anaconda and Python on Windows