This session demonstrates how to perform a ‘Brightness scaling’ of a Colour image in AMD Ryzen AI Phoenix using AIE DIALECTS and AIE API
RequirementsAMD Ryzen AI Phoenix.
Linux® based development environment
Python® (for test automation and result validation)
IRON API and MLIR-based AI Engine Toolchain
OpenCV (Open Source Computer Vision Library)
Project BriefThe SOC is designed to accelerate the AIE-ML algorithms to deliver a good, exceptional performance. The NPU complex has
- 16 AI Cores for computation
- 4 Memory Tiles for fast memory access
- 4 SHIM DMA to Move data in and out of L3 Memory
Note: This project is customized for Phoenix.
Features covered in this session“How to write a kernel for ‘Brightness scaling’ of a Colour image?”
ArchitectureBrightness scaling of a colour Image
Brightness scaling in image processing, typically ranging from 0 (black) to 255 (white) for 8-bit images, are used to adjust, enhance, and analyze image intensity. Key applications include changing image exposure (lightening/darkening), enhancing contrast, correcting, and normalizing images for improved visualization, machine learning, or surveillance.
- Image Enhancement: Adjusting the brightness scale allows for fixing under- or over-exposed images, making details in shadows or highlights visible.
- Contrast Adjustment: By stretching or shrinking the brightness range (histogram stretching), the distinction between objects can be improved.
- Gamma Correction: Using a logarithmic brightness scale helps adjust images based on human visual perception, rather than just linear, physical light changes.
- Normalization and Preprocessing: Normalizing brightness is crucial in machine learning, particularly for training Convolutional Neural Networks (CNNs), to ensure consistent input data.
In this section, SHIM DMA(0, 0), MEM Tile (0, 1), Core(0, 2) for R, Core(0, 3) for G, and Core(0, 4) for B of column 0 are used. A 1920x1080 8-bit image is sent from L3 Memory to the MEM Tile row by row of R, G, and B.
Data Flow for Computation
The core then calculates the brightness scaling of each pixel and then routes the converted pixels back to L3 memory.
How to Build and RunTo compile the placed design:
env use_placed=1 make
make dataflow_graph.exeTo run the design:
./dataflow_graph.exe -x build/final_1920.xclbin -i build/insts.bin -k MLIR_AIE --image input_image.jpgInput images
Output images
https://www.hackster.io/541340/amd-ryzen-ai-npu-tool-chain-installation-and-execution-b252fa
ConclusionThis session demonstrates how to use the “IRON API and MLIR-based AI Engine Toolchain” and “AIE API” to write a kernel to perform the “Brightness scaling of a coloured image”.








Comments