How to draw same size rectangle on different image location
古いコメントを表示
Hi,
I have selected random points using the below code
m = imread('a.jpg');
figure, imshow(m);
random_num = 50;
l = randi(numel(m), 1, random_num);
m(l) = 255;
figure, imshow(m);
Now I want to draw circle/rectangle for each random points. circle/rectangle for all points will be of equal size.
Can anyone assist me how to do that please.
Added an image for your information.

採用された回答
その他の回答 (2 件)
Youssef Khmou
2014 年 11 月 22 日
Try to adjust this protocol to your problem :
L=0.5;
N=100;
for n=1:N
p=randn;
p2=randn;
r=p+L;
r2=p2+L;
x=[p r r p p];
y=[p2 p2 r2 r2 p2]; plot(x,y,'k')
hold on;
end
title(' Random positions of same size rectangles')

2 件のコメント
Tania
2014 年 11 月 22 日
Ahmet Cecen
2014 年 11 月 21 日
0 投票
This is a filter operation. I am 95% sure you cancan get away with using imdilate with a circle or square structral element of your liking. Basically make your randomcpoints 1 and everything else 0, and dilate that image.
4 件のコメント
Ahmet Cecen
2014 年 11 月 21 日
Maybe I am not understanding you. Do you basically want to draw circles at random locations? Like the image you attached?
Tania
2014 年 11 月 22 日
Image Analyst
2014 年 11 月 22 日
Isn't that what I showed in my answer?
カテゴリ
ヘルプ センター および File Exchange で Image Arithmetic についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

