The LineBuffer class implements the line buffer structure that is commonly
seen in image convolution (filtering) operations, where a filter kernel is "slided" over an
input image and is applied on a local window (e.g., a square) of pixels at every sliding
location. As the filter is slided across the image, the line buffer is fed with a new pixel
at every new sliding location while retaining the pixels of the previous image rows that
can be covered for the sliding window. The public interface of the
LineBuffer class is shown below,
Below shows an example usage of the LineBuffer class:
Instantiate the line buffer in your C++
code, with template arguments being the pixel data type, input image width, and sliding
window size. The window maintained by the line buffer assumes a square
WindowSize x WindowSize window. If you are instantiating the line
buffer inside a pipelined function (accepting a new pixel in every function call), you
will need to add 'static' to make the line buffer
static.
Shift in a new pixel by calling the
ShiftInPixel
method:
line_buffer.ShiftInPixel(input_pixel);
Then your filter can access any pixels
in the window
by:
line_buffer.window[i][j]
The figure below illustrates how the line buffer window is being updated
after each call of ShiftInPixel. You will notice that the window
can contain out-of-bound pixels at certain sliding locations.