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

add_Filter Class Reference
[Image Processing FiltersTemporal]

#include <add_Filter.h>

Inheritance diagram for add_Filter:

phFilter phMutex phObject List of all members.

Detailed Description

Temporal addition of images takes a series of image frames and adds them together.

add_Filter is used to add a series of images together and it's behaviour is controlled by the nFrames and frame_step parameters. The filter will alter the workspace only after it has seen enough frames to perform the addition on nFrames given the value of frame_step. There will be ( ( (nFrames - 1 ) * frame_step) + 1 ) frames buffered internally to the filter to facilitate adding nFrames worth of frames with a temporal stepping of frame_step. nFrames must be greater than or equal to two and frame_step must be greater than or equal to one. The constructor and set methods check for this and force correct values.

For example, if nFrames = 3 and frame_step = 3 then the filter will save ((3-1) * 3) + 1 = 7 frames during runtime and will only start writing to the workspace after the 7th frame is seen. Once seven frames have been seen, then frames 0,3,6 will be added. The series of frames to be added will be 1,4,7, then 2,5,8, then 3,6,9, etc. Seven frames are being saved because the Image pointer (which points to the workspace data) is pointing to the 7th buffer and the output at the same time. The 7th frame needs to be saved before the additions take place because the additions are being written out to Image immediately.

Depending on the output format, the values in the pixels will be clipped at the limit of the channel size. The channel size is the number of bytes per channel. In the case of Phission, all images are limited to having channels that are the size of a byte. So all values added up get clipped at 255. Each channel is added to the corresponding channel in the other frames and there is no cross channel addition. To be clear, the channels for an RGB image are Red, Green, and Blue. Each pixel has a range from 0-255 because Phission currently supports only byte sized channels.

Below is what the buffers will look like where the '+' denotes the frames to be added and the value is the temporal index/id of the frame. There are two lines for each iteration to denote the precondition(or before the algorithm is run) and the postcondition which is when the algorithm (or the add_Filter::filter method) has completed execution.

Pre: Buffer = [ x][ x][ x][ x][ x][ x][ x] Image = [ 0]
Post:Buffer = [ 0][ x][ x][ x][ x][ x][ x] Image = [=>0]

Pre: Buffer = [ 0][ x][ x][ x][ x][ x][ x] Image = [ 1]
Post:Buffer = [ 0][ 1][ x][ x][ x][ x][ x] Image = [=>1]

Pre: Buffer = [ 0][ 1][ x][ x][ x][ x][ x] Image = [ 2]
Post:Buffer = [ 0][ 1][ 2][ x][ x][ x][ x] Image = [=>2]

Pre: Buffer = [ 0][ 1][ 2][ x][ x][ x][ x] Image = [ 3]
Post:Buffer = [ 0][ 1][ 2][ 3][ x][ x][ x] Image = [=>3]

Pre: Buffer = [ 0][ 1][ 2][ 3][ x][ x][ x] Image = [ 4]
Post:Buffer = [ 0][ 1][ 2][ 3][ 4][ x][ x] Image = [=>4]

Pre: Buffer = [ 0][ 1][ 2][ 3][ 4][ x][ x] Image = [ 5]
Post:Buffer = [ 0][ 1][ 2][ 3][ 4][ 5][ x] Image = [=>5]

Here is when we start to add frames together given nFrames=3 and frame_step=2:

0+3+6
Pre: Buffer = [ 0][ 1][ 2][ 3][ 4][ 5][ x] Image = [ 6]
Post:Buffer = [+0][ 1][ 2][ +3][ 4][ 5][+6] Image = [ 0+3+6]
1+4+7
Pre: Buffer = [ 0][ 1][ 2][ 3][ 4][ 5][ 6] Image = [ 7]
Post:Buffer = [+7][+1][ 2][ 3][ +4][ 5][ 6] Image = [ 1+4+7]
2+5+8
Pre: Buffer = [ 7][ 1][ 2][ 3][ 4][ 5][ 6] Image = [ 8]
Post:Buffer = [ 7][+8][+2][ 3][ 4][ +5][ 6] Image = [ 2+5+8]
3+6+9
Pre: Buffer = [ 7][ 8][ 2][ 3][ 4][ 5][ 6] Image = [ 9]
Post:Buffer = [ 7][ 8][+9][ +3][ 4][ 5][+6] Image = [ 3+6+9]
4+7+10
Pre: Buffer = [ 7][ 8][ 9][ 3][ 4][ 5][ 6] Image = [ 10]
Post:Buffer = [+7][ 8][ 9][+10][ +4][ 5][ 6] Image = [4+7+10]
5+8+11
Pre: Buffer = [ 7][ 8][ 9][ 10][ 4][ 5][ 6] Image = [ 11]
Post:Buffer = [ 7][+8][ 9][ 10][+11][ +5][ 6] Image = [5+8+11]
6+9+12
Pre: Buffer = [ 7][ 8][ 9][ 10][ 11][ 5][ 6] Image = [ 12]
Post:Buffer = [ 7][ 8][+9][ 10][ 11][+12][+6] Image = [6+9+12]
...

This filter is a generic addition filter but will likely be used with nFrames = 2 and frame_step = 1. This adds 2 consecutive frames together and begins altering the workspace after it has seen 2 frames. These are the default parameters if the add_Filter object is created without passing values to the constructor.

The follow are a couple more examples of which frames will be added and stored:

Example 1

nFrames = 2 , frame_step = 1
Total buffered frames = ((2-1) * 1)+1 = 2

Pre: Buffer = [ x][ x] Image = [ 0]
Post:Buffer = [ 0][ x] Image = [=>0]

Start adding here:
0+1
Pre: Buffer = [ 0][ x] Image = [ 1]
Post:Buffer = [ 0][ 1] Image = [0+1]
1+2
Pre: Buffer = [ 0][ 1] Image = [ 2]
Post:Buffer = [ 2][ 1] Image = [1+2]
2+3
Pre: Buffer = [ 2][ 1] Image = [ 3]
Post:Buffer = [ 2][ 3] Image = [2+3]
...

Example 2

nFrames = 3 , frame_step = 1
Total buffered frames = ((3-1) * 1) + 1 = 3

Pre: Buffer = [ x][ x][ x] Image = [ 0]
Post:Buffer = [ 0][ x][ x] Image = [ =>0]

Pre: Buffer = [ 0][ x][ x] Image = [ 1]
Post:Buffer = [ 0][ 1][ x] Image = [ =>1]

Start adding here:
0+1+2
Pre: Buffer = [ 0][ 1][ x] Image = [ 2]
Post:Buffer = [ 0][ 1][ 2] Image = [0+1+2]
1+2+3
Pre: Buffer = [ 0][ 1][ 2] Image = [ 3]
Post:Buffer = [ 3][ 1][ 2] Image = [1+2+3]
2+3+4
Pre: Buffer = [ 3][ 1][ 2] Image = [ 4]
Post:Buffer = [ 3][ 4][ 2] Image = [2+3+4]
3+4+5
Pre: Buffer = [ 3][ 4][ 2] Image = [ 5]
Post:Buffer = [ 3][ 4][ 5] Image = [3+4+5]
4+5+6
Pre: Buffer = [ 3][ 4][ 5] Image = [ 6]
Post:Buffer = [ 6][ 4][ 5] Image = [4+5+6]
...

Example 3

nFrames = 3 , frame_step = 2
Total buffered frames = ((3-1) * 2) + 1 = 5

Pre: Buffer = [ x][ x][ x][ x][ x] Image = [ 0]
Post:Buffer = [ 0][ x][ x][ x][ x] Image = [ =>0]

Pre: Buffer = [ 0][ x][ x][ x][ x] Image = [ 1]
Post:Buffer = [ 0][ 1][ x][ x][ x] Image = [ =>1]

Pre: Buffer = [ 0][ 1][ x][ x][ x] Image = [ 2]
Post:Buffer = [ 0][ 1][ 2][ x][ x] Image = [ =>2]

Pre: Buffer = [ 0][ 1][ 2][ x][ x] Image = [ 3]
Post:Buffer = [ 0][ 1][ 2][ 3][ x] Image = [ =>3]

Start adding here: 0+2+4
Pre: Buffer = [ 0][ 1][ 2][ 3][ x] Image = [ 4]
Post:Buffer = [+0][ 1][+2][ 3][+4] Image = [0+2+4]
1+3+5
Pre: Buffer = [ 0][ 1][ 2][ 3][ 4] Image = [ 5]
Post:Buffer = [+5][+1][ 2][+3][ 4] Image = [1+3+5]
2+4+6
Pre: Buffer = [ 5][ 1][ 2][ 3][ 4] Image = [ 6]
Post:Buffer = [ 5][+6][+2][ 3][+4] Image = [2+4+6]
3+5+7
Pre: Buffer = [ 5][ 6][ 2][ 3][ 4] Image = [ 7]
Post:Buffer = [+5][ 6][+7][+3][ 4] Image = [3+5+7]
4+6+8
Pre: Buffer = [ 5][ 6][ 7][ 3][ 4] Image = [ 8]
Post:Buffer = [ 5][+6][ 7][+8][+4] Image = [4+6+8]
...

Supports the following formats:

See also:
subtract_Filter | phFilter
Todo:
Merge all temporal filters into a single individual "math" filter that can have a math string or math flag to perform an equation or series of mathmatical operations between temporally different frames

add example application code that shows how the processed images were output

Todo:
explore temporal mean/median/gaussian/etc 4D filtering
Todo:
add example image inputs and processed image outputs

Definition at line 246 of file add_Filter.h.

Public Member Functions

 add_Filter (uint32_t nFrames=2, uint32_t frame_step=1)
 This is the constructor for add_Filter that initializes all the member variables to valid default values.
 ~add_Filter ()
 This is the destructor for add_Filter which frees up m_buffers and m_imgptrs member variables which point to allocated information.
int set (uint32_t nFrames=2, uint32_t frame_step=1)
 This is the 'set' method for the filter that allows changing of the algorithm parameters before or during the filter's runtime.
int flush ()
 This method flushes all the buffers by erasing the values in the buffers.
phFiltercloneFilter ()
 This method returns a newly allocated instance of the add_Filter with the same parameters as the current instance.

Protected Member Functions

int filter ()
 This is overloaded from phFilter and contains the core of the add_Filter's algorithm.

Private Member Functions

int check_buffers (uint32_t alloc=0)
 check_buffers makes sure that the buffers necessary to store all the frames are allocated; It's called from the add_Filter::filter() method to set up for the generic addition algorithm.

Private Attributes

uint32_t m_nFrames
uint32_t m_frame_step
uint32_t m_total_stored
uint32_t m_first_frame_index
uint32_t m_current_frame_index
uint32_t m_frame_elems
uint32_t m_frame_size
uint8_t ** m_imgptrs
uint32_t m_imgptrs_size
uint8_tm_buffer
uint32_t m_buffer_size
uint8_tm_outputBuffer
uint32_t m_outputBuffer_size
uint32_t m_buf_height
uint32_t m_buf_width
uint32_t m_buf_depth
uint32_t m_buf_format
uint32_t m_buf_nframes
uint32_t m_buf_step
uint32_t m_add_nframes


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



Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

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