MATLAB: Image Processing : Boundary

age analystdigital image processingimage analysisimage processingImage Processing Toolbox

I am trying to obtain the boundary and measure the perimeter of of the spanner. However, it seems like there are some weird boundary selected as well (1, 2 , 10, 11). can anyone suggest me how can i get rid of the unknown boundary ? i am new to matlab image processing and i am using image analyst 's code. Below is the coding for boundary :
boundaries = bwboundaries(binaryImage,'noholes');
numberOfBoundaries = size(boundaries, 1);
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k};
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
end

Best Answer

Solved! bwareaopen can be used to solve this problem ;)