Output image and patch as new image

16 views (last 30 days)
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.

Accepted Answer

Matt Fig
Matt Fig on 8 May 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 Comments
Matt Fig
Matt Fig on 8 May 2011
I find the problem can be fixed by issuing this command at the beginning of your function:
opengl('software')
Alba
Alba on 8 May 2011
Thank you very much! It worked perfectly.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!