請幫助我找到附加圖像中用綠色點標記的點的座標。線的斜率是已知的,並且中心的座標對於圖像是已知的。我想在MATLAB中編寫代碼。請給我同樣的想法。
圖像由座標已知的中心點組成,並且知道通過中心點的直線的斜率確定綠點座標。找到圖像上的座標,知道一條線的中心點和斜率
-3
A
回答
0
我創建了通過中心座標的座標矢量,並具有所需的斜率。
我用過極座標來創建X,Y座標向量。
找到座標後,我搜索曲線上的綠色圓點。
我的解決方案是不理解(不是最優雅的)那麼簡單......
這裏是我的代碼:
%Input image (for testing).
I = imread('cameraman.tif');
I = cat(3, I, I, I); %Make I it "color" image where (R = G = B).
center = [100, 100];
slope = 1.5;
%Mark the center point with red (for debugging).
I(center(1)-1:center(1)+1, center(2)-1:center(2)+1, 1) = 255;
%Put green dots (for debugging).
x0 = 123;y0 = 65;
x1 = 12;y1 = 232;
I(y0-1:y0+1, x0-1:x0+1, 2) = 255;I(y0, x0, 1) = 0;I(y0, x0, 3) = 0;
I(y1-1:y1+1, x1-1:x1+1, 2) = 255;I(y1, x1, 1) = 0;I(y1, x1, 3) = 0;
% #
% 1.5# #
% # #
% # #
% ## alpha
% ############
% 1
alpha = -atan2(slope, 1);
%Create vector of "radius" (distance from the center).
r = -norm(size(I))/2:0.2:norm(size(I))/2;
%Each (x,y) coordinate is on the line passing through center point
x = r*cos(alpha) + center(2);
y = r*sin(alpha) + center(1);
%Remove x and y outsize image boundaries from x, y arrays.
X = x;Y = y;
X((x < 1) | (x > size(I,2)) | (y < 1) | (y > size(I,1))) = [];
Y((x < 1) | (x > size(I,2)) | (y < 1) | (y > size(I,1))) = [];
%Round X and Y (to be legal pixel coordinates).
X = round(X);
Y = round(Y);
R = zeros(size(X)) + 1; %Coordinate of 1'rd plane (red channel).
G = zeros(size(X)) + 2; %Coordinate of 2'rd plane (green channel).
B = zeros(size(X)) + 3; %Coordinate of 3'rd plane (blue channel).
%V gets values of pixels channel pixels in the curve.
rV = I(sub2ind(size(I), Y, X, R)); %Red channel values.
gV = I(sub2ind(size(I), Y, X, G)); %Green channel values.
bV = I(sub2ind(size(I), Y, X, B)); %Blue channel values.
%Find green dots where r, g, b = 255.
V = (rV == 0) & (gV == 255) & (bV == 0);
%Mark X,Y coordinates with blue color (for debugging).
I(sub2ind(size(I), Y, X, B)) = 255;
figure;imshow(I)
v0 = find(V, 1, 'last');
v1 = find(V, 1);
greenDot0 = [Y(v0), X(v0)]
greenDot1 = [Y(v1), X(v1)]
1
如果中心點是已知的,我認爲,沒有必要做圖像處理。 你需要的是一個線性方程。
y = tan(slope) * x
然後你只需簡單地找到x1
和x2
,因爲y1
和y2
也從照片聞名。
+0
實際上斜率已經是角度的切線。所以'y = slope * x' –
相關問題
- 1. 找到兩條線的交叉點,給定一個不變的斜率並改變座標
- 2. 已知線上的點的座標
- 3. iPhone座標系兩點斜率截距
- 4. 計算圓的中心座標知道2點
- 5. 圖像上點擊點的座標HTML
- 6. 如何使用OpenCV查找圖像上另一點的座標
- 7. 使用Python查找位於圖像中曲線上的點的座標
- 8. 找到一條線上的點
- 9. 計算圓上一點的座標,沿圓的中心與另一點之間的一條直線?
- 10. 製作一個函數,使線段座標以點(x y)爲中心,斜率爲m
- 11. 如何在UIWebView中查找圖像的中心/ x,y座標
- 12. 獲取從地圖上畫出一條直線上的座標
- 13. 查找C#中線條交點的座標
- 14. 解析圖像座標上的座標
- 15. 基於焦點點在座標系上畫一條橢圓線?
- 16. 以座標軸爲中心的散點圖,看起來像「十字線」
- 17. 查找曲線中的線性部分和斜率
- 18. 如何知道在Google地圖上選定標記的座標
- 19. 從一個點和一條線獲取矩形座標
- 20. 如何在C#中的圖像中找到像素座標?
- 21. 在圖像c中查找條形碼的座標#
- 22. 如何在觸摸時知道圖像的座標
- 23. 如何查找Google地圖上特定點和線之間的最近座標?
- 24. 如何找到離斜坡m上給定點d距離的xy座標?
- 25. 查找圖像視圖內的座標?
- 26. 如何找到閾值圖像中最低像素的座標?
- 27. 查找圖像每一行的斜率(角度)
- 28. 如何找到一個像素的鄰域和它的座標
- 29. 找到一條線的交點
- 30. 如何查找圖像中矩形的角點座標
你的意思是你的輸入是一個圖像,你想使用圖像處理技術來獲得座標? –
嗨prashanth,請寫一個[最小,完整和可驗證的例子](http://stackoverflow.com/help/mcve) – obchardon