如何在 MATLAB 中编辑图像的轴以反转方向?
我想编辑正在显示的一系列图像中的轴。
这就是我的图像的样子:
如您所见,从上到下的范围是 0 到 500 左右。我可以颠倒一下吗? 另外,我想镜像所显示的图像,以便它从左到右开始......或者,如果可能的话,让轴从右到左显示。
I would like to edit the axes in my series of images being displayed.
This is what my image looks like:
As you can see, it ranges from 0 to about 500 from top to bottom. Can I invert that?
Plus, I want to mirror the image being shown, so that it starts from left to right... or, if it's possible, to let the axes show from right to left.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
要反转轴,您可以设置
' XDir'
或'YDir'
的属性当前轴到'reverse'
:请记住,以这种方式翻转轴也会翻转图中的所有内容。这可能不是您想要对 y 轴执行的操作。您可能只想翻转 y 轴标签,可以通过修改
'YTickLabel'
属性,方法如下:To reverse an axis, you can set the
'XDir'
or'YDir'
property of the current axes to'reverse'
:Keep in mind that flipping an axis in this way flips everything in the plot as well. This probably isn't what you want to do for the y axis. You probably just want to flip the y axis labels, which you can do by modifying the
'YTickLabel'
property in the following way:哇哦,图像现在有一个 y 轴,范围从下到上!
在 MATLAB 中使用 IMAGE 或 IMAGEESC 函数显示图像时,如何反转 y 轴? mathworks 的另一个解决方案
And whoop dee doo the image now have an y axis with the range from bottom to top!
How can I reverse the y-axis when I use the IMAGE or IMAGESC function to display an image in MATLAB? Another solution from mathworks
我发现 gnovice 的答案很有帮助,但它需要对我进行一些调整。我认为以下是反转 y 轴上标签的更通用方法。只需按降序对 y 刻度数字进行排序并重新标记即可。
I found gnovice's answer helpful but it needed some tweaks for me. I think the following is a more general way to reverse the labels on the y axis. Simply sort the y tick numbers in descending order and relabel.
我从一个重复的问题重定向到这里:
翻转轴刻度
'ale' 想要做的只是将 y 轴方向翻转为自上而下。如果这是唯一需要的东西而没有其他东西,我会使用:
I was redirected here from a duplicate question:
Flipping axis ticks
What 'ale' wanted to do there was just to flip the y-axis direction to be top down. If that is the only thing needed and nothing else, I would use: