saving image after using slider
Show older comments
HI, I have problem with slider.
function slidergamma_Callback(hObject, eventdata, handles)
x=get(hObject,'Value');
imga=handles.imga;
imgas=imga.^x;
axes(handles.axes4);cla;
imshow(imgas);
set(handles.edit1,'String',num2str(x));
update(handles)
%guidata(hObject,handles);
It changes the value of gamma function . The function works but I need to safe image(handles.imga) and there is a problem. When I don´t use guidata(hObject,handles) at the end of the function ,the image is not upgraded and it always save the original image , when i use guidata(hObject,handles) saving works, but slider doesn´t work very well ( it doesn´t get real value of slider but I don´t now maybe it multiply values). Do somebody knows where is the problem?
Thanks a lot
j.
Answers (1)
Image Analyst
on 15 May 2013
Try
imgas= double(imga) .^ x;
axes(handles.axes4);
cla;
imshow(imgas, []); % The [] is important!
10 Comments
Image Analyst
on 15 May 2013
P.S. To save it you will have to convert to uint8 or uint16, or else save it in a .mat file.
janepear
on 15 May 2013
Image Analyst
on 15 May 2013
Usually image formats want integers. You didn't show how you were saving the files. Where is your call to imwrite()?
janepear
on 16 May 2013
Image Analyst
on 16 May 2013
Did you cast imga to double before raising it to a power? It doesn't look like it. Try that.
janepear
on 16 May 2013
Image Analyst
on 16 May 2013
That's the key that you left out. im2double() convert the image into the range 0-1 if the input is an integer. Most disk formats don't like floating point images in that range.
Image Analyst
on 16 May 2013
Well, are you calling imwrite() once or twice? From the code you showed, it looks like you're calling it just once, so why do you think it would save both images? However that was for some button callback, not the slider callback, which you haven't shown yet.
Categories
Find more on Image Arithmetic 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!