Can someone help me to improve this code.It is about detection of weeds
조회 수: 2 (최근 30일)
이전 댓글 표시
A = imread('C:/Users/Jainee/Desktop/Cracks/irrigation.jpg');
[m,t]=size();
C=zeros(m,t);
for k=1:t
for l=1:m
if A(l,k,1) == 0 && A(l,k,2)>50 || A(l,k,2)<120 && A(l,k,3)==0; % Considering all weeds of %green color having intensity between 50 and 120.
C(l,k)=255; %(weed)
end
end
end
답변 (1개)
Walter Roberson
2018년 2월 12일
A = imread('C:/Users/Jainee/Desktop/Cracks/irrigation.jpg');
mask = A(:,:,1) == 0 & A(:,:,2) > 50 | A(:,:,2) < 120 & A(:,:,3) == 0;
C = 0 * A;
C(mask) = 255;
Your line
[m,t]=size();
is incorrect because it does not pass any parameter to size(). The obvious thing to pass would be the image, A, but then the line would be wrong because when you have a 3 dimensional array, [m,t] = size(A) does not mean that the number of rows should be stored in m and that the number of columns should be stored in t. You would need [m, t, ~] = size(A) to get that.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!