How do i find the coordinates of a boundary
7 次查看(过去 30 天)
显示 更早的评论
Hi, I am needing to find the length of only the line circled below. I am thinking if i can get the coorindates of the four corners of the boundary i would be able to subtract away the unwanted sides from the perimeter of the boundary, thus giving me the distance desired.
I = imread('ss3.png');
% imshow(I)
hold on
J=rgb2gray(I);
BW1=edge(J,'sobel',.009);
% imshow(imfill(BW1,'holes'))
mask = imclose(BW1, true(7));
mask = conv2(double(mask), ones(3), 'same') > 3.1; % Adjust number to control the size of the new mask.
mask = imfill(mask, 'holes'); % Remove any interior holes
% imshow(mask,'InitialMagnification', 'fit')
%Auto crop image using set points----------------------------------------
I2 = imcrop(mask,[407.51 0.51 83.98 1037.98]);
imshow(I2,'InitialMagnification', 'fit')
% 407.51 0.51 83.98 1037.98
I3 = bwareafilt(I2,[40 100000]);
% imshow(I3)
%boundary outline and trace -----------------------------------------
[B,L] = bwboundaries(I3,'noholes');
imshow(label2rgb(L, @gray, [0 0 0]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'g', 'LineWidth', 0.5)
end
% numPixels(k) = size(boundary, 1)
1 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!