当前位置:网站首页>编程记录——图片旋转函数scipy.ndimage.rotate()的简单使用和效果观察
编程记录——图片旋转函数scipy.ndimage.rotate()的简单使用和效果观察
2022-04-23 05:44:00 【umbrellalalalala】
一、矩阵上的效果
言简意赅地介绍下这个函数的使用方法:
import numpy as np
from scipy import ndimage
c = np.zeros([10, 10]).astype(int)
for i in range(10):
for j in range(10):
c[i][j] = 10 * i + j
d = ndimage.rotate(c, 60, reshape=False)
print(c)
print(d)
输出结果:
[[ 0 1 2 3 4 5 6 7 8 9]
[10 11 12 13 14 15 16 17 18 19]
[20 21 22 23 24 25 26 27 28 29]
[30 31 32 33 34 35 36 37 38 39]
[40 41 42 43 44 45 46 47 48 49]
[50 51 52 53 54 55 56 57 58 59]
[60 61 62 63 64 65 66 67 68 69]
[70 71 72 73 74 75 76 77 78 79]
[80 81 82 83 84 85 86 87 88 89]
[90 91 92 93 94 95 96 97 98 99]]
[[ 0 0 7 17 27 36 0 0 0 0]
[ 0 0 11 22 30 40 49 58 0 0]
[ 0 6 16 25 35 44 53 62 71 80]
[ 0 10 21 29 39 48 57 66 75 84]
[ 5 16 24 34 43 52 61 70 79 89]
[10 20 29 38 47 56 65 75 83 94]
[15 24 33 42 51 60 70 78 89 0]
[19 28 37 46 55 64 74 83 93 0]
[ 0 0 41 50 59 69 77 88 0 0]
[ 0 0 0 0 63 72 82 92 0 0]]
可以看出,经过d = ndimage.rotate(c, 60, reshape=False)
后,d是由c逆时针旋转60度而得。
二、图片上的效果
这个方法可以使用在图片上面:
ph1 = ndimage.rotate(ph, 60, reshape=False)
plt.subplot(1, 2, 1)
plt.imshow(ph, cmap='gray')
plt.subplot(1, 2, 2)
plt.imshow(ph1, cmap='gray')
plt.show()
输出结果如下:
可见在调用ph1 = ndimage.rotate(ph, 60, reshape=False)
后,右侧(ph1)是左侧(ph)逆时针旋转60度获得的。
版权声明
本文为[umbrellalalalala]所创,转载请带上原文链接,感谢
https://blog.csdn.net/umbrellalalalala/article/details/122042742
边栏推荐
- 数字图像处理基础(冈萨雷斯)二:灰度变换与空间滤波
- Font shape `OMX/cmex/m/n‘ in size <10.53937> not available (Font) size <10.95> substituted.
- PyQt5学习(一):布局管理+信号和槽关联+菜单栏与工具栏+打包资源包
- Dwsurvey is an open source questionnaire system. Solve the problem that cannot be run and modify the bug.
- Remedy after postfix becomes a spam transit station
- Pytorch学习记录(五):反向传播+基于梯度的优化器(SGD,Adagrad,RMSporp,Adam)
- 手动删除eureka上已经注册的服务
- mysql-触发器、存储过程、存储函数
- 图解numpy数组矩阵
- POI exports to excel, and the same row of data is automatically merged into cells
猜你喜欢
Pyqy5 learning (4): qabstractbutton + qradiobutton + qcheckbox
Pytorch——数据加载和处理
PyEMD安装及简单使用
Pytorch学习记录(十):数据预处理+Batch Normalization批处理(BN)
解决报错:ImportError: IProgress not found. Please update jupyter and ipywidgets
软件架构设计——软件架构风格
字符串(String)笔记
lambda表达式
Pytorch Learning record (XIII): Recurrent Neural Network
Understand the current commonly used encryption technology system (symmetric, asymmetric, information abstract, digital signature, digital certificate, public key system)
随机推荐
无监督去噪——[TMI2022]ISCL: Interdependent Self-Cooperative Learning for Unpaired Image Denoising
Summary of redis classic interview questions 2022
Pytorch学习记录(十二):学习率衰减+正则化
Font shape `OMX/cmex/m/n‘ in size <10.53937> not available (Font) size <10.95> substituted.
Object to map
Idea plug-in --- playing songs in the background
治疗TensorFlow后遗症——简单例子记录torch.utils.data.dataset.Dataset重写时的图片维度问题
Latex quick start
redhat实现目录下特定文本类型内关键字查找及vim模式下关键字查找
线程的底部实现原理—静态代理模式
Pytorch学习记录(十):数据预处理+Batch Normalization批处理(BN)
lambda表达式
Common status codes
Anaconda安装PyQt5 和 pyqt5-tools后没有出现designer.exe的问题解决
Understand the current commonly used encryption technology system (symmetric, asymmetric, information abstract, digital signature, digital certificate, public key system)
Excel obtains the difference data of two columns of data
Navicate连接oracle(11g)时ORA:28547 Connection to server failed probable Oeacle Net admin error
框架解析1.系统架构简介
Anaconda
Rsync for file server backup