2

I have an image and I plotted the boundary of the image. Can anyone please tell me how to draw a rectangle on the image by overwriting the boundary pixel values, using MATLAB.

2 Answers 2

1

If it is a straight rectangle, just set the values in the matrix:

function Stack1()
im = imread('peppers.png');
x = 10;
y = 20;
w = 40;
h = 50;
im(y:y+h,x,:) = 255;
im(y:y+h,x+w,:) = 255;

im(y,x:x+w,:) = 255;
im(y+h,x:x+w,:) = 255;

figure();imshow(im);


end
0

Probably you can use this File Exchange submission:

Draw a border around an image

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.