saving image after using slider
显示 更早的评论
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.
回答(1 个)
Image Analyst
2013-5-15
Try
imgas= double(imga) .^ x;
axes(handles.axes4);
cla;
imshow(imgas, []); % The [] is important!
10 个评论
Image Analyst
2013-5-15
P.S. To save it you will have to convert to uint8 or uint16, or else save it in a .mat file.
janepear
2013-5-15
Image Analyst
2013-5-15
Usually image formats want integers. You didn't show how you were saving the files. Where is your call to imwrite()?
janepear
2013-5-16
Image Analyst
2013-5-16
Did you cast imga to double before raising it to a power? It doesn't look like it. Try that.
janepear
2013-5-16
Image Analyst
2013-5-16
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
2013-5-16
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!