Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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

Respuestas (1)

Walter Roberson
Walter Roberson el 12 de Feb. de 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.

Categorías

Más información sobre Agriculture en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by