matlab矩阵按坐标取,在Matlab中获取inlier点的坐标(Get coordinates of inlier points in Matlab)...
在Matlab中獲取inlier點的坐標(Get coordinates of inlier points in Matlab)
我需要找到使用impixel()在對象檢測中獲得的內(nèi)部點的像素值。 我使用鏈接中的示例中提供的相同代碼
如何獲得內(nèi)點的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)位置設(shè)為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
相關(guān)問答
只需使用regionprops : stats = regionprops(B,'Centroid')
以下是如何使用它的詳細方法: 首先我會產(chǎn)生一些隨機點 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(這應(yīng)該相對容易),簡單的方法是使用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)位置設(shè)為inlierBoxPoints.Location 。 然后你可以得到第i個點的像素值,如下所示: loc = round(inlierBoxPoints.Location(i, :));
pixVal = boxImage(loc(2), loc(1),
...
編輯:無可否認,這只是一個部分答案,因為我只是解釋為什么這些方法甚至可以用這些擬合方法,而不是如何改進輸入關(guān)鍵點從一開始就避免這個問題。 正如其他答案中所述,關(guān)鍵點匹配的分布存在問題,并且在關(guān)鍵點檢測階段有辦法解決這個問題。 但是,對于具有相同關(guān)鍵點對的 estimateFundamentalMatrix 矩陣的重復(fù)執(zhí)行, 相同輸入會產(chǎn)生不同結(jié)果的原因是因為以下原因。 (同樣,這并不能為改善關(guān)鍵點提供合理的建議以解決這個問題)。 重復(fù)執(zhí)行的不同結(jié)果的原因與RANSAC方法(以及LMedS和MSAC
...
您可以使用pcshow函數(shù)繪制您的點,它將直接采用M-by-N-by-3陣列。 然后,您可以打開數(shù)據(jù)提示并單擊繪圖中的點以查看其坐標。 如果您仍想創(chuàng)建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
...
關(guān)于你的第二個要求,當用戶按下一個鍵時,控件會從圖形窗口移動到命令窗口,除非你使用的是waitforbuttonpress ,這會使事情變得不必要。 因此,可以建議使用雙擊來表示輸入坐標結(jié)束的替代解決方案。 這是在下面顯示的鏈接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本質(zhì)上返回一個結(jié)構(gòu) ,其中每個字段包含有關(guān)在圖像中檢測到的興趣點的相關(guān)信息。 為了給出一個可重現(xiàn)的例子,讓我們使用作為圖像處理工具箱一部分的cameraman.tif圖像。 讓我們同時使用兩個功能檢測框架和默認參數(shù): >> im = imread('cameraman.tif');
>> harrisPoints = detectHarrisFeatures(im);
>> surfPoints = detectSURF
...
這總是很有趣:) 首先:Mohsen Nosratinia的回答是好的,只要 你不需要知道實際的距離 你可以絕對肯定地保證你永遠不會去極地附近 并且永遠不會接近±180°子午線 對于給定的緯度,-180°和+ 180°經(jīng)度實際上是相同的點 ,因此僅僅觀察角度之間的差異是不夠的。 這在極地地區(qū)將是一個更大的問題,因為那里的大經(jīng)度差異對實際距離的影響較小。 球面坐標對于導(dǎo)航,繪圖和類似的東西非常有用和實用。 然而,對于空間計算,就像您嘗試計算的表面距離一樣,球面坐標實際上非常麻煩。 雖然可以直接使用角
...
總結(jié)
以上是生活随笔為你收集整理的matlab矩阵按坐标取,在Matlab中获取inlier点的坐标(Get coordinates of inlier points in Matlab)...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2021中国汽车供应链峰会盛大开幕,第一
- 下一篇: 华夏万家是做什么的 许多投资者余额变成了