Detecting shortest path on binary image
显示 更早的评论
I'm trying to detect the shortest path from certain point on the image P in certain radius of searching, as shown on the picture. I was using linear equation y=ax+b,
x=400;
y=600;
switch direction
case 'right'
while(impixel(image,x,y)==[0,0,0])
x=x+1;
%y=600 stays the same
end
case 'left'
while(impixel(image,x,y)==[0,0,0])
x=x-1;
end
%(...)
end
which is easy to use with horizontal line (a=0,b=x), but problem appears when I want to rotate the line with point P as origin. Since the pixel P is not the origin (0,0) of the image, its not enough to just change the 'a' parameter, but also somehow calculate 'b' for full linear equation.
Maybe there is some helpfull command that allows to detect the clostest binary object in given direction? If not, I'd appreciate any suggestions how can I calculate a and b parameters for the line equations.
2 个评论
KALYAN ACHARJYA
2019-11-29
The question is:
Are you looking for the distance between yellow point and nearest white pixel towards right hand side?
Right?
sooljex
2019-11-29
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
