程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Example of Python digital image processing environment installation and configuration process

編輯:Python

Catalog

introduction

One 、 Installation package required

Two 、 Download and install anaconda

3、 ... and 、 A simple test

Four 、skimage Sub modules of the package

introduction

Digital image processing programming , Maybe most people will think of matlab, but matlab It also has its own shortcomings :

1、 Not open source , Expensive price

2、 The software capacity is large . commonly 3G above , The higher version even reaches 5G above .

3、 Only research , It's not easy to translate into software .

therefore , Here we use python This script language is used for digital image processing .

To use python, Must be installed first python, It's usually 2.7 Above version , No matter what windows System , still linux System , The installation is very simple .

To use python Carry out all kinds of development and scientific calculation , You also need to install the corresponding package . This sum matlab Very similar , It's just matlab It's called a toolbox (toolbox), and python It's called Ku or Bao . be based on python Script language development of digital image processing package , In fact, a lot of , such as PIL,Pillow, opencv, scikit-image etc. .

Compare these bags ,PIL and Pillow Only the most basic digital image processing , Limited function ;

opencv It's actually a c++ library , It just provides python Interface , The update speed is very slow . Up to now python It's all developed 3.5 edition , and opencv Only to python 2.7 edition ;

scikit-image Is based on scipy An image processing package , It takes pictures as numpy Array processing , Coincide with matlab equally , therefore , We finally choose scikit-image Digital image processing .

One 、 Installation package required

because scikit-image Is based on scipy To perform an operation , So the installation numpy and scipy Is "yes" . To display pictures , It also needs to be installed matplotlib package , combined , The bags needed 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

Compare , It takes a lot of work to install , In especial scipy, stay windows Basically, it cannot be installed .

But don't be afraid of , Let's choose an integrated installation environment , We recommend Anaconda, It integrates all the packages needed above , So we actually just need to install... From beginning to end Anaconda Just software , Don't pack anything else .

Two 、 Download and install anaconda

Come first https://www.anaconda.com/products/distribution download anaconda, The current version has python2.7 Version and python3.5 edition , Download the corresponding version 、 Corresponding to the anaconda, It's actually a sh Script files , about 280M about .

This series uses windows7+python3.5 For example , So we download the version shown in the red box below :

The name is :Anaconda3-2.4.1-Windows-x86_64.exe

It's an executable exe file , Download complete , Double click directly to install .

During installation , Suppose we install in D Packing list , Such as :

And choose both options , Write the installation path to the environment variable .

Then wait for the installation to complete .

After installation , open windows Command prompt for :

Input conda list You can query which libraries are installed now , frequently-used numpy, scipy Among them . If you have any packages not installed , Can run

conda install *** To install .(*** The name of the package you want )

If a package version is not the latest , function conda update *** You can update .

3、 ... and 、 A simple test

anaconda Comes with an editor spyder, We can use this editor to write code later .

spyder.exe In the installation directory Scripts Inside , As I am D:/Anaconda3/Scripts/spyder.exe, Double click to run . We can right-click to send to desktop shortcut , It will be more convenient to run later .

Let's write a simple program to test whether the installation is successful , This program is used to open a picture and display . First prepare a picture , Then open the spyder, Write the following code :

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

Will be one of the d:/dog.jpg Change the position of your picture

Then click the green triangle in the toolbar above to run , Finally, it shows

If the lower right corner “ Ipython console" Can display pictures , It indicates that our running environment has been successfully installed .

We can choose the one in the upper right corner ” variable explorer" To view picture information , Such as

We can save this program , Be careful python The suffix of the script file is py.

Four 、skimage Sub modules of the package

skimage The full name of the package is scikit-imageSciKit (toolkit forSciPy) , It's right scipy.ndimage It has been extended , Provides more image processing functions . It is from python language-written , from scipy Community development and maintenance .skimage The package consists of many submodules , Each sub module provides different functions . The main sub modules are listed below :

Submodule name Main 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 、 Sort filter 、 Automatic threshold, etc draw Operate on numpy Basic graphics drawing on array , Including lines 、 rectangular 、 Circle and text, etc transform Geometric transformation or other transformation , Such as rotation 、 Stretching and radon transformation, etc morphology Morphological operation , Such as open close operation 、 Skeleton extraction, etc exposure Picture intensity adjustment , Such as brightness adjustment 、 Histogram equalization, etc feature Feature detection and extraction measure Measurement of image attributes , Such as similarity or contour, etc segmentation Image segmentation restoration Image restoration util The generic function

When using some image processing operation functions , You need to import the corresponding sub module , If you need to import multiple sub modules , Separated by commas , Such as :

from skimage import io,data,color

That's all python Details of an example of the installation and configuration process of a digital image processing environment , More about python For information about the installation and configuration of digital image processing environment, please pay attention to other relevant articles on the software development network !



  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved