How to save full size image in axes 2?

1 次查看(过去 30 天)
(this is when I load an image in axes1)
axes(handles.axes1);
handles.DummyImage = uigetfile({'*.jpg';'*.jpeg';'*.png';'*.bmp'});
guidata(hObject,handles);
I=imread(handles.DummyImage);
imshow(I);
(example of processing method)
axes(handles.axes2);
L=imread(handles.DummyImage);
M=adapthisteq(L);
imshow(M);
(this is what I used to save image)
[FileName, PathName] = uiputfile('*.jpg','*.tif', 'Save As');
Name = fullfile(PathName,FileName);
F=getframe(handles.axes2);
W=frame2im(F);
imwrite(W, Name, 'tif');
*I want to save full size image and not in frame size

采纳的回答

Geoff Hayes
Geoff Hayes 2014-10-28
Ahmad - since your code is showing the image M in your axes2 as
axes(handles.axes2);
L=imread(handles.DummyImage);
M=adapthisteq(L);
imshow(M);
then why not re-use M to save the image to file as
imwrite(M, Name, 'tif');
Are you grabbing the frame because the "save" code is in a different callback and so you no longer have access to M? If so, you have a couple of options - either save M as a member of the handles structure (use guidata for this), or try to access the image data directly as
[FileName, PathName] = uiputfile('*.jpg','*.tif', 'Save As');
Name = fullfile(PathName,FileName);
% get the handle to the child object axes2
hChildAxes2 = get(handles.axes2,'Children');
% assume one child only and grab the image data
W = get(hChildAxes2(1),'CData');
% write the image to file
imwrite(W, Name, 'tif');
Try the above and see what happens!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by