You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today, I profiled opj_decompress on Windows and Linux and mentioned that it's 3x slower on Windows. After a deeper look (for which I had to add some printfs and compile opj_decompress.exe), I realized that imagetopnm takes 165ms, while decompressor just 62ms:
$ time -p bin/opj_decompress.exe -i lala.jp2 -o lala2.pgm
load image + initialize: 0.390500 ms
[INFO] Start to read j2k main header (85).
[INFO] Main header has been correctly decoded.
[INFO] No decoded area parameters, set the decoded area to the whole image
[INFO] Header of tile 1 / 1 has been read.
[INFO] Stream reached its end !
[INFO] Generated Outfile lala2.pgm
imagetopnm: 164.228699 ms
decode time: 62 ms
total time: 228.419403 ms
real 0.28
user 0.00
sys 0.01
The reason for this is the fact that imagetopng calls fprintf for every pixel. For text-based variants (such as P2), it could be justified, but for binary PGM (P5), it can be way faster.
My quick and dirty experiment, where I just generate the output array for a 16-bit PGM in a loop (shuffling the bytes, so that they are in bigendian mode, as required for PGM) and then call a single fwrite, the time for imagetopnm goes down to ~7 ms.
Would you be open for a patch that will have a (much) faster path for saving binary PGM files?
I will be totally cool to work on that, but would appreciate an early signal that this is an acceptable approach.
Thank you in advance,
Ivan Krasin
The text was updated successfully, but these errors were encountered:
Hi there,
Thank you for maintaining OpenJPEG!
Today, I profiled opj_decompress on Windows and Linux and mentioned that it's 3x slower on Windows. After a deeper look (for which I had to add some printfs and compile opj_decompress.exe), I realized that imagetopnm takes 165ms, while decompressor just 62ms:
The reason for this is the fact that imagetopng calls fprintf for every pixel. For text-based variants (such as P2), it could be justified, but for binary PGM (P5), it can be way faster.
My quick and dirty experiment, where I just generate the output array for a 16-bit PGM in a loop (shuffling the bytes, so that they are in bigendian mode, as required for PGM) and then call a single fwrite, the time for imagetopnm goes down to ~7 ms.
Would you be open for a patch that will have a (much) faster path for saving binary PGM files?
I will be totally cool to work on that, but would appreciate an early signal that this is an acceptable approach.
Thank you in advance,
Ivan Krasin
The text was updated successfully, but these errors were encountered: