Save plot on top of an image.
Mostrar comentarios más antiguos
Hello!
I need to save a graph on top of a black image. I have an image, so I want to make a plot on this image, and save it on a new image with black background and with same dimensions.
In the beginning I "paint" the image with black color, since I want both images to have the same dimensions. Then I use ginput and plot to pick the part of the image that I want. Then I open the black image using imshow(blackimage) and I use these commands:
f = getframe(gcf);
DATA = frame2im(f);
and I use imwrite to save DATA.
But I am having a problem with it because this program changes the dimensions of DATA, changes it to uint8, and the image becomes 3D. Please, can someone help me to solve this problem? What can I do to both images have the same dimensions?
Thank you for the help!
4 comentarios
Walter Roberson
el 16 de Jun. de 2015
Editada: Walter Roberson
el 16 de Jun. de 2015
I am confused about how many images are involved here?
You have an image, say X, and you want to select part of it, and make a plot on top of the part, say P, and then you want to take the whole thing and make a black border around it, and save the result (P on part-of-X on black) with the same size as the original image X?
Or you have an image, say X, and you have a plot, say P, and you want to plot P with a black border around it and sav the (P on black) with the same size as the original image X, and the content of the original X does not matter?
Or you have an image, say X, and a plot, say P, and you want to select part of the image that P should be drawn on top of, and then you want to take the whole thing and make a black border around it, and save the result (placed-P on X on black) with the same size as the original image X?
Determining where to place the plot relative to the black is not clear to me.
Ana Olivia
el 16 de Jun. de 2015
Walter Roberson
el 16 de Jun. de 2015
Is all of the original image to be included in the final image (except for the part covered up by the plot)? Or are you extracting a portion of the image and want to plot on a sub-portion of that? Something like:
display the full image
user selects a portion of it
everything outside of the selected portion is to be cleared to black
then plot on top in some pre-determined location
Is the plot a constant size and constant coordinates? Or is the user pointing out the location (and implicitly size) to put the plot? What is being set to black??
Ana Olivia
el 17 de Jun. de 2015
Respuestas (1)
Is this what you are looking for?
uiopen('C:\black.gif',1)%first image
imshow('black.gif');
[x,y] = ginput% select your interest
hold on
plot((1:900),1:900)%second image,plotting on first image
note: 1.here at the time of using "ginput" you have to select area manually and hit enter.
2.insteed of plot use your own.
1 comentario
Ana Olivia
el 17 de Jun. de 2015
Categorías
Más información sobre Data Exploration en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!