Borrar filtros
Borrar filtros

How can I specify the size of image I want to save?

4 visualizaciones (últimos 30 días)
reza
reza el 28 de Dic. de 2014
Comentada: Image Analyst el 30 de Dic. de 2014
Hi I am trying to save the image of my axes with this code :
F = getframe(handles.axes3);
image=frame2im(F);
imwrite(image, fullfile(add,name));
But my result image size is difference from original image! How can I save it in it's original size?

Respuestas (1)

Image Analyst
Image Analyst el 28 de Dic. de 2014
Editada: Image Analyst el 28 de Dic. de 2014
Use getimage() instead of getframe(). getimage() gets the actual image wheras getframe gets more like a screenshot of the image as it's displayed, which can be a different size and have graphics/annotation on it. Here's a demo:
grayImage = imread('concordorthophoto.png');
imshow(grayImage);
[rows, columns, numberOfColorChannels] = size(grayImage)
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Extract the image back out
extractedImage = getimage(gca);
[rows2, columns2, numberOfColorChannels2] = size(extractedImage)
% Extract the frame
frameStructure = getframe(gca);
frameImage = frameStructure.cdata;
[rows3, columns3, numberOfColorChannels3] = size(frameImage)
In the command window is the proof:
Warning: Image is too big to fit on screen; displaying at 33%
> In initSize at 71
In imshow at 309
In test1 at 10
rows =
2215
columns =
2956
numberOfColorChannels =
1
rows2 =
2215
columns2 =
2956
numberOfColorChannels2 =
1
rows3 =
881
columns3 =
1627
numberOfColorChannels3 =
3
You see that getimage() is getting the full sized image even though the displayed image was shrunk down to fit on the display. And you can see that getframe() gets you the screenshot sized image.
Not only that, but getframe() converts a grayscale image into color in case it needs to capture color graphics/text/annotation that's displayed in the overlay. You might not want your image converted to color.
  1 comentario
Image Analyst
Image Analyst el 30 de Dic. de 2014
reza, did that answer your question? If so, mark it as Accepted. If not, let me know what's still confusing.

Iniciar sesión para comentar.

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by