Codebook for background-foreground segmentation

3 views (last 30 days)
Indra
Indra on 10 Dec 2013
Commented: sanaa on 20 Apr 2015
Can someone please explain me how to write a code for codebook model for background-foreground segmentation on image sequence? I've read the paper about in Real-time Foreground-Background segmentation using codebook model by Kyungnam KIm. But because I am a beginner in image processing and also using MATLAB therefore I have no idea how to write the code for my research.
I am trying to write based on my understanding following the guideline on that paper:
close all; clear all; clc;
%Set the number of training frames
background = imread('C:\Users\View_001\frame_1.jpg');
numofframes= 100; threshold = numofframes/2;
bg_bw = double(rgb2gray(background));
fr_size = size(background); width = fr_size(2); height = fr_size(1); fg = zeros(height, width);
for j = 1:numofframes jpgFilename = strcat('C:\Users\View_001\frame_', int2str(j), '.jpg'); fr_img = imread(jpgFilename); fr_img = double (fr_img);
%foreground_img = (abs(double(fr_img) - double(bg_bw)));
%decompose the RGB components within the image
Img_R = fr_img(:,:,1)>threshold;
Img_G = fr_img(:,:,2)>threshold;
Img_B = fr_img(:,:,3)>threshold;
xt= R.^2 + G.^2 + B.^2;
xt= (xt).^0.5;
%Normalized the RGB image color
[row, col] size (fr_img(:,:,1));
for y= 1:row %number of rows in image
for x = 1:col %number of columns in the image
Red = Img_R (x,y);
Green= Img_G (x,y);
Blue = Img_B (x,y);
Normalized_R = Red/xt;
Normalized_G = Green/xt;
Normalized_B = Blue/xt;
end
end
and I am stucking on the normalized image and after that I have no idea to do.
Here the instruction from the paper:
I wish someone can teach me how to write the code.. Thank you
  1 Comment
sanaa
sanaa on 20 Apr 2015
Sir/ Madame
Did you get any luck with this Code ??? Actually i'm working on the same program and i'm stuck , i need code for codebook model for background-foreground segmentation on image sequence? I've read the paper about in Real-time Foreground-Background segmentation using codebook model by Kyungnam KIm.
Thank you

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!