Minions
Minions

Reputation: 5477

Drawing rectangle in an image - Matlab

I need to draw a rectangle inside an image, then i want to set all the area that is out of the rectangle (that filled by the orange airBrush) to black and save the editing!

Here is my code:

%Draw rectangle
shapeInserter = vision.ShapeInserter;
rectangle = int32([100 100 800 800]);
J = step(shapeInserter, imageA , rectangle);
imshow(J);

enter image description here

I was just drawn the rectangle, without any idea to complete my work, any help ?

Image dimension is 1000x1000.

Upvotes: 1

Views: 1169

Answers (1)

Tasos Papastylianou
Tasos Papastylianou

Reputation: 22225

RickRoll = rgb2gray(imread('Rick-Roll3.png'));  % 800x800 image
I = zeros ([1000, 1000]);
I(101:100+800, 101:100+800) = RickRoll;

enter image description here

Upvotes: 4

Related Questions