Take the 2-minute tour ×

I have a video with upper half background as white and lower half background as gray. As the video proceeds, there is smoke and the visibility of the background reduces. There is a camera shake and hence the point at which the black background changes to white keeps changing (moving up and down). My objective is to quantify the camera shake in each frame by tracking the vertical position at which the black background becomes gray.

I want to track the vertical co-ordinate (Y) at which the background changes from black to gray. In this regard, I have the following questions,

1) How to identify the change in color? Is there any method to find the color change (gradient) between consecutive pixels in MATLAB?

2) How to increase the visibility of the background? Is there any filter to enhance the background visibility?

share|improve this question

3 Answers 3

If your camera is reasonably stationary and the background is constant enough you could just subtract subsequent images. If the differences between the smoky part of your image and the background are large enough the area where smoke wasn't in the previous frame and is in the new frame will show a much larger difference than the rest of the image. This will give you the location of the "new" smoke, and you can use that to keep track of how far the smoke has progressed.

share|improve this answer
Thanks for the reply. I was not clear in my objective earlier. I have modified the question to include my objective. I have to quantify the camera shake by tracking a static object, which in this case is the background. All the foreground features in the video are moving. –  Sulla Feb 17 '12 at 9:31
Do you only want to detect vertical shake? Is horizontal shake not an issue? Have you tried a simple optical flow algorithm (en.wikipedia.org/wiki/Optical_flow) to detect shake? –  jilles de wit Feb 17 '12 at 9:49

to clear your image you can use:-

clear_image= histeq(im);

To detect the change in black and gray use the following code:-

BW = edge(I,'canny');
[B,L] = bwboundaries(BW,'noholes');
boundary = B{1}; 
plot(boundary(:,2), boundary(:,1), 'r', 'LineWidth', 2);
share|improve this answer

Try vision.ForegroundDetector from the Computer Vision System Toolbox.

share|improve this answer

Your Answer


