当前位置:网站首页>Numpy basic learning
Numpy basic learning
2022-07-27 05:57:00 【Pie star's favorite spongebob】
numpy Bottom use c Language , Calculate around an array , Default 64 Bit floating point
np.array()

np.zeros()

np.ones()

np.shape()

np.arange()

np.random.rand()

Convert data type
1. Creation time
b=np.zeros((2,3),dtype=np.int32)

np.int8/16/32/64
np.uint8/16/32/64
np.float32/64
bool
str
2. Created
a=a.astype(int)
Basic operation
1. arithmetic
Same size :
a=np.array([1,2,3,4])
b=np.array([5,4,3,2])

Different sizes :
a=np.array([[1],
[2]])
b=np.array([5,4])

hold a The array consists of
| 1 |
| 2 |
Expanded into
| 1 | 1 |
| 2 | 2 |
2. Other mathematical operations
square root , logarithmic , Index of operation , Sine, etc
np.sqrt(a)
np.log(a)
np.pow(a,3)
np.sin(a)
Filter elements
b[(b>3)&(b%2==0)]

a=np.array([[1,2],[3,4]])
a[1,:]

Typical applications - The image processing
1. Read the picture
from PIL import Image
im=Image.open('F:\\ desktop \\flower.jpg')
im.show
2. Convert images to arrays
im=np.array(im)
im.shape

3. cut picture
im1=np.array(Image.open('F:\\ desktop \\flower.jpg'))
im2=np.array(Image.open('F:\\ desktop \\yellow.jpg'))
im1_cropped=im1[:600,:1000,:]
im2_cropped=im2[:600,:1000,:]
Image.fromarray(im1_cropped).show()
Image.fromarray(im2_cropped).show()

4. Mix two pictures
im_blend=im1_cropped*0.2+im2_cropped*0.5
im_blend=im_blend.astype(np.uint8)
Image.fromarray(im_blend).show()

5. Rollover Image
im1_fliepped=im1[::-1,:,:]
Image.fromarray(im1_fliepped).show()

边栏推荐
- Seektiger will launch STI fusion mining function to obtain Oka pass
- Cap principle
- GBASE 8C——SQL参考6 sql语法(3)
- 14.实例-多分类问题
- 基于深度神经网络的社交媒体用户级心理压力检测
- 常用adb命令汇总 性能优化
- PHP的CI框架学习
- 17.动量与学习率的衰减
- The NFT market pattern has not changed. Can okaleido set off a new round of waves?
- Day 8.Developing Simplified Chinese Psychological Linguistic Analysis Dictionary for Microblog
猜你喜欢

5.索引和切片

数字图像处理第五章——图像复原与重建

Sealem Finance - a new decentralized financial platform based on Web3

7.合并与分割

Day14. 用可解释机器学习方法鉴别肠结核和克罗恩病

Count the quantity in parallel after MySQL grouping

Seektiger's okaleido has a big move. Will the STI of ecological pass break out?

How can seektiger go against the cold air in the market?

Read and understand the advantages of the LAAS scheme of elephant swap

新冠时空分析——Global evidence of expressed sentiment alterations during the COVID-19 pandemic
随机推荐
Getaverse, a distant bridge to Web3
Day 4.Social Data Sentiment Analysis: Detection of Adolescent Depression Signals
Gbase 8C - SQL reference 6 SQL syntax (11)
Public opinion & spatio-temporal analysis of infectious diseases literature reading notes
Gbase 8C - SQL reference 6 SQL syntax (7)
Day 8.Developing Simplified Chinese Psychological Linguistic Analysis Dictionary for Microblog
Emoji表情符号用于文本情感分析-Improving sentiment analysis accuracy with emoji embedding
Day 17.The role of news sentiment in oil futures returns and volatility forecasting
3.分类问题---手写数字识别初体验
mysql优化sql相关(持续补充)
Global evidence of expressed sentimental alterations during the covid-19 pandemics
GBASE 8C——SQL参考6 sql语法(6)
Okaleido launched the fusion mining mode, which is the only way for Oka to verify the current output
MySQL快速比较数据库表数据
Day 15. Deep learning radiomics can predict axillary lymphnode status in early-stage breast cancer
Day 7. Towards Preemptive Detection of Depression and Anxiety in Twitter
Day 6.重大医疗伤害事件网络舆情能量传播过程分析*———以“魏则西事件”为例
Day 17.The role of news sentiment in oil futures returns and volatility forecasting
Minio8.x version setting policy bucket policy
Performance optimization of common ADB commands
