Smooth Binary Image Edges
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Image Analyst
el 9 de Jun. de 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 comentarios
Eric Chadwick
el 7 de Nov. de 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
el 7 de Nov. de 2018
Use bwareafilt() or bwropfilt() to identify thin objects and erase those from the image, then smooth, then OR them back into the image.
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!