当前位置:网站首页>Scientific computing toolkit SciPy image processing
Scientific computing toolkit SciPy image processing
2022-07-24 21:06:00 【Hua Weiyun】
Reading guide
scipy It also provides many methods about image processing , Mainly packaged in ndimage In bag , This article mainly introduces the use of some image processing methods
Image filtering
- Get photo
from scipy import misc,ndimagefrom matplotlib import pyplot as plt# Get a picture from the website img = misc.ascent()# Displays a grayscale image plt.gray()# display picture plt.imshow(f)plt.show()
- wave filtering
wave filteringIt is usually used for image denoising ,scipy Many filtering algorithms are also provided in
# Gauss filtering ,sigma Set the standard deviation of Gaussian kernel gauss_f_img = ndimage.gaussian_filter(img,sigma=3)# Maximum filtering max_f_img = ndimage.maximum_filter(img,size=20)# median filtering median_f_img = ndimage.median_filter(img,size=20)# Minimum filtering min_f_img = ndimage.minimum_filter(img,size=20)# Percentile filtering percentile_f_img = ndimage.percentile_filter(img,percentile=20,size=20)# Set the display of the picture listimg_list = [img,gauss_f_img,max_f_img,median_f_img,min_f_img,percentile_f_img]title_list = ["origin","guassian filter","maximum filter","median filter","minimum filter","percentile filter"]for i in range(len(img_list)): plt.subplot(2,3,i+1) # Set the title of the display picture plt.title(title_list[i]) # display picture plt.imshow(img_list[i]) # Turn off the display of the coordinate axis plt.axis("off")plt.show()
Image interpolation
Image interpolation is also widely used in image processing , for example : Perspective transformation 、 Affine transformation 、 translation 、 The zoom 、 rotate You can see it when you wait ,scipy Several functions are also provided for image interpolation , Let's take a look at
On the principle of image affine transformation , You can refer to my article Understand affine transformation
- Affine transformation
# Define the translation matrix of an image M = np.array([[1,0,10],[0,1,30]])# Affine transformation affine_img = ndimage.affine_transform(img,M)plt.imshow(affine_img)plt.show()
- Image rotation
# Rotated image #reshape Set whether to display all images ,True Show all ,False The image will be cropped rotate_img = ndimage.rotate(img,45,reshape=False)plt.imshow(rotate_img)plt.show()
- Image zooming
# Reduce the image to the original 1/2zoom_img = ndimage.zoom(img,0.5)plt.imshow(zoom_img)plt.show()
- Geometric interpolation
adoptgeometric_transformWe can realize geometric interpolation , You only need to define a function of image position transformation , As defined belowshift_funcFunction to move the image to the lower left corner 1 Pixel , The cross-border position uses... By default 0 Fill in
a = np.arange(0,12).reshape((4,3))def shift_func(output_coords): # Define the interpolation function return (output_coords[0] - 1,output_coords[1] - 1)# The pixel values of the coordinates are transformed according to the coordinates of the data t_a = ndimage.geometric_transform(a,shift_func)"""[[ 0 1 2] [ 3 4 5] [ 6 7 8] [ 9 10 11]][[0 0 0] [0 0 1] [0 3 4] [0 6 7]]"""边栏推荐
- Is it safe for Hengtai securities to open an account?
- Baidu interview question - judge whether a positive integer is to the power of K of 2
- Fluoronisin peptide nucleic acid oligomer complex | regular active group alkyne, SH thiol alkynyl modified peptide nucleic acid
- C WinForm actual operation XML code, including the demonstration of creating, saving, querying and deleting forms
- How to test WebService interface
- [sciter]: window communication
- C local functions and yield statements
- Lua environment configuration
- [JVM] selection of garbage collector
- Leetcode 1928. minimum cost of reaching the destination within the specified time
猜你喜欢

Smarter! Airiot accelerates the upgrading of energy conservation and emission reduction in the coal industry

Appium element positioning - App automated testing

Fluoronisin peptide nucleic acid oligomer complex | regular active group alkyne, SH thiol alkynyl modified peptide nucleic acid
![[record of question brushing] 16. The sum of the nearest three numbers](/img/b9/a78b72650e94c75ccbe22af1f43857.png)
[record of question brushing] 16. The sum of the nearest three numbers

90% of people don't know the most underestimated function of postman!
![[feature transformation] feature transformation is to ensure small information loss but high-quality prediction results.](/img/ad/6f5d97caa3f5163197ba435276a719.png)
[feature transformation] feature transformation is to ensure small information loss but high-quality prediction results.

ma.glasnost.orika. MappingException:No converter registered for conversion from Date to LocalDateTime

Summary of yarn capacity scheduler

class file has wrong version 55.0, should be 52.0
![[msp430g2553] graphical development notes (1) configuration environment](/img/42/479c96d1e7f6747f893d1a0b65be3f.png)
[msp430g2553] graphical development notes (1) configuration environment
随机推荐
Docker builds redis and clusters
Detailed OSPF configuration of layer 3 switch / router [Huawei ENSP experiment]
92. Recursive implementation of exponential enumeration
Strong reference, weak reference, soft reference, virtual reference
PHP page Jump mode
Vscode connected to the remote server cannot format the code / document (resolved)
Node installation using NVM succeeded, but NPM installation failed (error while downloading, TLS handshake timeout)
Preview and save pictures using uni app
[advanced data processing technology] data filtering, advanced data filling, initial and advanced data transformation
[feature construction] construction method of features
How to choose securities companies that support flush? Is it safe to open an account on your mobile phone
MySQL docker installation master-slave deployment
Easy to use office network optimization tool onedns
[feature selection] several methods of feature selection
API data interface of A-share transaction data
Drive subsystem development
One bite of Stream(7)
Synthesis route of ALA PNA alanine modified PNA peptide nucleic acid | AC ala PNA
Shenzhen Merchants Securities account opening? Is it safe to open a mobile account?
Acwing 94. recursive implementation of permutation enumeration