Matlab:获取图像的子集 [英] Matlab: getting a subset of an image

查看:560
本文介绍了Matlab:获取图像的子集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从4个点获得图像的子集。遵循此处中给出的解决方案我找到了点并根据最大和最小x,y值对它们进行了排序。之后我做了:

I am trying to get a subset of an image from 4 points. Following the solution given in here I located the points and sorted them in terms of maximum and minimum x,y values. After that I did:

subim = image(x_min:x_max,y_min:y_max,:);

以获取由 x_min中包含的矩形形成的子图像:x_max,y_min:y_max ,但这不起作用。

in order to obtain a sub-image formed by the rectangle contained in x_min:x_max,y_min:y_max, but this didn't work.

我做错了什么?

推荐答案

喜欢@Divakar回答你,

Like @Divakar answer you,

matlab image 适用于行和列属性,如图1中的帮助所示。

matlab image works with row and columns attribute as you can see in figure 1 on this help.

在图2中,它们显示了如何(x,y) )轴是定义的。如您所见, y 是行轴, x 列。

And in figure 2, they show how ( x , y ) axis are define. As you can see, y is the rows axis and x the columns.

因此当您使用 imshow imtool 时得到一个图上的坐标,它显示在(x,y)而不是(row,col)。只需反转您的坐标,您就可以获得所需。

So when you are using imshow or imtool to get coordinate on a figure, it's show in (x,y) instead of (row,col). Just by inverting your coordinate, you'll get what you need.

请注意,并非所有库或langague都使用相同的顺序,例如python中的Numpy与Matlab相同,但OpenCV是反向的。

Be aware not all library or langague use the same order, like Numpy in python is same as Matlab but OpenCV is the inverse.

这篇关于Matlab:获取图像的子集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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