I need to compute a background model using the information below can someone please help me in understanding and implementing the idea below
Show older comments
To compute this background model all of the pixels in the image are histogrammed-namely, for each pixel its color intensity is placed in the proper bin of a preferred possible 256 intensity levels. This is preferably done for each of the red, green and blue (RGB) channels thus generating three separate histograms. Alternately, one histogram could be generated using some joint space rep- resentation of the channels. Once the histogram has been computed, a Gaussian distribution for each histogram is calculated to provide the mean pixel intensity of the background and the vari- ance.
Answers (1)
Image Analyst
on 2 Aug 2012
Edited: Image Analyst
on 2 Aug 2012
Depends on what your background image is. I use polyfitn ( http://www.mathworks.com/matlabcentral/fileexchange/34765-polyfitn) to get a smooth illumination profile that I can use to correct for non-uniform lighting. But if you had, say a street scene with a bunch of people on it, then you wouldn't use that method, you'd take the mode or use GMM models or something.
I don't see how your proposed method would work at all. I don't even know what it does, except maybe get the mean color of the image, but you don't need to fit histograms to Gaussians to do that, or even to take histograms at all. Basically your method is just the same as:
meanRedValue = mean(rgbImage(:,:,1));
meanGreenValue = mean(rgbImage(:,:,2));
meanBlueValue = mean(rgbImage(:,:,3));
That's all your algorithm does, which is not even as locally adaptive as a blurring with conv2(). That's not really background correction at all.
7 Comments
Image Analyst
on 2 Aug 2012
Let's say you have a uint8 image with 256 gray levels. Now let's say you're scanning across all the pixels in the image and your current pixel has an RGB value of (100, 120, 140). You'd have 3 histogram arrays, each 256 elements (bins) long. In the red histogram array, you'd increment the element at 100 by 1 for that one pixel you're examining. Similarly you'd increment the green histogram array at 120 and you'd increment the bin for gray level 140 for the blue array.
Maria
on 3 Aug 2012
Image Analyst
on 4 Aug 2012
No, you don't want to do that. You don't want to write your own nested for loop manual procedure for getting a histogram when you can just call imhist(). Anyway, why do you want the histogram anyway when you can just use the three lines I gave you to determine the mean, which is what you asked about? A similar 3 lines using std() and var() will get you the standard deviation and variance.
Maria
on 4 Aug 2012
Categories
Find more on Histograms in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!