For details about how to install Anaconda and python on windows, anacondapython
When it comes to digital image processing programming, most people may think of matlab, but matlab also has its own shortcomings:
1. Not open-source, expensive
2. Large software capacity. Generally, it is 3G or above, and the version is later than 5g.
3. You can only do research and it is not easy to convert it into software.
Therefore, we use the Python script language for digital image processing.
To use Python, you must first install python, which is generally version 2.7 or later. The installation is very simple in both windows and Linux systems.
To use python for various development and scientific computing, you also need to install the corresponding package. This is very similar to matlab, but matlab is called toolbox, while python is called library or package. There are many digital image processing packages developed based on the python script language, such as PIL, Pillow, OpenCV, and scikit-image.
Compared with these packages, PIL and Pillow only provide the most basic digital image processing and have limited functions. OpenCV is actually a c ++ library, but only provides python interfaces, and the update speed is very slow. Now python has developed to version 3.5, while opencv only supports python 2.7. scikit-image is an image processing package based on scipy, which processes images as numpy arrays, just like matlab, we finally chose scikit-image for digital image processing.
1. required installation packages
Because scikit-image is based on scipy, it is certain to install numpy and scipy. To display images, you also need to install the matplotlib package. In combination, the required packages include:
Python >= 2.6Numpy >= 1.6.1Cython >= 0.21Six >=1.4SciPy >=0.9Matplotlib >= 1.1.0NetworkX >= 1.8Pillow >= 1.7.8dask[array] >= 0.5.0
Compared, It is very troublesome to install, especially scipy, which is basically not installed on windows.
But don't worry, we just need to select an integrated installation environment. Here we recommend Anaconda, which integrates all the preceding packages, therefore, we only need to install the Anaconda software from start to end, and nothing else needs to be installed.
2. Download and install anaconda
First to the https://www.continuum.io/downloads to download anaconda, the current version of python2.7 and python3.5 versions, download the corresponding version, the corresponding system of anaconda, it is actually a sh script file, about 280M.
This series uses Windows 7 + python3.5 as an example. Therefore, we download the version in the red box:
Name: Anaconda3-2.4.1-Windows-x86_64.exe
Is an executable exe file. After the download is complete, you can simply double-click it to install it.
During installation, assume that we have installed it in the root directory of the d disk, for example:
Select both options and write the installation path to the environment variable.
Then wait until the installation is complete.
After the installation is complete, open the windows command prompt:
Enter the conda list to query which libraries are currently installed, including commonly used numpy and scipy. You can run
Conda install. (*** Indicates the name of the required package)
If a package version is not the latest, run conda update *** to update it.
Iii. Simple Test
Anaconda comes with an editor spyder. We can use this editor to write code later.
Put spyder.exe In the scripts directory under the installation directory. For example, if my file is D:/Anaconda3/scripts/spyder.exe, you can directly double-click it to run it. We can right-click the desktop shortcut to make it easier to run later.
We simply write a program to test whether the installation is successful. The program is used to open an image and display it. First, prepare an image, open spyder, and write the following code:
from skimage import ioimg=io.imread('d:/dog.jpg')io.imshow(img)
Change d:/dog.jpg to your image location.
Click the green triangle in the toolbar to run the task.
If an image is displayed on the "Ipython console" in the lower-right corner, the running environment is successfully installed.
You can select "variable explorer" in the upper right corner to view the image information, as shown in figure
We can save this program. Note that the suffix of the python script file is py.
Iv. submodules of the skimage package
The full name of the skimage package is scikit-image SciKit (toolkit for SciPy). It extends scipy. ndimage and provides more image processing functions. It is written in python and developed and maintained by the scipy community. The skimage package consists of many sub-modules. Each sub-module provides different functions. The list of main sub-modules is as follows:
Sub-module name |
Main functions |
Io |
Read, save, and display images or videos |
Data |
Provides some test images and sample data |
Color |
Color Space Transformation |
Filters |
Image Enhancement, edge detection, sorting filter, automatic threshold, etc. |
Draw |
Allows you to draw basic images on the numpy array, including lines, rectangles, circles, and texts. |
Transform |
Geometric or other transformations, such as rotation, stretching, and Laidong Transformation |
Morphology |
Morphological operations, such as open/closed operations and skeleton extraction |
Exposure |
Image intensity adjustment, such as brightness adjustment and histogram balancing |
Feature |
Feature Detection and Extraction |
Measure |
Measure image attributes, such as similarity or contour lines. |
Segmentation |
Image Segmentation |
Restoration |
Image Restoration |
Util |
Common functions |
When using image processing functions, You need to import the corresponding sub-modules. If you need to import multiple sub-modules, separate them with commas, for example:
from skimage import io,data,color
The above is a detailed tutorial on installing Anaconda and python on windows. I hope it will be helpful to you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!