How to draw multiple shapes using Matlab's vision toolkit and step function?

I am trying to insert 2 images (circle and rectangle) into an image using these functions. But I can’t do it. Here is my code

J = step(shapeInserter, I, bbox); %bbox is rectangle which is already defined
J = step(shapeInserter, I, circle); %circle is circle which is already defined
imwrite(J,'image.jpg','jpg'); % it draws only the circle

I have a long way to go, which is to save the image of the rectangle and then load it again to draw a circle and save it. Which I want to avoid, as it really takes a lot of time.

I am trying to do something like this (similar to the graph plot function)

hold on
%draw circle
%draw rectangle
hold off
imwrite(J,'image.jpg','jpg');

Please inform, thanks

+4
source share
2 answers

vision.ShapeInserter Shape,

  • 'Rectangles'
  • 'Circles'
  • 'Lines'
  • 'Polygons'

'Rectangles'. ShapeInserter, , , release(shapeInserter); Shape set(shapeInserter,'Shape','Circles'). , .

:

I = imread('cameraman.tif');
rectangle = int32([10,10,50,60]);
circle = int32([200,200,40]);
shapeInserter = vision.ShapeInserter('Fill',true);

J = step(shapeInserter,I,rectangle);

release(shapeInserter);
set(shapeInserter,'Shape','Circles');
K = step(shapeInserter,J,circle);

imshow(K);

Result

+4

noob Matlab Image, - :

   frame=imread( '/home/omido/DeepLearning/matlab_segmentation/track/track/Image2.jpg' );
        result = insertShape(frame, 'FilledRectangle', [100,100,100,100], 'Color', 'green');
result = insertShape(result, 'FilledRectangle',  [200,200,200,200]  , 'Color', 'yellow');
        imshow(result);

: enter image description here

, .

+1

All Articles