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.

 采纳的回答

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 个评论

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
This is a result of your using Alpha properties of the patch. You will notice that the problem disappears if you leave Alpha alone.
I find the problem can be fixed by issuing this command at the beginning of your function:
opengl('software')
Thank you very much! It worked perfectly.

请先登录,再进行评论。

更多回答(0 个)

类别

Community Treasure Hunt

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

Start Hunting!

Translated by