Main Content

Compute Negative Image

Create the negative of an image by looking up the opposite pixel values in a table.

For a hardware-compatible design, the model converts the input video to a stream of pixel values. The Frame to Pixels and Pixels to Frame blocks are configured to match the format of the video source.

The Pixel-Stream Lookup Table subsystem contains a Lookup Table block, configured with inversion data. The input pixel data type is uint8, so the negative value is 255 - pixel, or linspace(255,0,256). The output pixel data type is the same as the data type of the table contents, in this case, uint8.

To generate and check the HDL code referenced in this example, you must have an HDL Coder™ license.

To generate the HDL code, use the following command:

makehdl('LookupTableHDL/Pixel-Stream Lookup Table')

To infer a RAM to implement the lookup table, the LUTRegisterResetType property is set to none. To access this property, right-click the Lookup Table block inside the subsystem, and navigate to HDL Coder > HDL Block Properties.

To generate a test bench for the generated HDL code, use the following command:

makehdltb('LookupTableHDL/Pixel-Stream Lookup Table')

See Also

Blocks