Efficient way to remove objects that are partially surrounded by other objects?
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a 3D image that I have separated into several objects that touch eachother. Most of these objects are cylinders that border each other at their endpoints. I would like to keep these objects. Other objects appear to be embedded into these cylinders and I wold like to delete them or merge them with the cylinders. So far my method of doing this is to determine the outer pixels or boundaries of all objects individually as well as the boundaries of the the entire image (all objects combined) which we will call the "global boundary". Objects that share a low amount (<50%) of their boundaries with the global boundary are deleted. So far this is the code:
obj_coords is an Nx2 array that contains all coordinates of the objects (column 1) and their corresponding object ID (column 2)
A is the metric I will use to delete objects. I.e. if A(i,:) < 0.5 delete object i.
global_bound = im - imerode(im,true(3));
for i = 1:numobjects
obj = zeros(size(im),'uint8');
obj(obj_coords(obj_coords(:,2)==i),1) = 1;
loc_bound = obj - imerode(obj,true(3));
A(i,:) = length(find(loc_bound.*global_bound))/length(find(loc_bound));
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Basic Display 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!