旋转 numpy 二维数组

2023-07-03Python开发问题
10

本文介绍了旋转 numpy 二维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一组灰度图像作为 2D numpy 数组.

I have a set of greyscale images as a 2D numpy arrays.

我需要围绕一个不同的浮动角度(在它们内部)旋转图像.旋转不需要到位,我将允许(当然,如果到目前为止我解释得很好)进行插值.

I need to rotate the images about one point (inside them) of different, float angles. The rotation doesn't need to be in place, and I will allow (of course, if I explained well so far) for interpolation.

我想留在 numpy 中,因为我需要对结果执行数值运算,但我也可以(如果不可能)允许步入/退出;例如,我尝试使用 PIL,即 Image.rotate(theta),但不明白如何将其应用于我的数组,以及如何取回数组.

I'd like to remain in numpy, as I need to perform numerical operations on the result, but I can also (if that's impossible) allow for step in/out; for example I tried using PIL, namely Image.rotate(theta) but don't understand how to apply that to my arrays, and how to get an array back.

感谢您的意见.

推荐答案

参见 cgohlke 2011-11-10 18:34 的评论:

See the comment of cgohlke Nov 10 '11 at 18:34:

考虑 scipy.ndimage.interpolation.shift() 和 rotate() 用于 2D numpy 数组的插值平移和旋转.

Consider scipy.ndimage.interpolation.shift() and rotate() for interpolated translations and rotations of 2D numpy arrays.

这篇关于旋转 numpy 二维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

在xarray中按单个维度的多个坐标分组
groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)...
2024-08-22 Python开发问题
15

Pandas中的GROUP BY AND SUM不丢失列
Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)...
2024-08-22 Python开发问题
17

GROUP BY+新列+基于条件的前一行抓取值
Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)...
2024-08-22 Python开发问题
18

PANDA中的Groupby算法和插值算法
Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)...
2024-08-22 Python开发问题
11

PANAS-基于列对行进行分组,并将NaN替换为非空值
Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)...
2024-08-22 Python开发问题
10

按10分钟间隔对 pandas 数据帧进行分组
Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)...
2024-08-22 Python开发问题
11