Background Subtraction using gmm on single image

4 ビュー (過去 30 日間)
Muzamil Hassan
Muzamil Hassan 2020 年 5 月 31 日
編集済み: Sarvath Sharma 2020 年 7 月 17 日
clc
clear all
close all
[file, pathname] = uigetfile('D:\studies\FYP\original images.jpg','Load Image');
cd(pathname);
foregroundDetector = vision.ForegroundDetector('NumGaussians', 3, ...
'NumTrainingFrames', 50);
face_original = imread(file);
size_img = size(face_original);
imshow(face_original), title ('Original Image')
foreground = step(foregroundDetector, face_original);
figure; imshow(foreground); title('Foreground');
this code gives black screen.
  2 件のコメント
Image Analyst
Image Analyst 2020 年 5 月 31 日
I guess it didn't find a face. But what do I know -- you didn't post your image.
Muzamil Hassan
Muzamil Hassan 2020 年 5 月 31 日
here is an image and this code gives output as an black image

サインインしてコメントする。

回答 (1 件)

Aakash Mehta
Aakash Mehta 2020 年 6 月 24 日
ForegroundDetector method is used to detect the motion in the video. As you are applying it to a single image, it is considering the whole image as a background.
foreground = step(foregroundDetector, face_original);
Above line will give the foreground mask which is 2D matrix. It contains 0's and 1's. In your case it's giving all 0's as it is not able to detect any foreground. That's why when you are trying to display image you are getting black image.
  1 件のコメント
Sarvath Sharma
Sarvath Sharma 2020 年 7 月 17 日
編集済み: Sarvath Sharma 2020 年 7 月 17 日
So how would one use the foregroundDetector and the step function to clear out and determine the 1s and 0s for the foreground mask? Would we have to do a comparison between two images and pass that in as a parameter to the step fucntion?

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by