MATLAB: Varying image properties Using MATLAB slider

propertyslider

I'm not using slider for viewing image/graph on axes by sliding it. Code shown below is a part of my m-file.
function slider2_Callback(hObject, eventdata, handles)
% hObject handle to slider2 (see GCBO)
%eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fname = getappdata(0, 'fname');
[a, map] = imread(fname);
x = ind2rgb(a, map);
b = get(handles.slider2,'value');
j = imadjust(x,[],[],b);
axes(handles.axes1);
imshow(j);
b in above code is a variable. The moment I slide the slider image brightness changes but at first when I run the code slider's initial point will be in extreme left. But for above code slider should be at the center.
How can i set values( to increase/decrease brightness) to that slider? How can i go for it?

Best Answer

To make sure your slider initialize in any value of your liking, place the set function on the start-up function of your GUI.
set(handles.slider2,'value','your_value_here');
Related Question