saving image after using slider
Mostra commenti meno recenti
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.
Risposte (1)
Image Analyst
il 15 Mag 2013
Try
imgas= double(imga) .^ x;
axes(handles.axes4);
cla;
imshow(imgas, []); % The [] is important!
10 Commenti
Image Analyst
il 15 Mag 2013
P.S. To save it you will have to convert to uint8 or uint16, or else save it in a .mat file.
janepear
il 15 Mag 2013
Image Analyst
il 15 Mag 2013
Usually image formats want integers. You didn't show how you were saving the files. Where is your call to imwrite()?
janepear
il 16 Mag 2013
Image Analyst
il 16 Mag 2013
Did you cast imga to double before raising it to a power? It doesn't look like it. Try that.
janepear
il 16 Mag 2013
Image Analyst
il 16 Mag 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
il 16 Mag 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.
Categorie
Scopri di più su Image Arithmetic in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!