How to draw a rectangle on a image?

I am trying to draw a rectangle on a image.
box =[100 200 200 200]
im=imread(im); figure, imshow(im)
hold on rectange = rectangle('Position', box, 'FaceColor','k')
Everytime the image gets displayed but without the rectangle. Please help me.

回答 (1 件)

DGM
DGM 2023 年 3 月 21 日

0 投票

I'm going to guess that whatever the image was, it was either too small for the specified rectangle to be in-frame, or it was large, and the rectangle was being placed in a dark region.
box =[100 200 100 100];
im=imread('peppers.png');
imshow(im)
hold on
rectangle('Position', box, 'FaceColor','k')

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

質問済み:

2015 年 6 月 11 日

回答済み:

DGM
2023 年 3 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by