matlab矩阵按坐标取,在Matlab中获取inlier点的坐标(Get coordinates of inlier points in Matlab)...

在Matlab中获取inlier点的坐标(Get coordinates of inlier points in Matlab)

我需要找到使用impixel()在对象检测中获得的内部点的像素值。 我使用链接中的示例中提供的相同代码

如何获得内点的x,y坐标相对于图像尺寸。(图像的左上角被视为0行, 0 col),以便我可以使用坐标来查找各自的像素值。 我在Matlab中找不到任何与C++中的KeyPoint对象相同的解决方案,它可以轻松地提供坐标值。

I need to find pixel values of inlier points obtained in object detection using impixel(). I am using the same code as provided in the example at the link

How can I get x,y coordinates of the inlier points being with respect to image dimensions.(Top-left corner of image considered as 0 row, 0 col) so that I can use the coordinates to find their respective pixel values. I couldn't find any solution in Matlab same as KeyPoint object in C++ that gives coordinate values easily.

原文:https://stackoverflow.com/questions/29530724

更新时间:2020-01-08 00:29

最满意答案

你这里不需要impixel 。 impixel可让您从图中显示的图像中获取像素值,这不是您想要做的。

在您使用的示例中, inlierBoxPoints和inlierScenePoints是SURFPoints对象。 您可以将点的(x,y)位置设为inlierBoxPoints.Location 。 然后你可以得到第i个点的像素值,如下所示:

loc = round(inlierBoxPoints.Location(i, :));

pixVal = boxImage(loc(2), loc(1), :);

请记住,在MATLAB中,图像被索引为(row,col),左上角像素为(1,1),而不是(0,0)。 您必须舍入坐标,因为以子像素精度检测点。

You do not need impixel here. impixel lets you get the pixel value from in image displayed in a figure, which is not what you are trying to do.

In the example you are using, inlierBoxPoints and inlierScenePoints are SURFPoints objects. You can get the (x,y) locations of the points as inlierBoxPoints.Location. Then you can get the pixel value for the i-th point as follows:

loc = round(inlierBoxPoints.Location(i, :));

pixVal = boxImage(loc(2), loc(1), :);

Keep in mind that in MATLAB the images are indexed as (row, col), and that the top-left corner pixel is (1,1), not (0,0). You have to round off the coordinates, because the points are detected with sub-pixel accuracy.

2015-04-09

相关问答

只需使用regionprops : stats = regionprops(B,'Centroid')

以下是如何使用它的详细方法: 首先我会产生一些随机点 a=zeros(50);

a(ind2sub(size(a),randi(numel(a),7,1)))=1;

a=padarray(a,[10 10]);

a=conv2(a,fspecial('gaussian',7,1),'same');

b=a>0.02;

imagesc(b);

然后使用regionprops: stats

...

data = [2,2 ; 2,3 ; 1,2 ; 1,3 ; 2,1 ; 1,1 ; 3,2 ; 3,3 ; 3 ,1]

% corresponding sort-value, pick one out or make one up yourself:

sortval = data(:,1); % the x-value

sortval = data(:,2); % y-value

sortval = (data(:,1)-x0).^2 + (data(:,2)-y0).^2; % distan

...

一旦你进入matirx(这应该相对容易),简单的方法是使用imresize,否则困难的方法是使用interp2将值拉伸或压缩到另一个的大小。 然后只需使用减法来获得矩阵之间的差异 Once you get it into a matirx (this should be relatively easy), the easy way is to use imresize, otherwise the hard way is to use interp2 to stretch or condense

...

你这里不需要impixel 。 impixel可让您从图中显示的图像中获取像素值,这不是您想要做的。 在您使用的示例中, inlierBoxPoints和inlierScenePoints是SURFPoints对象。 您可以将点的(x,y)位置设为inlierBoxPoints.Location 。 然后你可以得到第i个点的像素值,如下所示: loc = round(inlierBoxPoints.Location(i, :));

pixVal = boxImage(loc(2), loc(1),

...

编辑:无可否认,这只是一个部分答案,因为我只是解释为什么这些方法甚至可以用这些拟合方法,而不是如何改进输入关键点从一开始就避免这个问题。 正如其他答案中所述,关键点匹配的分布存在问题,并且在关键点检测阶段有办法解决这个问题。 但是,对于具有相同关键点对的 estimateFundamentalMatrix 矩阵的重复执行, 相同输入会产生不同结果的原因是因为以下原因。 (同样,这并不能为改善关键点提供合理的建议以解决这个问题)。 重复执行的不同结果的原因与RANSAC方法(以及LMedS和MSAC

...

您可以使用pcshow函数绘制您的点,它将直接采用M-by-N-by-3阵列。 然后,您可以打开数据提示并单击绘图中的点以查看其坐标。 如果您仍想创建3乘N矩阵,那么最简单的方法是: x = xyzPoints(:,:,1);

y = xyzPoints(:,:,2);

z = zyzPoints(:,:,3);

points3D = [x(:)'; y(:)', z(:)'];

You can use the pcshow function to plot your points, and i

...

关于你的第二个要求,当用户按下一个键时,控件会从图形窗口移动到命令窗口,除非你使用的是waitforbuttonpress ,这会使事情变得不必要。 因此,可以建议使用双击来表示输入坐标结束的替代解决方案。 这是在下面显示的链接stackoverflow代码的修改版本中完成的。 码 function varargout = ginput_ax_mod2(ha,n)

if nargin<2

n=1;

end

k = 0;

button = 0;

%%// Tolerance so that

...

为了进一步理解,我在此链接中尝试了以下代码。 % Extract SURF features

I = imread('cameraman.tif');

points = detectSURFFeatures(I);

[features, valid_points] = extractFeatures(I, points);

% Visualize 10 strongest SURF features, including their

% scales and orientation

...

使用detectSURFFeatures和detectSURFFeatures本质上返回一个结构 ,其中每个字段包含有关在图像中检测到的兴趣点的相关信息。 为了给出一个可重现的例子,让我们使用作为图像处理工具箱一部分的cameraman.tif图像。 让我们同时使用两个功能检测框架和默认参数: >> im = imread('cameraman.tif');

>> harrisPoints = detectHarrisFeatures(im);

>> surfPoints = detectSURF

...

这总是很有趣:) 首先:Mohsen Nosratinia的回答是好的,只要 你不需要知道实际的距离 你可以绝对肯定地保证你永远不会去极地附近 并且永远不会接近±180°子午线 对于给定的纬度,-180°和+ 180°经度实际上是相同的点 ,因此仅仅观察角度之间的差异是不够的。 这在极地地区将是一个更大的问题,因为那里的大经度差异对实际距离的影响较小。 球面坐标对于导航,绘图和类似的东西非常有用和实用。 然而,对于空间计算,就像您尝试计算的表面距离一样,球面坐标实际上非常麻烦。 虽然可以直接使用角

...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值