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/spec开发者_开发知识库ified location?
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 );
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.
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.
精彩评论