numpy翻转坐标系 [英] Numpy flipped coordinate system

查看:329
本文介绍了numpy翻转坐标系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用opencv进行了一些图像处理.然后,我尝试在绘图仪上绘制图像(原点位于左下方),但是图像被翻转了. opencv的原点在左上角,因此图像的y坐标被翻转.> /p>

我应该对我的点应用什么函数,以使其在新的原点系统(左下角)中正确绘制?

我不关心更改绘图显示,实际上我需要翻转点的坐标. 使用np.flipud根本不会更改这些点,因为该点由N X 2矩阵显示.

解决方案

问题不在于numpy,而在于显示数据的matplotlib方式.为了产生有效的可视化效果,您应该在 image generation 级别上翻转y轴,而不是进行numpy分析.可以通过matplitlib API轻松地将其用于axis对象:

plt.gca().invert_yaxis()

I used opencv to do some image processing. I tried to then plot the image on my plotter (origin at lower left), however the image is flipped. opencv's origin is in the upper left, and so the y coordinates of the image are flipped.

What function should I apply to my points such that it will plot properly in the new origin system (lower left)?

EDIT: I am not concerned with changing the plot display, I actually need the points' coordinates flipped. Using np.flipud did not change the points at all since the point are displayed by a N X 2 matrix.

解决方案

The problem does not lie in numpy but in matplotlib way of displaying data. In order to produce valid visualization you should flip y-axis on the image generation level, not numpy analysis. It can be easily done through matplitlib API to the axes object:

plt.gca().invert_yaxis()

这篇关于numpy翻转坐标系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆