which function should i use for a slider to adjust the contrast of an image.
3 views (last 30 days)
Show older comments
I've created a slider to adjust the brightness, now i have to create another for contrast. Which function should i use?
Brightness slider function:
% --- Executes on slider movement. function slider_brightness_Callback(hObject, eventdata, handles) % hObject handle to slider_brightness (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
A = get(handles.slider_brightness,'Value');
AFMimage = handles.AFM_Adjust; a = get(hObject,'Value'); BadjAFMimage = imadd(AFMimage,a); handles.AFM_BAdjust = BadjAFMimage;
axes(handles.axes1); imshow(BadjAFMimage); axes(handles.axes4); imhist(BadjAFMimage);
set(handles.slider_brightness,'Value',A); set(handles.Btext,'String',num2str(A));
imwrite(BadjAFMimage,'Enhance Image.jpg','jpg')
% Update handles structure guidata(hObject, handles);
% --- Executes during object creation, after setting all properties. function slider_brightness_CreateFcn(hObject, eventdata, handles) % hObject handle to slider_brightness (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end
0 Comments
Answers (1)
Image Analyst
on 21 Jan 2014
I'd probably call imadjust() to have the slider change the image. Or you could just change the colormap and apply that, or you could call intlut(). However you want to do it.
2 Comments
Image Analyst
on 22 Jan 2014
Don't you think you just called it incorrectly? What do you think (the badly-named) a should be? Look at the help, then see what your slider value is, and construct a second argument for imadjust() that makes sense. I know you can do it because you're a smart engineer.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!