필터 지우기
필터 지우기

PLease help me with filling the gape after doing simple subtraction of these images

조회 수: 3 (최근 30일)
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

답변 (2개)

Image Analyst
Image Analyst 2016년 7월 2일
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
Image Analyst
Image Analyst 2016년 7월 2일
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
Walter Roberson 2016년 7월 2일
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
Image Analyst
Image Analyst 2016년 7월 2일
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.
BlueBee77
BlueBee77 2016년 7월 2일
Yes, you re right. I can ignore this image but the same happens with other images when the skin is exposed or a person has a bald head e.g., image attached. For situation like this i cannot get a perfect boundary or mask. Do you have any idea what should i do for it.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by