how to use a for loop to find all row ?!

조회 수: 1 (최근 30일)
Ajaree Rattanaharn
Ajaree Rattanaharn 2019년 2월 28일
댓글: Ajaree Rattanaharn 2019년 3월 1일
Hello, Please Help me?
I want to find the lenght of index <1 = black color in the picture name 'bwcircle_crop'
crack_crop.jpg
but now, I write the code for thr first row but I dont know to use for loop to find the same way in all row.
เส้นแถวแรก.png
Thank you ^^

채택된 답변

KSSV
KSSV 2019년 2월 28일
편집: KSSV 2019년 3월 1일
I = imread('crack_crop.jpeg') ;
I = rgb2gray(I) ;
[y,x] = find(I==0) ;
imshow(I)
hold on
plot(x,y,'.r')
%% GEt bounding box
x0 = min(x) ; x1 = max(x) ;
y0 = min(y) ; y1 = max(y) ;
%
B = x1-x0 ;
L = y1-y0 ;
R = [x0 y0 ; x0 y1 ; x1 y1 ; x1 y0] ;
% patch(R(:,1),R(:,2),'b')
if L>B
title('Vertical Crack')
else
title('Horizonatal Crack')
end
  댓글 수: 5
KSSV
KSSV 2019년 3월 1일
Edited the code.
Ajaree Rattanaharn
Ajaree Rattanaharn 2019년 3월 1일
Thank You very much
I'm done.^^

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by