m by 1 array of uint8 data to image
Show older comments
I want to display an image from my device. Currently i can read in the image using binblockread of type unit8 and print the image to a fie using fwrite and it displays fine.
However, I would like to display the image in MATLAB first for a user prompt i'm developing. The array is read into MATLAB as an m by 1 array ranging from 0 to 255. I have tried imshow, imagesc, and image. As well as playing with the different parameters but nothing wants to take.
Perhaps someone could help. I have attached the array I am reading into to matlab. THis is the same array i'm using to print to my .gif file.
5 Comments
Geoff Hayes
on 1 Mar 2016
Jason - you didn't attach your array file. Once you have chosen the file, you must press the Attach File button.
Walter Roberson
on 2 Mar 2016
Is the data being read already in image file format? You mention it looking fine when you fwrite it, and fwrite does not add image file headers, suggesting that the data is already an image file.
If the data is already an image file, really the easiest thing to do is write it to disk and read it with imread() if you want to display it.
Jason Allnutt
on 2 Mar 2016
Edited: Jason Allnutt
on 2 Mar 2016
Walter Roberson
on 2 Mar 2016
Looking at that code, Yes, what you are receiving must already be in image file format. If you were to hunt around long enough you could probably find a Java or library that could accept an array of bytes that is the image file data, and which would decode the image file data into the pixel arrays so that you could display them... but it would be easier to write the file and read it with imread()
Jason Allnutt
on 2 Mar 2016
Accepted Answer
More Answers (0)
Categories
Find more on Convert Image Type 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!