Efficient way to remove objects that are partially surrounded by other objects?

5 views (last 30 days)
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

Answers (0)

Community Treasure Hunt

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

Start Hunting!