From: Kevin on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <70da088b-a44a-41cb-a645-f6a1d980e172(a)33g2000yqj.googlegroups.com>...
> Kevin:
> The bwareaopen() function considers only the area and pixels of the
> blob itself so of course it's very accurate. The median filter
> considers the value of ANY pixels that are contained in the window
> whether they belong to the blob of the center pixel, or to any other
> blob that's not even connected to the center pixel. Thus the median
> filter will give you inaccurate results as the window size gets larger
> and starts to include more unconnected blobs.
>
> I can't help you with the larger, more complicated problem of
> accurately outlining people and cars in any outdoor scene. This is a
> complicated situation worthy of a Ph.D. (unless you have very rigid
> constrained tightly controlled situations). Presumably that's what
> you're working on, so good luck with that.
>
> Perhaps this link of virtually all the image processing papers ever
> published will be of use:
> http://iris.usc.edu/Vision-Notes/bibliography/contents.html

Can you give/direct me some to examples in order to perform the median filteration as am interested to remove the small unconnected pixels.

Also forgot to say, the pic in the link is actually obtained from a video frame which is basically processed through gaussian background subtraction. So even if I could run some sort of filteration during in order to remove them small pixels.

Cheers
Kevin
From: Kevin on
This is the run file btw

%---------------------------------------------------------------------------------------
clc
clear all

source = aviread('san_fran_traffic_30sec_QVGA_Cinepak');

pixel_depth = 8; % 8-bit resolution
pixel_range = 2^pixel_depth -1; % pixel range (# of possible values)

% ----------------------- frame size variables -----------------------
nframe = source(1).cdata; % read in 1st frame as background frame
fr_bw = rgb2gray(nframe); % convert background to greyscale
frame_size = size(nframe);
width = frame_size(2);
height = frame_size(1);
foreground = zeros(height, width);
% --------------------- mog variables -----------------------------------
C = 3; % number of gaussian components (typically 3-5)\
M = 3; % number of background components
D = 2.5; % positive deviation threshold
alpha = 0.5; % learning rate (between 0 and 1)
threshold = 0.25; % foreground threshold (0.25 or 0.75 in paper)
sd_init = 0; % initial standard deviation (for new components) var = 36 in paper
w = zeros(height,width,C); % initialize weights array
mean = zeros(height,width,C); % pixel means
sd = zeros(height,width,C); % pixel standard deviations
u_diff = zeros(height,width,C); % difference of each pixel from mean
p = alpha/(1/C); % initial p variable (used to update mean and sd)
% --------------------- initialize component means and weights -----------

for i=1:height
for j=1:width
for k=1:C

mean(i,j,k) = rand*pixel_range; % means random (0-255)
w(i,j,k) = 1/C; % weights uniformly dist
sd(i,j,k) = sd_init; % initialize to sd_init

end
end
end


for n = 1:length(source)


nframe = double(source(n).cdata); % read in frame


[fr_bw, foreground, mean, sd] = background_subtraction(nframe,mean,w,sd,alpha,threshold,C,D,M,width,height);

figure(1),subplot(1,2,1),imshow(uint8(fr_bw))
subplot(1,2,2),imshow(uint8(foreground))


end
From: ImageAnalyst on
I didn't exactly follow the code.
I dont' really know what these are:
C = 3; % number of gaussian
components (typically 3-5)\
M = 3; % number of background
components
and I'm not really sure why you're putting a random value in to the
formula for mean(i,j,k). And I'm not sure I followed all of that
reshaping you're doing. It looks like the gist of it is to subtract
each pixel from a gaussian - weighted time average - is that right?

One question. Is your camera stationary? Or does it pan around,
changing the scene?
From: Kevin on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <199fc7d5-d9e5-4d4f-b09c-ef0310031008(a)x12g2000yqx.googlegroups.com>...
> I didn't exactly follow the code.
> I dont' really know what these are:
> C = 3; % number of gaussian
> components (typically 3-5)\
> M = 3; % number of background
> components
> and I'm not really sure why you're putting a random value in to the
> formula for mean(i,j,k). And I'm not sure I followed all of that
> reshaping you're doing. It looks like the gist of it is to subtract
> each pixel from a gaussian - weighted time average - is that right?
>
> One question. Is your camera stationary? Or does it pan around,
> changing the scene?

The camera is stationary yeah. Basically want to reduce the number of small pixels so that the larger connected pixels are only in the image.
From: Kevin on
Guys even if somebody could tell me how to apply median filter to my code or other kind of filteration which will prevent all the small pixels to appear in the videos.

Thanks