Smooth Binary Image Edges
25 次查看(过去 30 天)
显示 更早的评论
I am looking to smooth edges of a binary image (black and white). Currently I have a 3D segmented image with fairly jagged edges which I would like to smooth. The code I have written takes the image and separates it into slices, with my intention being to smooth the edge of each slice to hopefully give a good 3D smooth surface.
How can I go about making these edges smooth? I cant seem to solve this problem.
Thanks in advance!
segment_volume = int16(readanalyze([ImagePath ImageName]));
for i = 1:size(segment_volume,1)
im_temp = squeeze(segment_volume(:,i,:)); %(row, column, slice)
% Smoothing function here???
segment_volume(:,i,:) = reshape(im_temp, [1 size(im_temp)]);
end
%Save File
writeanalyze(FileName, segment_volume_smooth);
0 个评论
回答(1 个)
Image Analyst
2018-6-9
A fairly good way is to just blur the image and threshold. Something like (untested)
kernel = ones(N, N, N) / N^3;
blurryImage = convn(double(binaryImage), kernel, 'same');
newBinaryImage = blurryImage > 0.5;
Increase N from 3 to some bigger odd number to get more smoothing.
2 个评论
Eric Chadwick
2018-11-7
Hi Image Analyst. Your suggestion works well if your image consists of thick objects, but if - as in my case - you are working with a range of object sizes, this method will delete thinner objects. Do you have any suggestions to smooth edges of only the thick objects? The thin objects don't need to have smoothing done to them.
Image Analyst
2018-11-7
Use bwareafilt() or bwropfilt() to identify thin objects and erase those from the image, then smooth, then OR them back into the image.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!