Saturday, 31 August 2013

Virtual drawing pad using color detection in matlab

Virtual drawing pad using color detection in matlab

I am trying to make a virtual drawing pad by detecting and tracking red
objects in a video from a webcam and increasing corresponding intensity
values on a blank background. I am using this code to track red objects
data = getsnapshot(vid);
diff_im = imsubtract(data(:,:,1), rgb2gray(data)); %find red regions in
image
diff_im = medfilt2(diff_im, [3 3]); %Use a median filter to
filter out noise
diff_im = im2bw(diff_im,0.18); % Convert the resulting grayscale
image into a binary image.
diff_im = bwareaopen(diff_im,300); % Remove all those pixels less than
300px,
[bw, count] = bwlabel(diff_im, 8);
if(count > 0)
%% then draw rectangle around centroid of detected object
I am checking for every pixel, which increases processing time when image
size increases(even for 640*480). As a result of this output is blank for
many frames. How can I improve it..??

No comments:

Post a Comment