sachin Agarwalla
sachin Agarwalla

Reputation: 11

How to highlight a region of Interest in an image in Matlab

I am wondering how to highlight a mask/Region of Interest (or how to mark identified objects) in an image in Matlab at given/specified location?

Upvotes: 1

Views: 6615

Answers (3)

andrea
andrea

Reputation: 1358

if you have all the vertexes of the region you are interested in you can simply use the line command. I post you how to draw a rectangle having the four vertexes (each a pair of x,y coordinates).

rect1=[a';b';c';d';a'];

line(rect1(:,1),rect1(:,2),'LineWidth',5);

I don't know if that is what you are looking for.

Upvotes: 0

Shai
Shai

Reputation: 114786

Another useful command is rectangle. Suppose rect holds the bounding box around the object (in format [ from_x from_y width height]), then the following code will produce a box around the object in the image:

figure('Name', 'showing detected object');
imshow( img ); % show original image
hold all;  % hold image and plot rectangle on top
rectangle( 'Position', rect );

Upvotes: 2

Alex
Alex

Reputation: 5893

If you want the user to select a region on an image, then you can use the functions:

imrect
impoly
imellipse
imline

from the Image Processing toolkit.

Upvotes: 0

Related Questions