How to Process Image data when they are at Hex format (for embedded C applications)

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

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.
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.
@Walter Roberson Hi Sir. Thanks for your input. Let's say I saved the image in shared flash memory as a Hex (8-bit) and a real jpeg image which starts at 0xFF, 0xD8 and ends at 0xFF, 0xD9. How can then I use this data to be processed in matlab? for resizing to [32, 32] pixels and turning into greyscale.
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.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!