This is my code:
clear all
vid=videoinput('winvideo',1);
set(vid,'ReturnedColorSpace','RGB');
for x = 1:10
img = getsnapshot(vid);
R = img(:,:,1);
G = img(:,:,2);
B = img(:,:,3);
a = find(R>90 & R<157 & G>0 & G<100 & B>0 & B<81);
BW=zeros(480,640);
BW(a)=1;
imshow(BW)end
No products are associated with this question.
Change your two lines
BW=zeros(480,640);
BW(a)=1;to
BW = double(a);
This would produce exactly the same matrix as you are now producing.
You might possibly get slightly better graphics performance with uint8 instead of double, but you'd want to time carefully to be sure. For that,
BW = uint8(255) .* uint8(a);
or maybe
BW = uint8( 255 .* a );
or perhaps even
T = uint8([0 255]); BW = T(1 + a);
1 Comment
Direct link to this comment:
http://mathworks.com/matlabcentral/answers/43379#comment_89663
Please do not use "matlab" as a Tag. http://www.mathworks.co.uk/matlabcentral/answers/43073-a-guide-to-tags