how can i connect between these squares in a line from the centers ????
1 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1184188/image.jpeg)
3 个评论
回答(1 个)
Marcel
2022-11-8
编辑:Marcel
2022-11-8
If you know the coordinates, width and height of each square, you can use the X and Y coordinates to get the top left corner of each square.
Now that you have the left corner, you add an "offset" to it, which would be half the height and width of the square to get the middle.
Then you can draw a line like this
% frame is something like you get from imread or getsnapshot
frame = insertShape(frame, 'Line', ...
[x1 y1 x2 y2], 'Color', "blue", "LineWidth", 4);
% X1 & y1 is the first square
% x2 & y2 is the second one
% by doing so you can connect them
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1185158/image.png)
2 个评论
Rik
2022-11-8
You have an image, therefore you have coordinates. An image is nothing more than a list of intensity values layed out in a grid. You need to determine the location of the red pixels. Do you have any idea where to start with that?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!