How to display rgb image from a matrix as well as insert rectangular shape in the same image.

4 visualizaciones (últimos 30 días)
I have a M x N matrix array which I have to display in rgb image. At the same time I want to insert a rectangular shape in the same image so that final image looks like a small portion is highlighted. Can somebody please tell me the appropriate code for it. In my case M=1065 N=1030 I want a rectangle of dimension 20 x 10 around [835,504]. Please help me out.

Respuesta aceptada

harjeet singh
harjeet singh el 30 de Dic. de 2015
try this
a(1:1065,1:1030,1:3)=255;
a=uint8(a);
roi=[835 504];
box=[20 10];
figure
imshow(a)
hold on
rectangle('position',[roi(1)-box(1)/2 roi(2)-box(2)/2 box(1),box(2)]);
hold off
drawnow

Más respuestas (1)

Walter Roberson
Walter Roberson el 30 de Dic. de 2015
image() or imshow() the matrix. rectangle() the highlight.
  1 comentario
RPG
RPG el 30 de Dic. de 2015
only 'image()' is working fine. Can you please elaborately write the command for 'rectangle()' for the above mentioned specifications. That will help me a lot.

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by