⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 overview of the j2000 coder-decoder modules.htm

📁 The J2000 codec was written in an effort to produce the cleanest and simplest implementation possibl
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0106)http://www.j2000.org/cgi-bin/viewcvs.cgi/*checkout*/j2k/docs/overview.html?rev=HEAD&content-type=text/html -->
<HTML><HEAD><TITLE>Overview of the J2000 coder/decoder modules</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1458" name=GENERATOR></HEAD>
<BODY>
<H1>Overview of the J2000 coder/decoder modules</H1>
<OL>
  <H3>
  <LI>Introduction</H3>The implementation of the JPEG-2000 encoder and decoder 
  is divided into several modules. The modules are: 
  <UL>
    <LI>J2K: implements a JPEG-2000 codestream reader/writer 
    <LI>TCD: implements a tile coder/decoder 
    <LI>MCT: implements multi-component transforms 
    <LI>DWT: implements a discrete wavelet transform 
    <LI>T1: implements tier-1 coding (coding of code-block coefficients) 
    <LI>MQC: implements an MQ-Coder 
    <LI>T2: implements tier-2 coding (packetization of code-block data) 
    <LI>PI: implements a packet iterator 
    <LI>TGT: implements a tag-tree coder 
    <LI>BIO: implements individual bit input-output 
    <LI>CIO: implements byte input-output 
    <LI>INT: implements operations on integers </LI></UL>Each module is used both 
  by the encoder and the decoder. For every encoding operations implemented by a 
  module, there is a corresponding decoding operation implemented in the same 
  module. The following diagram shows the "use" hierarchy that structures the 
  modules.<BR><IMG 
  src="Overview of the J2000 coder-decoder modules.files/use.gif"><BR>
  <H3>
  <LI>The JPEG-2000 Codestream Reader/Writer (J2K)</H3>The J2K module provides 
  functions for encoding and decoding JPEG-2000 codestreams. This module is 
  typically used by programs that convert specific image formats to/from 
  JPEG-2000 codestreams. The j2ktopgx and pgxtoj2k programs provide examples of 
  usage of the J2K module. <PRE><FONT color=#0000ff>/*</FONT><FONT color=#0000ff> </FONT>
<FONT color=#0000ff> * Encode an image into a JPEG-2000 codestream</FONT>
<FONT color=#0000ff> * i: image to encode</FONT>
<FONT color=#0000ff> * cp: coding parameters</FONT>
<FONT color=#0000ff> * dest: destination buffer</FONT>
<FONT color=#0000ff> * len: length of destination buffer</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>int</B></FONT> j2k_encode(j2k_image_t *i, j2k_cp_t *cp, <FONT color=#2e8b57><B>unsigned</B></FONT> <FONT color=#2e8b57><B>char</B></FONT> *dest, <FONT color=#2e8b57><B>int</B></FONT> len);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Decode an image from a JPEG-2000 codestream</FONT>
<FONT color=#0000ff> * src: source buffer</FONT>
<FONT color=#0000ff> * len: length of source buffer</FONT>
<FONT color=#0000ff> * i: decode image</FONT>
<FONT color=#0000ff> * cp: coding parameters that were used to encode the image</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>int</B></FONT> j2k_decode(<FONT color=#2e8b57><B>unsigned</B></FONT> <FONT color=#2e8b57><B>char</B></FONT> *src, <FONT color=#2e8b57><B>int</B></FONT> len, j2k_image_t **i, j2k_cp_t **cp);
</PRE>The j2k_image_t and j2k_comp_t data-structures are used to describe raw 
  images that are to be encoded or that were decoded: <PRE><FONT color=#2e8b57><B>typedef</B></FONT> <FONT color=#2e8b57><B>struct</B></FONT> {
    <FONT color=#2e8b57><B>int</B></FONT> dx, dy; <FONT color=#0000ff>// XRsiz, YRsiz</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> prec; <FONT color=#0000ff>// precision</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> sgnd; <FONT color=#0000ff>// signed</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> *data; <FONT color=#0000ff>// image-component data</FONT>
} j2k_comp_t;

<FONT color=#2e8b57><B>typedef</B></FONT> <FONT color=#2e8b57><B>struct</B></FONT> {
    <FONT color=#2e8b57><B>int</B></FONT> x0, y0; <FONT color=#0000ff>// XOsiz, YOsiz</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> x1, y1; <FONT color=#0000ff>// Xsiz, Ysiz </FONT>
    <FONT color=#2e8b57><B>int</B></FONT> numcomps; <FONT color=#0000ff>// number of components</FONT>
    j2k_comp_t *comps; <FONT color=#0000ff>// image-components</FONT>
} j2k_image_t;
</PRE>The following data-structures are used to describe the JPEG-2000 coding 
  parameters. The image coding parameters are divided in tile coding parameters, 
  that can be different for each tile. For each component in the image and for 
  each tile, there are tile-component coding parameters. The meaning of those 
  parameters is described in detail in the JPEG-2000 standard: <PRE><FONT color=#2e8b57><B>typedef</B></FONT> <FONT color=#2e8b57><B>struct</B></FONT> {
    <FONT color=#2e8b57><B>int</B></FONT> expn; <FONT color=#0000ff>// exponent</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> mant; <FONT color=#0000ff>// mantissa</FONT>
} j2k_stepsize_t;

<FONT color=#2e8b57><B>typedef</B></FONT> <FONT color=#2e8b57><B>struct</B></FONT> {
    <FONT color=#2e8b57><B>int</B></FONT> csty; <FONT color=#0000ff>// coding style</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> numresolutions; <FONT color=#0000ff>// number of resolutions</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> cblkw; <FONT color=#0000ff>// width of code-blocks</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> cblkh; <FONT color=#0000ff>// height of code-blocks</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> cblksty; <FONT color=#0000ff>// code-block coding style</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> qmfbid; <FONT color=#0000ff>// discrete wavelet transform identifier</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> qntsty; <FONT color=#0000ff>// quantisation style</FONT>
    j2k_stepsize_t stepsizes[J2K_MAXBANDS]; <FONT color=#0000ff>// stepsizes used for quantisation</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> numgbits; <FONT color=#0000ff>// number of guard bits</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> roishift; <FONT color=#0000ff>// Region Of Interest shift</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> prcw[J2K_MAXRLVLS]; <FONT color=#0000ff>// Precinct width</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> prch[J2K_MAXRLVLS]; <FONT color=#0000ff>// Precinct height</FONT>
} j2k_tccp_t;

<FONT color=#2e8b57><B>typedef</B></FONT> <FONT color=#2e8b57><B>struct</B></FONT> {
    <FONT color=#2e8b57><B>int</B></FONT> resno0, compno0;
    <FONT color=#2e8b57><B>int</B></FONT> layno1, resno1, compno1;
    <FONT color=#2e8b57><B>int</B></FONT> prg;
} j2k_poc_t;

<FONT color=#2e8b57><B>typedef</B></FONT> <FONT color=#2e8b57><B>struct</B></FONT> {
    <FONT color=#2e8b57><B>int</B></FONT> csty; <FONT color=#0000ff>// coding style  </FONT>
    <FONT color=#2e8b57><B>int</B></FONT> prg; <FONT color=#0000ff>// progression order</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> numlayers; <FONT color=#0000ff>// number of layers</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> mct; <FONT color=#0000ff>// multi-component transform identifier</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> rates[<FONT color=#ff00ff>32</FONT>]; <FONT color=#0000ff>// rates of layers</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> numpocs; <FONT color=#0000ff>// number of progression order changes </FONT>
    j2k_poc_t pocs[<FONT color=#ff00ff>32</FONT>]; <FONT color=#0000ff>// progression order changes</FONT>
    j2k_tccp_t *tccps; <FONT color=#0000ff>// tile-component coding parameters</FONT>
} j2k_tcp_t;

<FONT color=#2e8b57><B>typedef</B></FONT> <FONT color=#2e8b57><B>struct</B></FONT> {
    <FONT color=#2e8b57><B>int</B></FONT> tx0, ty0; <FONT color=#0000ff>// XTOsiz, YTOsiz</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> tdx, tdy; <FONT color=#0000ff>// XTsiz, YTsiz</FONT>
    <FONT color=#2e8b57><B>int</B></FONT> tw, th;
    j2k_tcp_t *tcps; <FONT color=#0000ff>// tile coding parameters</FONT>
} j2k_cp_t;
</PRE>
  <H3>
  <LI>The Tile Coder/Decoder (TCD)</H3>The Tile Coder/Decoder is used to process 
  individual tiles of the image. The TCD module is used by the J2K module. <PRE><FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Initialize the tile coder/decoder</FONT>
<FONT color=#0000ff> * img: raw image</FONT>
<FONT color=#0000ff> * cp: coding parameters</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> tcd_init(j2k_image_t *img, j2k_cp_t *cp);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Encode a tile from the raw image into a buffer</FONT>
<FONT color=#0000ff> * tileno: number that identifies one of the tiles to be encoded</FONT>
<FONT color=#0000ff> * dest: destination buffer</FONT>
<FONT color=#0000ff> * len: length of destination buffer</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>int</B></FONT> tcd_encode_tile(<FONT color=#2e8b57><B>int</B></FONT> tileno, <FONT color=#2e8b57><B>unsigned</B></FONT> <FONT color=#2e8b57><B>char</B></FONT> *dest, <FONT color=#2e8b57><B>int</B></FONT> len);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Decode a tile from a buffer into a raw image</FONT>
<FONT color=#0000ff> * src: source buffer</FONT>
<FONT color=#0000ff> * len: length of the source buffer</FONT>
<FONT color=#0000ff> * tileno: number that identifies the tile that will be decoded</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>int</B></FONT> tcd_decode_tile(<FONT color=#2e8b57><B>unsigned</B></FONT> <FONT color=#2e8b57><B>char</B></FONT> *src, <FONT color=#2e8b57><B>int</B></FONT> len, <FONT color=#2e8b57><B>int</B></FONT> tileno);
</PRE>
  <H3>
  <LI>The Multi-Component Transform (MCT)</H3>The multi-component transform is 
  used to better decorrelate the components of a color image. It consists of 
  converting the red, green and blue components into luminance and chrominance 
  components. The MCT modules implements a reversible as well as an irreversible 
  transform that is more precise. The MCT module is used by the TCD module. <PRE><FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Apply a reversible multi-component transform to an image</FONT>
<FONT color=#0000ff> * R: samples for red component</FONT>
<FONT color=#0000ff> * G: samples for green component</FONT>
<FONT color=#0000ff> * B: samples blue component</FONT>
<FONT color=#0000ff> * n: number of samples for each component</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> mct_encode(<FONT color=#2e8b57><B>int</B></FONT> *R, <FONT color=#2e8b57><B>int</B></FONT> *G, <FONT color=#2e8b57><B>int</B></FONT> *B, <FONT color=#2e8b57><B>int</B></FONT> n);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Apply a reversible multi-component inverse transform to an image</FONT>
<FONT color=#0000ff> * Y: samples for luminance component</FONT>
<FONT color=#0000ff> * U: samples for red chrominance component</FONT>
<FONT color=#0000ff> * V: samples for blue chrominance component</FONT>
<FONT color=#0000ff> * n: number of samples for each component</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> mct_decode(<FONT color=#2e8b57><B>int</B></FONT> *V, <FONT color=#2e8b57><B>int</B></FONT> *U, <FONT color=#2e8b57><B>int</B></FONT> *Y, <FONT color=#2e8b57><B>int</B></FONT> n);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Get norm of the basis function used for the reversible multi-component transform</FONT>
<FONT color=#0000ff> * compno: number of the component (0-&gt;Y, 1-&gt;U, 2-&gt;V)</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>double</B></FONT> mct_getnorm(<FONT color=#2e8b57><B>int</B></FONT> compno);

<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Apply an irreversible multi-component transform to an image</FONT>
<FONT color=#0000ff> * R: samples for red component</FONT>
<FONT color=#0000ff> * G: samples for green component</FONT>
<FONT color=#0000ff> * B: samples blue component</FONT>
<FONT color=#0000ff> * n: number of samples for each component</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> mct_encode_real(<FONT color=#2e8b57><B>int</B></FONT> *c0, <FONT color=#2e8b57><B>int</B></FONT> *c1, <FONT color=#2e8b57><B>int</B></FONT> *c2, <FONT color=#2e8b57><B>int</B></FONT> n);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Apply an irreversible multi-component inverse transform to an image</FONT>
<FONT color=#0000ff> * Y: samples for luminance component</FONT>
<FONT color=#0000ff> * U: samples for red chrominance component</FONT>
<FONT color=#0000ff> * V: samples for blue chrominance component</FONT>
<FONT color=#0000ff> * n: number of samples for each component</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> mct_decode_real(<FONT color=#2e8b57><B>int</B></FONT> *c0, <FONT color=#2e8b57><B>int</B></FONT> *c1, <FONT color=#2e8b57><B>int</B></FONT> *c2, <FONT color=#2e8b57><B>int</B></FONT> n);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Get norm of the basis function used for the irreversible multi-component transform</FONT>
<FONT color=#0000ff> * compno: number of the component (0-&gt;Y, 1-&gt;U, 2-&gt;V)</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>double</B></FONT> mct_getnorm_real(<FONT color=#2e8b57><B>int</B></FONT> compno);
</PRE>
  <H3>
  <LI>The Discrete Wavelet Transform (DWT)</H3>The Discrete Wavelet Transform is 
  applied on individual components of an image after a possible multi-component 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -