I have an image in which i would like to smoothen its edges. There was a bit of a challenge in getting a more accurate segmentation. I however got a solution by adapting the suggestion from: What can I do to enhance my image quality?.
The code i used is as follows:
%# Read in image
Img = imread('image_name.png');
%# Apply filter
h = fspecial('average');
Img = imfilter(Img, h);
%# Segment image
Img = rgb2gray(Img);
thresh = multithresh(Img, 2);
Iseg = imquantize(Img, thresh);
figure, imshow(Iseg,[]), title('Segmented Image');
%# separate channels
blackPixels = (Iseg == 1);
grayPixels = (Iseg == 2);
whitePixels = (Iseg == 3);
%# grow white channel
whitePixels_dilated = imdilate(whitePixels, strel('disk', 4, 4));
%# Add all channels
Iseg(whitePixels | whitePixels_dilated) = 3;
figure, imshow(Iseg,[]);
My challenge right now is to smoothen the edges of the solid (whitePixels) or the edges of all objects. I have no idea how to do this. I have tried filtering but that only takes off the small spots. Please any help, ideas, or suggestions or advice is greatly appreciated. Thank you.