Smooth Binary Image Edges

52 visualizzazioni (ultimi 30 giorni)
Kaden
Kaden il 8 Giu 2018
Commentato: Image Analyst il 7 Nov 2018
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);

Risposte (1)

Image Analyst
Image Analyst il 9 Giu 2018
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 Commenti
Eric Chadwick
Eric Chadwick il 7 Nov 2018
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 il 7 Nov 2018
Use bwareafilt() or bwropfilt() to identify thin objects and erase those from the image, then smooth, then OR them back into the image.

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by