PLease help me with filling the gape after doing simple subtraction of these images
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to do background subtraction,by simply subtracting two image. However the resultant image has some gape. Can anyone help me solve this. I would appreciate if someone can help. Attached are the images
0 commentaires
Réponses (2)
Image Analyst
le 2 Juil 2016
You need to lower your threshold if you want to capture the man's tan coat over a tan walkway. Or else look at optical flow.
9 commentaires
Image Analyst
le 2 Juil 2016
I'm surprised a low threshold with optical flow didn't work, or that Guassian mixed models or simple subtraction didn't work. But you promised you tried all those methods plus more and they all failed.
So you'll have to scout out the literature. Start here http://www.visionbib.com/bibliography/contents.html to look for possible other methods not covered by the Computer Vision System Toolbox.
Walter Roberson
le 2 Juil 2016
FirstImage = imread('BackgroundInt.png');
SecondImage = imread('BackInt4.png');
diff_image = double(SecondImage) - double(FirstImage);
sdiff_image = diff_image - min(diff_image(:));
sdiff_image = sdiff_image ./ max(sdiff_image(:));
pixels_changed = double( any(diff_image ~= 0, 3) );
image(sdiff_image, 'AlphaData', pixels_changed);
set(gca, 'color', [0 .5 0])
The green parts that show up will be the pixels with no change. You will see a lot of gray areas: those are areas where at least one of the pixel components changed a little. The person will have clearer outlines, including blue pants.
In order to get any further you would need to use a threshold to define changes as being too small to be meaningful. For example you could substitute
pixels_changed = double( any(abs(diff_image) >5, 3) );
Also, you can do
mask = repmat(logical(pixels_changed), 1, 1, 3);
FIm = FirstImage * 0; %same size and datatype
FIm(mask) = FirstImage(mask);
subplot(1,2,1);
image(FIm);
axis image
SIm = SecondImage * 0; %same size and datatype
SIm(mask) = SecondImage(mask);
subplot(1,2,2);
image(SIm);
axis image
this will pick out the pixels that have changed and show the "before" and "after" content of those pixels. You might want to experiment with
mask = logical(pixels_changed); mask = bwareafilt(mask,[10 inf]); mask = repmat(mask,1,1,3);
8 commentaires
Image Analyst
le 2 Juil 2016
Perhaps if they're within a certain distance of each other and they track/translate in synchrony with each other, then they're part of the same moving object. The easy tracking stuff is easy but you'll spend way way more code on handling these kinds of pathological situations like a man in a tan suit walking over a tan walkway, or people who align/overlap to produce one object and then suddenly turn around and way back in the direction they came, or a person getting in a car and then suddenly "disappearing", or two people in red shirts and blue jeans passing in front of each other, etc. Those kinds of bizarre situations always take a lot of special ad-hoc coding.
Voir également
Catégories
En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!