how to input to "imread" using uint8 vector that is equivalent to binary data of image file from fread
6 ビュー (過去 30 日間)
古いコメントを表示
Hi, I am trying to read many 512x512 jpg files that extracted from a .db database as uint8 vector for each file.
The vector is not the pixel intensity matrix, but exactly the binary data of file. So I need to fwrite the vector into a temp jpg file to hard disk, then imread that file as matrix in memory.
Because the number of jpg can be hundreds of thousands, so the frequent io from hard disc make the process very slow.
Is there a way to "recognize" the uint8 vector as if it is on the hard drive, then read it as a image file into imread?
Thanks.
0 件のコメント
採用された回答
Walter Roberson
2020 年 8 月 4 日
For jpeg in particular, imread() invokes a function that calls upon a .mex* file to do the reading. It is likely that the file invokes libjpeg .
I believe that there is a route to do what you want by using Java. Java permits defining a Java.io.FileInputStream from memory (Byte array), and ImageIO.read() can be used to read images from FileInputStream .
I do not have any code that puts all this together; I have not used Java much.
その他の回答 (1 件)
Image Analyst
2020 年 8 月 4 日
Of course imread() will "recognize" the image file on disk as a uint8 jpg image if you got it written out properly. I don't know of anyway to decompress a JPG array that's in binary in memory so writing it out to disk to read back in may be the way you need to do it. If that's too slow, you can use solid state drive instead of a hard drive. Exactly how slow is it? For me, it typically takes less than a second to read in an image from my SSD.
4 件のコメント
Image Analyst
2020 年 8 月 4 日
You can put it in as a suggestion but I think it would rarely be used by others so it probably will never rise to the top of the priority list. In over 40 years of image processing I've never had to do that.
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!