您的位置:首页 > 编程语言 > MATLAB

Matlab 连通分量处理, 二维和三维 (Matlab, Connected Component Process, 2D&3D)

2016-06-13 22:10 776 查看
Matlab 连通分量处理, 二维和三维 (Matlab, Connected Component Process, 2D&3D)

The code for your reference, which is used to remove the minor components:

function Connect_Elimi = Connection_Judge_3D(Binary_Img, reject_T)
Connect_Elimi = Binary_Img;
% find components
CC = bwconncomp(Binary_Img);
% component number
C_number = CC.NumObjects;
% pixel number
numPixels = cellfun(@numel, CC.PixelIdxList);
totalPixels_N = sum(numPixels);
% remove minor components
for k = 1:C_number
cPixel_N = length( CC.PixelIdxList{k} );
ratio = cPixel_N / totalPixels_N;
if ratio  < reject_T
Connect_Elimi(CC.PixelIdxList{k}) = 0;
end
end


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息