Output image and patch as new image

I have an image that I put a transparent patch over. I would like to now "merge" the image and the patch into a new image, which I can call later. I've tried setting the patch to a variable and using imshow to show this image, but that does not work because the variable is only a number, not an image matrix. I would like to know if there is a way to do this and if there is, how.
Thank you.

 Respuesta aceptada

Matt Fig
Matt Fig el 8 de Mayo de 2011
Use GETFRAME to capture what you see on the axes.
For example:
X = load('clown');
X = ind2rgb(X.X,X.map);
image(X) % Show the clown.
patch([50,150 150 50],[50 50 20 20],'b') % Make a patch
F = getframe(gca);
figure
image(F.cdata) % Show the new image in new figure...

4 comentarios

Alba
Alba el 8 de Mayo de 2011
I'm using a while loop where if statements determine the color of the patch. When I try to use this method, it only copies the original image and not the new patched one. Do you know how to get around this?
my code is linked below:
http://pastebin.com/w76Zhaa1
Matt Fig
Matt Fig el 8 de Mayo de 2011
This is a result of your using Alpha properties of the patch. You will notice that the problem disappears if you leave Alpha alone.
Matt Fig
Matt Fig el 8 de Mayo de 2011
I find the problem can be fixed by issuing this command at the beginning of your function:
opengl('software')
Alba
Alba el 8 de Mayo de 2011
Thank you very much! It worked perfectly.

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 7 de Mayo de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by