segment all the images in the lisbox
2 views (last 30 days)
Show older comments
Pui Choo Wong
on 17 Jan 2017
Edited: Pui Choo Wong
on 18 Jan 2017
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.
0 Comments
Accepted Answer
Walter Roberson
on 17 Jan 2017
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
6 Comments
Image Analyst
on 18 Jan 2017
You'll have to explain it better than that. Of course the segmented image doesn't look like the original - it's a binary image, not a gray scale or color image. You forgot to attach any images that illustrate your assertions. And there is no reason that you shouldn't be able to do the second and subsequent images in your loop. You should get a new Area for each image. Of course you're not storing them in an array so Area will get overwritten each time and after the loop just contain the last Area computed.
More Answers (1)
Image Analyst
on 17 Jan 2017
That's exactly what MAGIC does. http://www.mathworks.com/matlabcentral/fileexchange/24224-magic-matlab-generic-imaging-component Either use that code, or copy and paste the code from the "Go" button into your "Go" button that starts the batch process.
2 Comments
Image Analyst
on 17 Jan 2017
You forgot to post the error. I've used MAGIC myself with gray scale images and it works fine. I can't help you unless you post the error.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!