How can I fopen/fwrite into memory, or convert my fread double array
Show older comments
Hi, I am using a parfor loop to read images of jpeg compressed sequences (NorPix .seq).
Each worker fopen's the sequence and then fseek's to a previously specified 'readStart' and fread's the 'imageBufferSize'.
fid = fopen(fileName,'r','b');
fseek(fid,readStart,'bof');
JpegSEQ = fread(fid,imageBufferSize,'uint8','ieee-le');
Afterwards my working solution is to fwrite this 'JpegSEQ' variabe to a temporary jpg file.
tempName = [parallel_ID '_tmp.jpg'];
tempFile = fopen(tempName,'w');
fwrite(tempFile,JpegSEQ);
fclose(tempFile);
I = imread(tempName);
The JpegSEQ/imageBufferSize is variable due to compression (see below). However, fwrite will always generate the correct image dimensions of 420x2048 (WxH). Unfortunately, writing 8 temporary jpg to my HDD simultaneously will result in errors reading frames. If I do
pause(0.01);
after reading the image I can avoid all reading/writing errors, but with less performance.
Therefore, I would need a way to 'fwrite into memory' since this should be faster. Otherwise, I could just convert my JpegSEQ double array to a image of correct size, but reshape would not work due to the different JpegSEQ/imageBufferSize sizes.
readStart imageBufferSize
1028 115458
116494 116032
232534 115383
347925 115535
463468 116119
579595 115892
695495 115766
811269 115810
Does someone know a solution?
3 Comments
OCDER
on 6 Aug 2018
Why can't you use imwrite and imread?
Walter Roberson
on 6 Aug 2018
imread does not handle seq files as far as I recall.
Paul Siefert
on 6 Aug 2018
Accepted Answer
More Answers (0)
Categories
Find more on Large Files and Big Data 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!