MATLAB Answers

Aneta Ch

How to draw many rectangles in matlab?

Asked by Aneta Ch
on 13 Jan 2019
Latest activity Commented on by Image Analyst
on 6 Feb 2019 at 3:54
This question was flagged by Image Analyst
Any ideas for how to draw many rectangles in Matlab using conv or nlfilter?
This is my code:
for r = 1:step:imH - windowH + 1
for c = 1:step:imW - windowW + 1
W = I(r:r + windowH - 1, c:c + windowW - 1, :);
pos = [r c windowH windowW];
if p > 7
subplot(121); imshow(I); title 'Image';
hold on;
rectangle('Position', pos, 'FaceColor', '(1 0 0)');

  1 Comment

Note: aneta, for some reason, got rid of the original question and replaced it with one where the answers below no longer make sense.

Sign in to comment.

1 Answer

Answer by Image Analyst
on 13 Jan 2019

You forgot to attach your image.
Why not simply use the Color Thresholder app on the Apps tab of the tool ribbon?
Or else vectorize your code?