Why I get the background in white color while it should be black !
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Han
am 9 Mär. 2018
Beantwortet: Image Analyst
am 9 Mär. 2018
Hi ..
I have the following code:
vid = videoinput('winvideo',1);
set(vid, 'ReturnedColorspace', 'rgb');
% set(vid,'FramesPerTrigger',4);
set(vid,'TriggerRepeat',Inf);
vid.FrameGrabInterval = 6;
start(vid);
BackgroundImage = getsnapshot(vid);
I1 = rgb2gray(BackgroundImage);
figure;
subplot(3,3,1);
imshow(I1);
title('Background F1');
while 1
frames = getsnapshot(vid);
subplot(3,3,2);
imshow(frames);
title('RGB frames');
I2 = rgb2gray(frames);
subplot(3,3,3);
imshow(I2);
title('Gray frames');
Objects = I1 ~= I2;
subplot(3,3,4);
imshow(Objects);
title('Objects');
end
In this part of code should give me a black background and the objects should be white
Objects = I1 ~= I2;
subplot(3,3,4);
imshow(Objects);
title('Objects');
but I get white background ! when I tried it on images it was work just fine :|
Could you please help me
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 9 Mär. 2018
Every pixel is likely to be different since it came from a video camera. So you can't compare value for value. You should see if values are within some tolerance threshold, like closer than 5 gray levels or whatever.
toleranceThreshold = 5; % Whatever works for you...
Objects = abs(double(I1) - double(I2)) > toleranceThreshold; % A binary image.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!