how to detect border irregularity?

I have traced exterior boundaries of this region. now i want to have boundary box and centre of mass around it. How can I do this?

답변 (1개)

KSSV
KSSV 2020년 3월 20일

0 개 추천

If (x,y) are your boundary points.
% Get bounding box
x0 = min(x) ; x1 = max(x) ;
y0 = min(y) ; y1 = max(y) ;
%
A = [x0,y0] ;
B = [x1,y1] ;
Also to get the center, you can find mean.
iwant = [mean(x) mean(y)] ;

댓글 수: 9

joynob ahmed
joynob ahmed 2020년 3월 20일
But how can I get (x,y) point? i have used this code for boundary determination.
[B,L] = bwboundaries(BW,'noholes');
imshow(label2rgb(L, @jet, [.5 .5 .5]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)
end
KSSV
KSSV 2020년 3월 20일
편집: KSSV 2020년 3월 20일
B = cell2mat(B) ; % assuming B is two columns
x = B(:,2) ; y = B(:,1) ;
joynob ahmed
joynob ahmed 2020년 3월 21일
편집: joynob ahmed 2020년 3월 21일
No,it can't give me the bounding box and centre of mass. May be I have done some mistake. Please check this out.I have attached the resultant image with code:
[B,L] = bwboundaries(rotatedImage,'noholes');
imshow(label2rgb(L, @jet, [1 1 1]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'black', 'LineWidth', 2)
end
% Get bounding box
B = cell2mat(B) ; % assuming B is two columns
x = B(:,2) ; y = B(:,1) ;
x0 = min(x) ; x1 = max(x) ;
y0 = min(y) ; y1 = max(y) ;
A = [x0,y0] ;
B = [x1,y1] ;
plot(A, B, 'r', 'LineWidth', 2)
iwant = [mean(x) mean(y)] ;
plot(iwant, 'g', 'LineWidth', 2)
joynob ahmed
joynob ahmed 2020년 3월 25일
can you help me with this please?
KSSV
KSSV 2020년 3월 26일
Attach your original image.
joynob ahmed
joynob ahmed 2020년 3월 26일
KSSV
KSSV 2020년 3월 26일
Attach B and L into mat file and share.
joynob ahmed
joynob ahmed 2020년 3월 28일
I have tried in 2 ways to detect border irregularity. Here I am taking help of an article where they have got success.I am adding both matfile and the article here.
joynob ahmed
joynob ahmed 2020년 4월 2일
KSSV,Have you seen the files?

댓글을 달려면 로그인하십시오.

질문:

2020년 3월 20일

댓글:

2020년 4월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by