![]() |
Leptonica 1.85.0
Image processing and image analysis suite
|
#include <string.h>#include "allheaders.h"Go to the source code of this file.
Read jp2k from file
PIX *pixReadJp2k() [special top level]
PIX *pixReadStreamJp2k()
static PIX *pixReadMemJp2kCore()
Write jp2k to file
l_int32 pixWriteJp2k() [special top level]
l_int32 pixWriteStreamJp2k()
static opj_image_t *pixConvertToOpjImage()
Read/write to memory
PIX *pixReadMemJp2k()
l_int32 pixWriteMemJp2k()
Static generator of opj_stream from a memory buffer
static opj_stream_t *opjCreateMemoryStream()
[and other static helpers]
Static generator of opj_stream fom a file stream
static opj_stream_t *opjCreateStream()
[and other static helpers]
Based on the OpenJPEG distribution:
http://www.openjpeg.org/
The ISO/IEC reference for jpeg2000 is:
http://www.jpeg.org/public/15444-1annexi.pdf
Compressing to memory and decompressing from memory
---------------------------------------------------
In previous versions, for systems like Windows that do not have
fmemopen() and open_memstream(), we wrote data to a temp file.
Now thanks to the contribution of Anton Tykhyy, we use the
opj_stream interface directly for operations to and from memory.
The file stream interface for these operations is a wrapper
around the memory interface.
Pdf can accept jp2k compressed strings directly
-----------------------------------------------
Transcoding (with the uncompress/compress cycle) is not required
to wrap images that have already been compressed with jp2k in pdf,
because the pdf format for jp2k includes the full string of the
jp2k compressed images. This is also true for jpeg compressed
strings.
N.B.
* Reading and writing jp2k are supported here for releases 2.1 and later.
* The openjpeg.h file is installed in an openjpeg-2.X subdirectory.
* In openjpeg-2.X, reading is slow compared to jpeg or webp,
and writing is very slow compared to jpeg or webp.
* Specifying a quality factor for jpeg2000 requires caution. Unlike
jpeg and webp, which have a sensible scale that goes from 0 (very poor)
to 100 (nearly lossless), kakadu and openjpeg use idiosyncratic and
non-intuitive numbers. kakadu uses "rate/distortion" numbers in
a narrow range around 50,000; openjpeg (and our write interface)
use SNR. The visually apparent artifacts introduced by compression
are strongly content-dependent and vary in a highly non-linear
way with SNR. We take SNR = 34 as default, roughly similar in
quality to jpeg's default standard of 75. For document images,
SNR = 25 is very poor, whereas SNR = 45 is nearly lossless. If you
use the latter, you will pay dearly in the size of the compressed file.
* The openjpeg interface was massively changed from 1.X to 2.0.
There were also changes from 2.0 to 2.1. From 2.0 to 2.1, the
ability to interface to a C file stream was removed permanently.
Leptonica supports both file stream and memory buffer interfaces
for every image I/O library, and it requires the libraries to
support at least one of these. However, because openjpeg-2.1+ provides
neither, we have brought several static functions over from
openjpeg-2.0 in order to retain the file stream interface.
See, for example, our static function opjCreateStream().
Definition in file jp2kio.c.