Logo Search packages:      
Sourcecode: djvulibre version File versions  Download package

JB2Dict Class Reference

#include <JB2Image.h>

Inheritance diagram for JB2Dict:

GPEnabled JB2Image

List of all members.

Detailed Description

Dictionary of JB2 shapes.

Definition at line 252 of file JB2Image.h.

Public Member Functions

int add_shape (const JB2Shape &shape)
void compress (void)
void decode (const GP< ByteStream > &gbs, JB2DecoderCallback *cb=0, void *arg=0)
void encode (const GP< ByteStream > &gbs) const
int get_count (void) const
unsigned int get_memory_usage (void) const
const JB2Shapeget_shape (const int shapeno) const
JB2Shapeget_shape (const int shapeno)
void init (void)
void set_inherited_dict (const GP< JB2Dict > &dict)
Files #"JB2Image.h"# and #"JB2Image.cpp"# address the compression of bilevel images using the JB2 soft pattern matching scheme. These files provide the complete decoder and the decoder back-end. The JB2 scheme is optimized for images containing a large number of self-similar small components such as characters. Typical text images can be compressed into files 3 to 5 times smaller than with G4/MMR and 2 to 4 times smaller than with JBIG1.

{ JB2 and JBIG2} --- JB2 has strong similarities with the forthcoming JBIG2 standard developed by the "ISO/IEC JTC1 SC29 Working Group 1" which is responsible for both the JPEG and JBIG standards. This is hardly surprising since JB2 was our own proposal for the JBIG2 standard and remained the only proposal for years. The full JBIG2 standard however is significantly more complex and slighlty less efficient than JB2 because it addresses a broader range of applications. Full JBIG2 compliance may be implemented in the future.

{ JB2 Images} --- Class {JB2Image} is the central data structure implemented here. A JB2Image# is composed of an array of shapes and an array of blits. Each shape contains a small bitmap representing an elementary blob of ink, such as a character or a segment of line art. Each blit instructs the decoder to render a particular shape at a specified position in the image. Some compression is already achieved because several blits can refer to the same shape. A shape can also contain a pointer to a parent shape. Additional compression is achieved when both shapes are similar because each shape is encoded using the parent shape as a model. A #"O"# shape for instance could be a parent for both a #"C"# shape and a #"Q"# shape.

{ JB2 Dictionary} --- Class {JB2Dict} is a peculiar kind of JB2Image which only contains an array of shapes. These shapes can be referenced from another JB2Dict/JB2Image. This is arranged by setting the ``inherited dictionary'' of a JB2Dict/JB2Image using function {JB2Dict::set_inherited_dict}. Several JB2Images can use shapes from a same JB2Dict encoded separately. This is how several pages of a same document can share information.

{ Decoding JB2 data} --- The first step for decoding JB2 data consists of creating an empty JB2Image# object. Function {JB2Image::decode} then reads the data and populates the JB2Image# with the shapes and the blits. Function {JB2Image::get_bitmap} finally produces an anti-aliased image.

{ Encoding JB2 data} --- The first step for decoding JB2 data also consists of creating an empty JB2Image# object. You must then use functions {JB2Image::add_shape} and {JB2Image::add_blit} to populate the JB2Image# object. Function {JB2Image::encode} finally produces the JB2 data. Function encode# sequentially encodes the blits and the necessary shapes. The compression ratio depends on several factors: {itemize} Blits should reuse shapes as often as possible. Blits should be sorted in reading order because this facilitates the prediction of the blit coordinates. Shapes should be sorted according to the order of first appearance in the sequence of blits because this facilitates the prediction of the shape indices. Shapes should be compared to all previous shapes in the shape array. The shape parent pointer should be set to a suitable parent shape if such a parent shape exists. The parent shape should have almost the same size and the same pixels. {itemize} All this is quite easy to achieve in the case of an electronically produced document such as a DVI file or a PS file: we know what the characters are and where they are located. If you only have a scanned image however you must first locate the characters (connected component analysis) and cut the remaining pieces of ink into smaller blobs. Ordering the blits and matching the shapes is then an essentially heuristic process. Although the quality of the heuristics substantially effects the file size, misordering blits or mismatching shapes never effects the quality of the image. The last refinement consists in smoothing the shapes in order to reduce the noise and maximize the similarities between shapes.

{ JB2 extensions} --- Two extensions of the JB2 encoding format have been introduced with DjVu files version 21. The first extension addresses the shared shape dictionaries. The second extension bounds the number of probability contexts used for coding numbers. Both extensions maintain backward compatibility with JB2 as described in the ICFDD proposal. A more complete discussion can be found in section {JB2 extensions for version 21.}.

{ References} {itemize} Paul G. Howard : {Text image compression using soft pattern matching}, Computer Journal, volume 40:2/3, 1997. JBIG1 : {http://www.jpeg.org/public/jbighomepage.htm}. JBIG2 draft : {http://www.jpeg.org/public/jbigpt2.htm}. ICFDD Draft Proposed American National Standard, 1999-08-26. {itemize}

JB2Image.h,v 1.13 2008/01/27 11:36:27 leonb Exp
# Coding bilevel images with JB2.
Paul Howard <pgh@research.att.com> -- JB2 design\ L\'eon Bottou <leonb@research.att.com> -- this implementation
From: Leon Bottou, 1/31/2002 Lizardtech has split the corresponding cpp file into a decoder and an encoder. Only superficial changes. The meat is mine.

GP< JB2Dictget_inherited_dict (void) const
int get_inherited_shape_count (void) const
int get_shape_count (void) const

Static Public Member Functions

static GP< JB2Dictcreate (void)

Public Attributes

GUTF8String comment

Protected Attributes

volatile int count
 The reference counter.

Private Member Functions

void get_bounding_box (int shapeno, LibRect &dest)

Private Attributes

GTArray< LibRect > boxes
GP< JB2Dictinherited_dict
int inherited_shapes
GArray< JB2Shapeshapes


class  JB2Codec
struct  LibRect

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index