Discussion:
imread is very slow !
(too old to reply)
Nati Deutsch
2006-12-03 08:25:07 UTC
Permalink
Hello !

I want to read a jpg image and i'm using the function imread. The
problem is that this function is very slow (6 seconds to read a
2448x3264 picture)
Do you know a better function, maybe a file somebody wrote im a mex
format, that have a better performance ?

Thank You
Nati
Jos
2006-12-03 14:26:48 UTC
Permalink
Post by Nati Deutsch
Hello !
I want to read a jpg image and i'm using the function imread. The
problem is that this function is very slow (6 seconds to read a
2448x3264 picture)
Do you know a better function, maybe a file somebody wrote im a mex
format, that have a better performance ?
Thank You
Nati
You can use the matlab MEX file for reading jpg images. It is called
RJPGC and can be found in ..toolbox\matlab\iofun\private
This should remove all the overhead by imread.

Copy it (and rename!) to your work directory and use:
A = myrjpgc('myfile.jpg') ;

hth
Jos
Nati Deutsch
2006-12-03 15:04:27 UTC
Permalink
Post by Jos
Post by Nati Deutsch
Hello !
I want to read a jpg image and i'm using the function imread.
The
Post by Jos
Post by Nati Deutsch
problem is that this function is very slow (6 seconds to read a
2448x3264 picture)
Do you know a better function, maybe a file somebody wrote im a
mex
Post by Nati Deutsch
format, that have a better performance ?
Thank You
Nati
You can use the matlab MEX file for reading jpg images. It is
called
RJPGC and can be found in ..toolbox\matlab\iofun\private
This should remove all the overhead by imread.
A = myrjpgc('myfile.jpg') ;
hth
Jos
O.K
I looked at this directiry at matlab 701
and it does not exist.
maybe you mean ..toolbox\matlab\imagesci\private ??
Nati
Steve Eddins
2006-12-04 13:24:34 UTC
Permalink
Post by Nati Deutsch
Hello !
I want to read a jpg image and i'm using the function imread. The
problem is that this function is very slow (6 seconds to read a
2448x3264 picture)
Do you know a better function, maybe a file somebody wrote im a mex
format, that have a better performance ?
Thank You
Nati
Hmm. It takes about 0.3 seconds on my IBM Thinkpad T60 laptop. About
95% of this time is used by the call to imagesci/private/rjpg8c, which
is a MEX-file that links to the Independent JPEG Group's library.

Try profiling your call; it might help you figure out where the time is
going on your computer.
--
Steve Eddins
http://blogs.mathworks.com/steve
Natan Deutsch
2006-12-04 13:41:38 UTC
Permalink
Post by Nati Deutsch
Hello !
I want to read a jpg image and i'm using the function imread.
The
Post by Nati Deutsch
problem is that this function is very slow (6 seconds to read a
2448x3264 picture)
Do you know a better function, maybe a file somebody wrote im a
mex
Post by Nati Deutsch
format, that have a better performance ?
Thank You
Nati
Hmm. It takes about 0.3 seconds on my IBM Thinkpad T60 laptop.
About
95% of this time is used by the call to imagesci/private/rjpg8c, which
is a MEX-file that links to the Independent JPEG Group's library.
Try profiling your call; it might help you figure out where the time is
going on your computer.
--
Steve Eddins
<http://blogs.mathworks.com/steve>
Thanks about your answer.
I tried it in another computer (2.8 Ghz) and it takes 3 seconds. are
you sure you tried to open 2448 x 3264 image ?

Thanks
Nati
Steve Eddins
2006-12-04 13:55:24 UTC
Permalink
Natan Deutsch wrote:

[SNIP imread performance question]
Post by Natan Deutsch
Thanks about your answer.
I tried it in another computer (2.8 Ghz) and it takes 3 seconds. are
you sure you tried to open 2448 x 3264 image ?
Thanks
Nati
tic, I = imread('bigjpeg.jpg'); toc
Elapsed time is 0.357010 seconds.
Post by Natan Deutsch
imfinfo bigjpeg.jpg
ans =

Filename: 'bigjpeg.jpg'
FileModDate: '04-Dec-2006 08:20:41'
FileSize: 4433017
Format: 'jpg'
FormatVersion: ''
Width: 3264
Height: 2448
BitDepth: 8
ColorType: 'grayscale'
FormatSignature: ''
NumberOfSamples: 1
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
--
Steve Eddins
http://blogs.mathworks.com/steve
Nati Deutsch
2006-12-04 14:33:42 UTC
Permalink
Post by Steve Eddins
[SNIP imread performance question]
Post by Natan Deutsch
Thanks about your answer.
I tried it in another computer (2.8 Ghz) and it takes 3
seconds.
Post by Steve Eddins
are
Post by Natan Deutsch
you sure you tried to open 2448 x 3264 image ?
Thanks
Nati
tic, I = imread('bigjpeg.jpg'); toc
Elapsed time is 0.357010 seconds.
Post by Natan Deutsch
imfinfo bigjpeg.jpg
ans =
Filename: 'bigjpeg.jpg'
FileModDate: '04-Dec-2006 08:20:41'
FileSize: 4433017
Format: 'jpg'
FormatVersion: ''
Width: 3264
Height: 2448
BitDepth: 8
ColorType: 'grayscale'
FormatSignature: ''
NumberOfSamples: 1
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
--
Steve Eddins
<http://blogs.mathworks.com/steve>
O.K my image it rgb one. how much time it takes to open an rgb jpeg
image in that size ?
Thanks
Nati
Steve Eddins
2006-12-04 14:41:57 UTC
Permalink
Post by Nati Deutsch
O.K my image it rgb one. how much time it takes to open an rgb jpeg
image in that size ?
Thanks
Nati
tic, rgb = imread('bigrgbjpeg.jpg'); toc
Elapsed time is 0.648810 seconds.
Post by Nati Deutsch
imfinfo bigrgbjpeg.jpg
ans =

Filename: 'bigrgbjpeg.jpg'
FileModDate: '04-Dec-2006 08:21:28'
FileSize: 4464640
Format: 'jpg'
FormatVersion: ''
Width: 3264
Height: 2448
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
--
Steve Eddins
http://blogs.mathworks.com/steve
J. Luis
2006-12-04 14:58:30 UTC
Permalink
Post by Nati Deutsch
O.K my image it rgb one. how much time it takes to open an rgb jpeg
image in that size ?
Thanks
Nati
ir=uint8(rand(2448,3264,3)*255);
imwrite(ir,'lixo.jpg');

R13Sp1:

tic, I = imread('lixo.jpg'); toc
elapsed_time = 1.2650

imwrite(ir,'lixo.jpg','Quality',100);
tic, I = imread('lixo.jpg'); toc
elapsed_time = 1.5620

R2006b:

imwrite(ir,'lixo.jpg');
tic, I = imread('lixo.jpg'); toc
Elapsed time is 0.797657 seconds.

imwrite(ir,'lixo.jpg','Quality',100);
tic, I = imread('lixo.jpg'); toc
elapsed_time = 0.986032

Pentium M 2GHz

Loading...