Inheritance diagram for ddimage_Filter:
This filter uses a Double Difference algorithm for calculating motion within a series of frames. The algorithm that this filter is based on takes 3 input images that are temporal neighbors. Image A and B are differenced to produce motion image Y and images B and C are differenced to produce motion image Z. If there is motion in the same pixel indecies of the Y and Z motion images, then motion is assumed and placed into the output image from this filter.
After the motion image is created, an optional 4x4 block filter can be used to filter out noise pixels that generally result from the differencing of frames. While the Double Difference algorithm is already less prone to noise due to the need for motion in both motion images Y And Z, it is possible there may still be noise. The 4x4 block filter is an extra step that isn't likely needed but can improve segmentation of the motion regions.
This page was referenced for the Double Difference algorithm:
The implementation of the Double Difference algorithm presented here makes several modifications and extensions of the original Double Difference algorithm. The first extension is the addition of stride and the second extension is the implementation of the 4x4 block filter to establish better motion boundaries.
The algorithm allows differencing 3 frames where A < B < C (temporally) and the number of frames separating A and B temporally is the same number that separate B and C temporally. This stride parameter potentially allows for potentially better motion resolution. Since this is a temporal filter, it will buffer all the frames it needs which is equal to 2 * stride.
A feature of this filter is that it saves previous computations that will be performed again in the future. This saves processing time but at the expense of a larger memory foot print. Let's use an example to illustrate the idea of buffering previous computations. Assume the case where the stride is 3. Following is a list of the differencing computations that will be made with the temporal indecies identifying the different frames. The list includes the corresponding saved incoming frame buffers and difference buffers, when they are saved and where they are used are listed next to each entry.
The 4x4 block filter normally breaks the image into a group of neighboring 4x4 blocks and reject an entire blocks of pixels if there weren't enough pixels (pixel_threshold) in that 4x4 block. A modification of the block filtering is permited that instead only modifies the top-left pixel of a the 4x4 moving kernel. The 4x4 kernel starts at the top left and moves one pixel to the right for the whole width of the image. If there are not enough motion pixels in the 4x4 block, the top-left most pixel is set to 0 (no motion), otherwise it is set to 255 (motion). When the right side of the image has been reached, then the entire 4x4 block will be set to the determined 0 (for no motion) or 255 (motion) value. After the entire width of the image has been covered, then the kernel moves down 1 row and the process is executed again. This solidifies edges and reduces noise pixels at the same time in order to give better motion outlines for better segmentation.
An extra output from the ddimage_Filter is a motion mask image (in phImageGREY8 format). The image is stored in a phImage instance to allow for the encapsulation of the width, height, format, etc. and for synchronous signalling and copying of the motion mask while the ddimage_Filter is executing. The mask is established by examining the output of the ddimage_Filter and determining if a particular pixel has motion or doesn't have motion. If there isn't motion, the mask value is set to 255. If there is motion, then the value is set to 0. By using this mask one can detemine an area of focus where there is a lot of motion or one can mask out areas where there is only occational motion. Since writing to another image buffer can impact the performance of the filter and it requires more memory, the generation of the motion mask image can be toggled with either ddimage_Filter::enableMotionMask() or ddimage_Filter::disableMotionMask.
Supports the following formats:
add a 'set' method; it will have to flush the buffers
add example image inputs and processed image outputs
add example application code that shows how the processed images were output
FIX the stride calculation in ddimage
Definition at line 243 of file ddimage_Filter.h.
Public Member Functions
|ddimage_Filter (uint32_t threshold=15, uint32_t stride=2, uint32_t pixel_threshold=0, uint32_t block_filter=ddimage_BlockKernel)|
|int||get (uint32_t *threshold, uint32_t *stride, uint32_t *pixel_threshold, uint32_t *block_filter)|
|int||setThreshold (uint32_t threshold)|
|int||setStride (uint32_t stride)|
|int||setPixelThreshold (uint32_t pixel_threshold)|
|int||setBlockFilter (uint32_t block_filter)|
|int||set (uint32_t threshold, uint32_t stride, uint32_t pixel_threshold, uint32_t block_filter)|
|int||enableMotionMask (int enable=1)|
|int||disableMotionMask (int disable=1)|
|phImage *||getMaskImage ()|
|phFilter *||cloneFilter ()|
Protected Member Functions
|Copyright (C) 2002 - 2007||
Philip D.S. Thoren ( email@example.com )
University Of Massachusetts at Lowell