Main Content

Line Buffer

Store video lines and return neighborhood pixels

  • Library:
  • Vision HDL Toolbox / Utilities

  • Line Buffer block

Description

The Line Buffer block selects neighborhood pixels from streaming image data. It handles video control signals and edge padding, and is pipelined for high-speed video designs. The block outputs one column of the neighborhood at a time. To compose a neighborhood for further processing, use the shiftEnable signal to store the output columns, including padding, in a shift register. This block allows you to share the line buffer resources when your design performs multiple operations on the same neighborhood.

The following waveform shows the Line Buffer block returning 5-by-1 pixel columns that make up a 5-by-5 neighborhood. The time frame shown is at the beginning (top-left corner) of an input frame. The output starts after the block has stored two (floor(M/2)) lines and is receiving the start of the third line. The shiftEnable signal is asserted two cycles earlier than the output ctrl.valid signal, which indicates that the first two (floor(M/2)) columns are exclusively padding pixels. Similarly, shiftEnable stays high for two extra cycles at the end of the line.

Ports

This block uses a streaming pixel interface with a bus for frame control signals. This interface enables the block to operate independently of image size and format. The pixel ports on this block support single pixel streaming or multipixel streaming. Single pixel streaming accepts and returns a single pixel value each clock cycle. Multipixel streaming accepts and returns 4 or 8 pixels per clock cycle to support high-frame-rate or high-resolution formats. Along with the pixel, the block accepts and returns a pixelcontrol bus that contains five control signals. The control signals indicate the validity of each pixel and their location in the frame. For multipixel streaming, one set of control signals applies to all four or eight pixels in the vector. To convert a frame (pixel matrix) into a serial pixel stream and control signals, use the Frame To Pixels block. For a full description of the interface, see Streaming Pixel Interface.

Input

expand all

This block supports single pixel streaming or multipixel streaming. For single pixel streaming, specify a single input pixel as a scalar intensity value. For multipixel streaming, specify a vector of four or eight pixel intensity values. For details of how to set up your model for multipixel streaming, see Filter Multipixel Video Streams.

This block does not support multicomponent streaming. To process multicomponent streams, replicate the block for each component. The pixelcontrol bus for all components is identical, so you can connect a single bus to multiple replicated blocks.

double and single data types are supported for simulation, but not for HDL code generation.

Data Types: uint8 | uint16 | uint32 | int8 | int16 | int32 | fixed point | Boolean | double | single

Specify a pixelcontrol bus that contains five signals. The signals describe the validity of the pixel and its location in the frame. For more information, see Pixel Control Bus.

For multipixel streaming, each vector of pixel values has one set of control signals. Because the vector has only one valid signal, the pixels in the vector must be either all valid or all invalid. The hStart and vStart signals apply to the pixel with the lowest index in the vector. The hEnd and vEnd signals apply to the pixel with the highest index in the vector.

Data Types: bus

Output

expand all

Column of neighborhood pixel values, returned as a of 1-by-M vector, where M is the vertical neighborhood dimension. When using multipixel streaming, the block returns a NumberOfPixels-by-M matrix, where NumberOfPixels is the size of the input pixel vector. The output pixel data type is the same as the data type of the input pixels.

To compose a neighborhood for further processing, use the shiftEnable signal to store the output columns for each kernel region, including padding, in a shift register. For multipixel streaming, use shift registers to construct NumberOfPixels regions, each of N-by-M pixels, and then perform the kernel operation NumberOfPixels times in parallel.

Note

HDL code generation is supported for small matrices, but matrix operations can impact hardware performance and resource usage. Therefore, minimize how much your design operates on an N-by-M neighborhood directly. You can :

  • Separate a filter into vertical and horizontal components.

  • Concatenate the neighborhood pixels into an (N*M)-by-1 vector.

  • Use a For Each subsystem to store and operate on each pixel row.

These design suggestions provide opportunities to add pipelining around each adder or multiplier to increase synthesized clock speed and fit the design to DSP blocks on an FPGA.

Data Types: int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | double | single

Control signals accompanying the output column, returned as a pixelcontrol bus containing five signals. The signals describe the validity of the center pixel of the column, and the location of that pixel within the frame. See Pixel Control Bus.

Columns that contain only padding pixels do not assert ctrl.valid. The shiftEnable signal is asserted for both padding and active columns.

Note

For most of the frame, the block returns the input control signals that arrived with the bottom pixel of the column. However, for the final floor(M/2) lines of each frame, the bottom pixel of the column is a padding pixel, so the block generates output control signals. The block generates a contiguously asserted ctrl.valid signal for the valid pixels in each line.

For multipixel streaming, there is one set of control signals for each vector of pixel values. Since there is only one valid signal for the vector, the pixels in the vector are either all valid or all invalid. The hStart and vStart signals apply to the pixel with the lowest index in the vector. The hEnd and vEnd signals apply to the pixel with the highest index in the vector.

Data Types: bus

Valid signal for neighborhood columns, returned as a Boolean scalar. Use this signal to control a shift register that composes a neighborhood from the output columns. This signal is true (1) for any neighborhood column, indicating that the column contains valid image pixels or that the column was added for edge padding.

Data Types: Boolean

Parameters

expand all

Size of output neighborhood to be formed, specified as a 2-element row vector of integer dimensions [vertical horizontal]. The block returns a column vector of vertical elements. The horizontal dimension is used to determine padding.

Select one of these methods for padding the boundary of the input image. For more information about these methods, see Edge Padding.

  • Constant — Interpret pixels outside the image frame as having a constant value.

  • Replicate — Repeat the value of pixels at the edge of the image.

  • Symmetric — Set the value of the padding pixels to mirror the edge of the image.

  • None — Exclude padding logic. The block does not set the pixels outside the image frame to any particular value. This option reduces the hardware resources used by the block and the blanking required between frames but affects the accuracy of the output pixels at the edges of the frame. To maintain pixel stream timing, the output frame is the same size as the input frame. However, to avoid using pixels calculated from undefined padding values, mask off the KernelSize/2 pixels around the edge of the frame for downstream operations. For details, see Increase Throughput with Padding None.

Specify an integer to pad the boundary of the input image. The block casts this value to the same data type as the input pixel.

Dependencies

To enable this parameter, set the Padding method parameter to Constant.

Specify a power of two that accommodates the number of active pixels in a single horizontal line.

If you specify a value that is not a power of two, the block uses the next largest power of two.

Algorithms

expand all

The block stores M – 1 lines of valid pixels, as specified by the neighborhood size. It adds padding bits at the edge of the frame. The block returns the first output column once it can form a complete neighborhood column, which occurs at the start of input line floor(M/2).

Extended Capabilities

Introduced in R2017b