![]() |
Leptonica 1.82.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()
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 functions from opj 2.0 to retain file stream interface
static opj_stream_t *opjCreateStream()
[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
---------------------------------------------------
On systems like windows without fmemopen() and open_memstream(),
we write data to a temp file and read it back for operations
between pix and compressed-data, such as pixReadMemJp2k() and
pixWriteMemJp2k().
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.
* This is based on the most recent openjpeg release: 2.1.
* The openjpeg interface was massively changed from 1.X. The debian
distribution is way back at 1.3. We have inquired but are unable
to determine if or when a debian distribution will be built for 2.1.
* For version 2.1, the openjpeg.h file is installed in an
openjpeg-2.1 subdirectory, which is hard to support.
* In openjpeg-2.1, reading is slow compared to jpeg or webp,
and writing is very slow compared to jpeg or webp. This is expected
to improve significantly in future versions.
* Reading and writing jp2k are supported here for 2.1.
The high-level interface to openjpeg continues to change.
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, openjpeg-2.1 provides neither, so we have brought
several static functions over from openjpeg-2.0 in order to
retain the file stream interface. See our static function
opjCreateStream().
* 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.
Definition in file jp2kio.c.