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!