1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| function jianche = detection_color(picture_2) red=0; yellow=0; green=0; for i = 1:size(picture_2,1) for j = 1:size(picture_2,2) if picture_2(i,j,1)>=200&&picture_2(i,j,2)<=50&&picture_2(i,j,3)<=50 red=red+1; elseif picture_2(i,j,1)>=200&&picture_2(i,j,2)>=200&&picture_2(i,j,3)<=50 yellow=yellow+1; elseif picture_2(i,j,2)>=200&&picture_2(i,j,1)<=100&&picture_2(i,j,3)<=100 green=green+1; end end end if max(max(red,yellow),green)==red color = 'red' elseif max(max(red,yellow),green)==yellow color='yellow' elseif max(max(red,yellow),green)==green color='green' end
|