Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ddimage_Filter Class Reference
[Image Processing FiltersTemporal]

#include <ddimage_Filter.h>

Inheritance diagram for ddimage_Filter:

phFilter phMutex phObject List of all members.

Detailed Description

Double Difference Image 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:

This code was originally coded into a phFilter by Mike Baker for car tracking research. It was later optimized by Phil Thoren to make use of buffer reusable computations (the motion image Z) and use a ring buffer for saving history images and saving on memory copies. In addition, the filter was extended to allow for the choice of the two different block filtering operations ( ddimage_BlockStandard and ddimage_BlockKernel ) as described above.
allow frame A, B and C to be arbitrarily located within the sequence of frames

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)
 ~ddimage_Filter ()
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)
phImagegetMaskImage ()
phFiltercloneFilter ()

Protected Member Functions

int filter ()

Private Attributes

uint8_t ** m_history
uint32_t m_history_count
uint32_t m_temp_frame_size
uint8_t ** m_diff
uint32_t m_diff_count
uint32_t m_diff_index
uint32_t m_stride
uint32_t m_mask_size
int m_domask
uint32_t m_threshold
uint32_t m_pixel_threshold
uint32_t m_block_filter

The documentation for this class was generated from the following files:

Copyright (C) 2002 - 2007 Philip D.S. Thoren ( )
University Of Massachusetts at Lowell
Robotics Lab Logo

Generated on Sat Jun 16 02:44:33 2007 for phission by  doxygen 1.4.4