Smooth Binary Image Edges

조회 수: 51 (최근 30일)
Kaden
Kaden 2018년 6월 8일
댓글: Image Analyst 2018년 11월 7일
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);

답변 (1개)

Image Analyst
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
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
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!

Translated by