我有一个图像,我想平滑其边缘。获得更准确的分割有一些挑战。然而,我通过改编来自What can I do to enhance my image quality?的建议得到了解决方案。我如何平滑多分量图像的边缘?
我使用的代码如下:现在
%# 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,[]);
我的挑战是理顺实体(whitePixels)的边缘或所有对象的边缘。我不知道如何做到这一点。我尝试了过滤,但只是取消了小点。 请大家非常感谢任何帮助,想法或建议或建议。谢谢。
你试过什么样的过滤? – Max
如果您平滑边缘,它将不再是分段(索引)图像。那是你要的吗? – beaker
@ user2201可能不是平滑边缘,而应尝试在索引图像上应用圆拟合算法。比你可以在你的索引图像上找到的圆圈更厚一点'LineWidth',你会在你的圆圈上得到更清晰的轮廓。然后 - 根据您需要的精度 - 您可以将镶嵌圆的像素索引为片段内部或外部。 – Max