MATLAB: How to use a value selected in listbox to use by a push button

axesguiimage processinglistboxpushbutton

i have a gui which contains
  • a push button to load file
  • a list box to select no of color (like 8,16,32)
  • a push button to convert the loaded rgb image to indexed using the value selected from the list box for its colormap.
  • an axes to display the image
how can i use the value of of listbox in my push button callback ??
[Merged information from Answer]
index_selected = get(hObject,'Value');
list = get(hObject,'String');
item_selected = list{index_selected};
handles.item = item_selected;
guidata(hObject, handles);
im using this in listbox call back but handles.item is putting the integer value in single quotation marks ('8') like this which my rgb2ind function doesnt accept and shows an error "X must be a positive integer value."
code for pushbutton callback
noofcol = handles.item;
[indimage,indmap] = rgb2ind('loaded file',noofcol);

Best Answer

handles.item = str2double( item_selected );
Related Question