MATLAB: Segment all the images in the lisbox

Image Processing Toolboxlistboxsegmentationthresholdingwatershed

I've multiple image in the listbox, 2 axes and 2 push button that is the segmentation method.(threshold and watershed) How can I segment all the images in the listbox and the orignal image is display in one of the axes and the segmented image in another axes. when click on different image the segmented image will actually correspond to the original image. All help is appreciated.

Best Answer

projectdir = 'the/directory_that/the/images/are_in';
selected_image_idx = get(handles.listbox1, 'Value');
all_image_names = cellstr( get(handles.listbox1, 'String') );
selected_image_names = all_image_names(selected_image_idx);
num_selected = length(selected_image_names);
for K = 1 : num_selected
this_name = selected_image_names{K};
this_image_file = fullfile( projectdir, this_name ); %presuming the stored name includes the extension
this_image = imread(this_image_file);
imshow(handles.axes1, this_image); %original image
title(handles.axes1, ['Original image: ', this_name ];
title(handles.axes2, 'Segmentation being computed');
imshow(handles.axes2, nan(1,1,3)); %blank output while we compute segmentation
drawnow();
segmented_image = segment_one_image(this_image);
imshow(handles.axes2, segmented_image);
title(handles.axes2, ['Segmented image: ', this_name ];
drawnow();
end
Related Question