How to save full size image in axes 2?

1 view (last 30 days)
(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

Accepted Answer

Geoff Hayes
Geoff Hayes on 28 Oct 2014
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!

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!