Azzera filtri
Azzera filtri

Can someone help me to improve this code.It is about detection of weeds

2 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Walter Roberson
Walter Roberson il 12 Feb 2018
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.

Categorie

Scopri di più su Agriculture in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by