one of the solutions
- use low-level i/o functions
fp=fopen('football.jpg','rb');
if fp > 0
ibin=fread(fp,inf,'*uint8');
fclose(fp);
whos ibin;
%{
Name Size Bytes Class Attributes
ibin 27130x1 27130 uint8
%}
end
us
Many thanks - that's exactly what I wanted! A secondary question if I may: - having read the data from the file using
ibin=fread(...);
if I wanted to display the image in ibn, is there a way of doing this without having to first save the data into a file using imwrite? In other words, can I extract the data in my variable A (A=imread('football.jpg')) from the data in ibn without first saving ibn back into a JPEG file? I've tried
imread (ibn);
but that doesn't work.
Many thanks.
obviously, nothing of the above will work since you simply slurped byte by byte without any decoding of the information...
us
A quick skim though imread to see if anything could be re-used didn't look too promising either.
Thanks guys - I guess I will just have to write the data back to a file and read it back to display:
fid=fopen('myfile.jpg','wb');
fwrite(fid,ibin);
fclose(fid);
A=imread('myfile.jpg');
imshow(A);
As I have to do this several times, I was hoping to avoid the repeated file write and read, but seems that can't be helped.
Thanks all the same.
"Bobane" <boba...@hotmail.com> wrote in message <hvd6e8$k1o$1...@fred.mathworks.com>...
Matlab does not provide any documented mechanism to display JPEG
byte-steams that are in memory.
You can probably find a Java JPEG displayer and edit it to accept byte
streams.
MATLAB does not provide any undocumented mechanism, either. :-)
---
Steve Eddins
http://blogs.mathworks.com/steve/
Sometimes it would be useful if Matlab provided a way to "fopen" a memory
buffer and do I/O operations on it. This is similar in some ways to mmap'ing a
file, except that no disk store would be used.
For writing, probably the first version should return a write error if the end
of the buffer was reached; extending the memory might perhaps not be the most
consistent behaviour... ah, unless perhaps the extended buffer became an
additional (optional) output argument.
Amongst other things, it would be useful if writing a plot (e.g., saveas,
imwrite) could be done to memory; likewise for audio files and for movies.