How to Process Image data when they are at Hex format (for embedded C applications)
Show older comments
I have a matlab code that is intended for embedded hardware. The matlab code is about Image Classification which will be deployed in STM32 (uC, not the Discovery board) using C code generator.
This is the simple block diagram of my architecture:

The image that will be captured by the camera in arduino is at [480, 640] pixels (RGB) which will be saved into the external shared flash memory. Then, the STM32 will retrieve the image in the shared flash memory which are at HEX format (jpg image).
My problem is that how can I process the Hex in my matlab generated C code such that it can resize the image and turn the image into grayscale.
I have found some code related to my problem but it is not intended for code generation in C.
If someone is knowledgeable on this, please help. Thanks!
4 Comments
Walter Roberson
on 13 Feb 2021
It would be more common for shared flash memory to be in binary rather than in hex. Hex implies that it is specifically stored using only the values '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', and 'A' 'B' 'C' 'D' 'E' 'F' or 'a' 'b' 'c' 'd' 'e' 'f' . Each of those characters requires 8 bits to store, whereas binary only requires 4 bits per nibble.
Walter Roberson
on 13 Feb 2021
Whether it is a "jpg image" would need to be cross-checked. It is a possibility. But what people call "jpg image" is really JFIF files (which is a container format) that happen to have a JPEG block inside them, where JPEG blocks are a particular binary format that represents DCT compressed data.
The reason this matters is that sometimes systems just store the JPEG blocks without the JFIF wrapper. It can be important to know which you are working with in order to interpret properly.
Chandler Timm Doloriel
on 13 Feb 2021
Edited: Chandler Timm Doloriel
on 13 Feb 2021
Walter Roberson
on 13 Feb 2021
https://www.file-recovery.com/jpg-signature-format.htm
Write the hex to a file as binary and imread the binary.
There are probably also Java methods.
Answers (0)
Categories
Find more on C2000 Microcontroller Blockset in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!