Bounding Boxes at any points

18 ビュー (過去 30 日間)
arun Dhillon
arun Dhillon 2019 年 1 月 29 日
コメント済み: Brian Hart 2019 年 1 月 30 日
Can anyone suggest me that how do i create a bounding box on any desired coordinate in an image,, for instance, if i want to create a bounding box of size 2*2mm at the pixel coordinate 13,15 or 25,25. Is there any way to create the bounding boxes as such.
8

採用された回答

Brian Hart
Brian Hart 2019 年 1 月 29 日
Hi arun,
Here's some code to do what you asked, but with everything in units of the graph/plot (not mixing mm / pixel coordinates):
figure;
x=3;
y=5;
plot(x,y,'*')
boxHalfWidth = 1; %
boxXStart = x-boxHalfWidth;
boxYStart = y-boxHalfWidth;
boxWidth = 2 * boxHalfWidth;
boxHeight = 2 * boxHalfWidth;
rectangle('Position',[boxXStart boxYStart boxWidth boxHeight])
axis([0 10 0 10])
axis square
You can change the boxHalfWidth variable for different box sizes.
  2 件のコメント
arun Dhillon
arun Dhillon 2019 年 1 月 29 日
Brian Hart
Thanks a lot for the help.
It works perfectly
Brian Hart
Brian Hart 2019 年 1 月 30 日
That should be possible. If the x,y points are in an array, you could use a for-loop to draw rectangles for each point pair.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by