How can i get viewable jpeg image from hex file ???
2 views (last 30 days)
Show older comments
bejaoui sawssen
on 1 Jul 2016
Edited: Chandler Timm Doloriel
on 30 Mar 2022
Hi all, i captured image with camera on arduino and i send it to PC over Xbee, I get a file wich contain "FF D8 FF E0 00 .. .. .. .. D4 FF D9 " , now i want to reconstruct the original image, how can i proceed ??
0 Comments
Accepted Answer
Walter Roberson
on 1 Jul 2016
YourFilename = 'AppropriateFileName.txt';
converted_file = uint8( sscanf( fileread(YourFileName) , '%2x') );
Now you should reshape() converted_file to have the appropriate number of rows and columns and color planes.
Depending on the order in which the values were sent, you might need to use permute() to rearrange the data into a color array suitable for displaying.
3 Comments
Walter Roberson
on 1 Jul 2016
You are being sent the content of a JPEG file, not the image data directly.
fid = fopen('AppropriateFileName.jpg', 'w');
fwrite(fid, converted_file, 'uint8');
fclose(fid);
Now you can examine the contents with any convenient image viewer, or you can
YourImage = imread('AppropriateFileName.jpg');
Looking at the image, it appears that you were sent a partial version of lena.jpg with most of it missing.
Chandler Timm Doloriel
on 30 Mar 2022
Edited: Chandler Timm Doloriel
on 30 Mar 2022
@Walter Roberson This may be super late. But how can I do the same without using fopen, fwrite, fclose?
After it reads the converted_file ,it should show the RGB888 values without using fopen, fwrite, fclose? Is there other way?
More Answers (1)
bejaoui sawssen
on 13 Jul 2016
1 Comment
Walter Roberson
on 13 Jul 2016
I have no assistance to offer for the facial recognition part.
For the transmission of the file, there are various ways. If you have a perfectly reliable transfer mechanism then the easiest way is to first send a count of the number of bytes in the file and then send the bytes. Or always send the same number of bytes. If you do not have a perfectly reliable transfer mechanism then there have been a lot of different ways developed over the years, including XModem, YModel, ZModem, Kermit; or running using the serial line to run an IP protocol layer by using SLIP or PPP, and then using something like rcp or ftp over top of that.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!