필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Jainee Solanki
Jainee Solanki 2018년 2월 12일
댓글: Jainee Solanki 2018년 2월 12일
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
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.

카테고리

Help CenterFile Exchange에서 Agriculture에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by