- Crop ROI
- Segment your image
- Obtain the boundaries and calculate thickness
How can i detect the boundary using bwtraceboundary function ??
3 次查看（过去 30 天）
I want to detect the seperate two boundaries (inner and outer boundary) in our case.. I want to seperately detect inner and outer boundary and calculate the distance between them along the boundaries. In the image.png, I shown the exmple how will i want to do seperate the boundary (red and green colour boundary) which i want to seperate into inner and outer boundary. please give me a solution so i can automatically select the starting point and store the boundary data into two matrix.
Thank you for help
Antoni Garcia-Herreros 2023-5-2
You can take a look at this thread.
But the general idea would be to:
%% Crop region
se = strel('disk',5);
skelImage = bwskel(BWc, 'MinBranchLength', 10); % First guess. Strangely bwskel() doesn't seem to have any short spurs, no matter what MinBranchLength is.
imshow(imoverlay(BWc, skelImage, 'r'));
title('Binary image with skel')
%% Obtain distances
edtImage = bwdist(~BWc); %Distance of to nearest 0 value
radii = edtImage(skelImage); % Extract the distances only along the skeleton
% These are the half widths. Multiply by 2 to get the full widths.
averageWidth = 2 * mean(radii)
%% Find the boundaries
E=edge(BWc); % Find the edges
CC = bwconncomp(E); % Isolate the different components
Pout1=[rowOut1,colOut1]; % Pixels forming Outer boundary 1
Pin=[rowIn,colIn]; % Pixels forming Inner boundary 1
Pout2=[rowOut2,colOut2]; % Pixels forming Outer boundary 2
Hope this helps