I have a 3-phase image in which I have segmented using automated thresholding (multithresh) and ‘imquantize’ functions. I do have lots of holes in the image without any filtering operation. However, these holes are reduced when I use a median filter although there are still quite a few of them left in-spite of the filtering.
Applying the ‘imfill’ function from this point results in “over-filling” as observed in the red-circled part of the image shown below.
The code is as follows:
%# Read in image
I = imread(‘original_image.jpg');
figure, imshow(I),axis off, title('Original Image');
%# Filter image
I = medfilt2(I);
% figure, imshow(I), title('Median-filtered image')
%# Segment image
thresh = multithresh(I, 2);
BW = imquantize(I, thresh);
figure, imshow(BW,[]),axis off, title('Segmented Image');
%# Fill holes
BW2 = imfill(BW,'holes');
figure, imshow(BW2, []); title('Filled holes image');
I am just wondering if there is any better way to handle this situation. Do you think using the ‘multithresh’ and ‘imquantize’ functions are good enough for the segmentation? Can the watershed do better and is it even necessary here?
In general, please what can I do to enhance the quality of my output image?
The reason I ask is because if you scale ‘imshow’ of the original image you will notice that most of the black phase touches the solid (white phase). However, the automated-segmentation doesn't accurately capture this as the segmented image has rings of the intermediate (grey) phase around the solid phase. How do I also handle this?
Many thanks for your anticipated help/suggestions.