Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
JP3746804B2 - Image compression device - Google Patents
[go: Go Back, main page]

JP3746804B2 - Image compression device - Google Patents

Image compression device Download PDF

Info

Publication number
JP3746804B2
JP3746804B2 JP04133495A JP4133495A JP3746804B2 JP 3746804 B2 JP3746804 B2 JP 3746804B2 JP 04133495 A JP04133495 A JP 04133495A JP 4133495 A JP4133495 A JP 4133495A JP 3746804 B2 JP3746804 B2 JP 3746804B2
Authority
JP
Japan
Prior art keywords
category
scan
spatial frequency
blocks
coefficient
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
JP04133495A
Other languages
Japanese (ja)
Other versions
JPH08214311A (en
Inventor
紳聡 阿部
Original Assignee
ペンタックス株式会社
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ペンタックス株式会社 filed Critical ペンタックス株式会社
Priority to JP04133495A priority Critical patent/JP3746804B2/en
Priority to US08/598,207 priority patent/US5937098A/en
Publication of JPH08214311A publication Critical patent/JPH08214311A/en
Application granted granted Critical
Publication of JP3746804B2 publication Critical patent/JP3746804B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Compression Or Coding Systems Of Tv Signals (AREA)
  • Compression Of Band Width Or Redundancy In Fax (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)
  • Image Processing (AREA)
  • Television Signal Processing For Recording (AREA)

Description

【0001】
【産業上の利用分野】
本発明は、カラー静止画像をJPEGアルゴリズムに準拠して情報圧縮する画像圧縮装置に関する。
【0002】
【従来の技術】
高解像度画像を符号化して通信伝送路を介して情報の授受を行う標準化アルゴリズムが、JPEG(Joint Photographic Expert Group)から勧告されている。このJPEGから勧告されているアルゴリズム、すなわちJPEGアルゴリズムのベースライン・プロセスでは、大幅な情報圧縮を行うため、初めに2次元DCT変換によって原画像データを空間周波数軸上の成分に分解し、そして、その空間周波数軸上で表された各データを量子化テーブルを用いて量子化し、さらに量子化した各データを符号化する。JPEGでは、この符号化のため、所定のハフマンテーブルを推奨している。
【0003】
従来の画像圧縮装置では、通常、デフォルトの量子化テーブルが使用され、必要に応じて、量子化テーブルの各量子化係数に単一の係数を乗じることによって修正された量子化テーブルが作成されている。
【0004】
【発明が解決しようとする課題】
このように修正量子化テーブルは、各空間周波数に対して一律に係数を乗じることによって得られているため、個々の画像の特質(例えば、低周波数成分に比して高周波数成分が多い等の性質)に応じた量子化を行うことができず、画質を落とすことなく画像データを圧縮しているとは言い難かった。
【0005】
本発明は、以上のような問題点に鑑み、個々の画像の画質に応じた画像圧縮を達成することができる画像圧縮装置を提供することを目的としている。
【0006】
【課題を解決するための手段】
本発明に係る画像圧縮装置は、原画像データに直交変換を施して空間周波数毎に直交変換係数を求める直交変換手段と、直交変換係数を所定の量子化係数から成る量子化テーブルにより量子化して量子化直交変換係数を求める量子化手段と、量子化直交変換係数を空間周波数に関して所定の1次元配列データに並びかえた後、量子化直交変換係数に基づいて符号化を行って符号化データを求める符号化手段と、全ての量子化係数が1であるデフォルトの量子化テーブルにより量子化して得られた量子化直交変換係数と所定のフィルタリングテーブルとに基づいて、空間周波数毎に符号化データのデータ量の目標値を設定する手段と、各空間周波数のデータ量が目標値以下になるように、その空間周波数に対応した量子化係数を定める量子化係数演算手段とを備えたことを特徴としている。
【0007】
【実施例】
以下図示実施例に基づいて本発明を説明する。
図1は本発明の一実施例に係る画像圧縮装置のブロック図である。
【0008】
被写体Sから到来した光は集光レンズ11によって集光され、被写体像がCCD(固体撮像素子)12の受光面上に結像される。CCD12の受光面には多数の光電変換素子が配設され、また光電変換素子の上面には、例えばR、G、Bの各色フィルタ要素から成るカラーフィルタが設けられている。各光電変換素子はひとつの画素に対応している。被写体像は、各光電変換素子によって所定の色に対応した電気信号に変換され、A/D変換器13に入力される。なお、図1の構成ではCCD12が1枚のみであるが、2枚以上のCCDが設けられた構成でもよい。
【0009】
A/D変換器13においてA/D変換された信号は、図示しない信号処理回路によって輝度信号Yと色差信号Cb、Crとに変換され、画像メモリ14に入力される。画像メモリ14は輝度信号Yおよび色差信号Cb、Crをそれぞれ格納するために、相互に独立したメモリ領域に分割されており、各メモリ領域は1画像分の記憶容量を有している。
【0010】
画像メモリ14から読み出された輝度信号Yおよび色差信号Cb、Crは、データ圧縮処理のため、DCT処理回路21に入力される。DCT処理回路21では、輝度信号Y等の原画像データが離散コサイン変換(以下DCTという)される。すなわち本実施例では、原画像データの直交変換としてDCT変換が利用される。なお、図1ではDCT処理回路21が1つの処理回路として示されているが、実際には輝度信号Yおよび色差信号Cb、Cr毎に独立したDCT処理回路が設けられている。
【0011】
画像圧縮装置は、DCT処理回路21、量子化処理回路22、ハフマン符号化処理回路23、空間周波数データ量設定部24、量子化テーブル生成部25等から成る。DCT処理回路21、量子化処理回路22およびハフマン符号化処理回路23では、輝度信号Y等の画像データは1画面に関して複数のブロックに分割され、ブロック単位で処理される。なお各ブロックは8×8個の画素データから構成される。
【0012】
DCT処理回路21において求められた輝度信号Yおよび色差信号Cb、CrのDCT係数は、それぞれ量子化処理回路22に入力される。量子化処理回路22も、DCT処理回路21と同様、各信号毎に設けられている。量子化処理回路22に入力された輝度信号Y、色差信号Cb、CrのDCT係数は、8×8個の量子化係数により構成される量子化テーブルQ1によって、それぞれ量子化される。この量子化は線形量子化であり、すなわち各DCT係数は対応する量子化係数によって割算される。
【0013】
なお本実施例においては、JPEGアルゴリズムに準拠して、輝度信号YのDCT係数を量子化する量子化テーブルQ1と、色差信号Cb、CrのDCT係数を量子化する量子化テーブルQ1とは異なっているが、各信号において同一の量子化テーブルQ1を用いてもよい。これらの量子化テーブルQ1は、後述するように、空間周波数データ量設定部24と量子化テーブル生成部25により、原画像データの空間周波数分布等の性質に応じた最適なものが生成される。
【0014】
量子化処理回路22から出力された輝度信号Y、色差信号Cb、Crの量子化DCT係数はハフマン符号化処理回路23に入力され、ハフマンテーブルQ2を用い、所定のアルゴリズムによってハフマン符号化される。
【0015】
ハフマン符号化により得られた画像信号(圧縮画像データ)は、ICメモリカード等の記録媒体に記録される。
【0016】
図2は、一例として、8×8画素のブロックの画像データP(Y)xy と、DCT係数S(Y)uv と、量子化DCT係数R(Y)uv と、量子化テーブルQ(Y)uv とを示している。
【0017】
図2(a)の画像データP(Y)xy は、2次元DCT変換によって、図2(b)に示す8×8=64個のDCT係数S(Y)uv に変換される。これらのDCT係数のうち、位置(0,0)にあるDCT係数S(Y)00 はDC成分であり、残り63個のDCT係数S(Y)uv はAC成分である。AC成分は、係数S(Y)01 若しくは係数S(Y)10 から係数S(Y)77 に向かって、より高い空間周波数成分が8×8画素ブロックの画像データ中にどのくらいあるかを示している。DC成分は8×8画素のブロック全体の画素値の平均値(直流成分)を表している。すなわち、各DCT係数S(Y)uv はそれぞれ所定の空間周波数に対応している。
【0018】
図2(d)は量子化処理回路21で用いられる量子化テーブルQ(Y)uv の一例を示している。このような量子化テーブルQ(Y)uv としては、上述したように、輝度信号Yと色差信号Cb、Crとで別のものでもよい。量子化テーブルQ(Y)uv は、JPEGフォーマットの画像データを記録媒体に記録する際に、各信号に対応した位置に、その信号の量子化に使用された量子化テーブルQ(Y)uv の内容が記録される。
【0019】
量子化テーブルQ(Y)uv を用いてDCT係数S(Y)uv を量子化する式は以下のように定義される。
R(Y)uv =round(S(Y)uv /Q(Y)uv) {0≦ u,v≦7}
この式における roundは最も近い整数への近似を意味する。すなわち、DCT係数S(Y)uv 及び量子化テーブルQ(Y)uv の各要素同士の割算と四捨五入とによって、図2(c)に示すような量子化DCT係数R(Y)uv が求められる。
【0020】
このようにして量子化処理回路22において求められた量子化DCT係数R(Y)uv 、R(Cb)uv、R(Cr)uvは、ハフマン符号化処理回路23に入力される。
【0021】
次にハフマン符号化処理回路23におけるハフマン符号化について、図3〜図8を参照して説明する。なお以下の説明において、量子化DC係数とは量子化されたDC成分をいい、量子化AC係数とは量子化されたAC成分をいう。
【0022】
量子化DC係数R(Y)00 と量子化AC係数(量子化DC係数R(Y)00 以外の量子化DCT係数R(Y)uv )では符号化方法が異なっている。量子化DC係数R(Y)00 の符号化は次のように行われる。
【0023】
まず、現在符号化しようとするブロックの量子化DC係数R(Y)00 と一つ前に符号化されたブロックの量子化DC係数R(Y)00 との差分が求められる。この差分値が図3に示すカテゴリの何れに属するかが判断され、そのカテゴリを表す符号語が、図4に示す符号表(DC成分の符号化テーブル)から求められる。例えば、現在符号化しようとするブロックの量子化DC係数R(Y)00 が「16」であり、一つ前に符号化されたブロックの量子化DC係数R(Y)00 が「25」である時、差分値は「−9」であるので、図3のカテゴリ表から、差分値=−9の属するカテゴリは「4」と判別され、さらにそのカテゴリの符号語が図4の符号表より「 101」と判断される。
【0024】
次いで差分値が、図3のカテゴリ表において、そのカテゴリ内において何番目の値であるかが、付加ビットにより表される。例えば差分値=−9はカテゴリ=4のグループにおいて、小さい方から7番目にあるので、付加ビットは「0110」となる。すなわち、現在符号化しているブロックの量子化DC係数R(Y)00 のハフマン符号語は「 1010110」となる。
【0025】
一方、量子化AC係数の符号化は、図5に示す処理ルーチンによって行われる。まずステップ120において、63個の量子化AC係数が図6に示す順序でジグザグスキャンされ、1次元配列データに並びかえられる。量子化AC係数を、ジグザグスキャンの順序に従って、スキャンAC1 、AC2 ・・・AC63と呼ぶこととする。次に、ステップ122では、1次元に並べられた各量子化AC係数が「0」であるか否かかが判断される。量子化AC係数が「0」である時、ステップ124において、その「0」である量子化AC係数が連続する数がカウントされる。これにより「0」が連続する長さ、すなわちラン長が求められる。
【0026】
これに対し、ステップ122において量子化AC係数が「0」でないと判断された時、ステップ126において、量子化DC係数と同じようなグループ分けが行われるとともに付加ビットが求められる。この量子化AC係数のグループ分けは、量子化DC係数のグループ分けとは異なり、その量子化AC係数そのものについて行われる。すなわち、量子化AC係数が例えば「4」である時、図7に示す表を参照してカテゴリ「3」が得られる。また、量子化AC係数「4」はカテゴリ=3のグループにおいて小さい方から5番目にあるので、付加ビットは「 100」となる。
【0027】
ステップ130では、ハフマンテーブルのAC符号表(図8)を参照し、例えば量子化AC係数「4」の直前のデータのラン長が「0」である場合、このラン長とカテゴリ=3とに基づいて、符号語「 100」が得られる。そして、この符号語「 100」とステップ126において得られた付加ビット「 100」を組み合わせことにより2次元ハフマン符号語「100100」が求められる。
【0028】
図2(c)の量子化DCT係数をハフマン符号化した結果を、図9の符号化データHFとして示す。
【0029】
図10は図9に示す符号化データHFを再び示している。このような符号化データHFは、各ブロック毎に得られ、1画面が5400ブロックにより構成される場合、符号化データHFは5400だけ得られる。上述したように、符号化データHFは、1つの量子化DC係数に関する符号化データと、63個の量子化AC係数に関する符号化データとから成る。
【0030】
量子化DC係数に関する符号化データは、カテゴリの符号語FA0と付加ビットFB0とから成る。量子化AC係数に関する符号化データは、ラン長・カテゴリの符号語と付加ビットから構成される。次に、量子化AC係数に関する符号化データについてさらに詳細に説明する。
【0031】
図9の例では、スキャンAC1 が4であり、かつラン長が0であることに基づく符号化データとして、ラン長・カテゴリの符号語FA1と付加ビットFB1が生成され、スキャンAC2 が−7であり、かつラン長が0であることに基づく符号化データとして、ラン長・カテゴリの符号語FA2と付加ビットFB2が生成されている。スキャンAC3 が0であるので、付加ビットFB2の後には、スキャンAC4 が3であり、かつラン長が1であることに基づく符号化データとして、ラン長・カテゴリの符号語FA4と付加ビットFB4が生成されている。同様にして、ラン長・カテゴリの符号語FA5と付加ビットFB5、ラン長・カテゴリの符号語FA8と付加ビットFB8、ラン長・カテゴリの符号語FA9と付加ビットFB9がそれぞれ生成されている。終端データ(EOB)は、スキャンAC10以降は全て0が続くことを示している。
【0032】
次に、量子化テーブルQ1の生成について説明する。
図1に示すように量子化テーブルQ1は、設定合計符号量とDCTデータ統計量とフィルタリングテーブルFLとに基づいて生成される。
【0033】
設定合計符号量は、記録媒体に記録される1画面分の符号化データHFの合計ビット数であり、例えば524288ビット(64Kbyte)である。DCTデータ統計量はDCT処理回路21の出力データに基づいて得られる。DCT処理回路21の出力データは原画像データをDCT変換したものであり、8×8個の量子化係数が全て「1」である量子化テーブルQ1(以下、デフォルトの量子化テーブルという)を用いて量子化したものと等価である。この出力データをジグザグスキャンして(図6参照)、ラン長とカテゴリを求めた(図5参照)後、図24に示す表を参照して各空間周波数毎のビット長を求めることにより、DCTデータ統計量が得られる。すなわち、このDCTデータ統計量は、次に述べるように、図11に示すようなカテゴリ分布と、図12に示すようなスキャン毎の符号量の分布である。フィルタリングテーブルFLは、各空間周波数におけるデータ圧縮の度合いを定めるものである。後述するようにフィルタリングテーブルFLは、各空間周波数に対応したフィルタリング係数を有し、各フィルタリング係数は、データ圧縮の度合いが大きい空間周波数ほど大きい値を有している。
【0034】
図11は、デフォルトの量子化テーブルを用いた時の所定の空間周波数(例えばスキャンAC1 )でのカテゴリ分布、すなわち各カテゴリに分類されるブロックの数の例を示している。この図に示すようなカテゴリ分布は、1つの画像において、DC成分に関するものと、63個のAC成分に関するものとが生成され、すなわちカテゴリ分布は全部で64だけ生成される。本実施例において原画像データは5400ブロックに分割されており、図11の例では、カテゴリが0であるブロック数は602であり、カテゴリが1であるブロック数は1088である。
【0035】
図12は、デフォルトの量子化テーブルを用いた時の各スキャンにおける符号化データHFのビット数の分布の例であり、これは1つの画像の全ブロックに関して、各空間周波数毎の合計ビット数を示している。例えばDC成分の場合、カテゴリの符号語FA0と付加ビットFB0(図10参照)の合計ビット数は42238(符号DB0)である。スキャンAC1 の場合、ラン長・カテゴリの符号語FA1と付加ビットFB1の合計ビット数は34009(符号DB1)、スキャンAC2 の場合、ラン長・カテゴリの符号語FA2と付加ビットFB2の合計ビット数は33833(符号DB2)である。図10の例では、スキャンAC3 に関してラン長・カテゴリの符号語と付加ビットは存在しないが、他のブロックにおいてスキャンAC3 のデータが存在するため、合計ビット数は25920(符号DB3)となっている。このようにして、スキャンAC63の合計ビット数20909(符号DB63)までのデータが生成される。
【0036】
設定合計符号量とDCTデータ統計量とフィルタリングテーブルFLは、空間周波数データ量設定部24に入力される。空間周波数データ量設定部24では、設定合計符号量とDCTデータ統計量とフィルタリングテーブルFLに基づいて、例えば図13に示すような、各空間周波数毎(すなわちスキャン毎)の符号量の分布が設定される。すなわち、DC成分の符号量は44240ビット(符号SB0)、スキャンAC1 の符号量は33008ビット(符号SB1)、スキャンAC2 の符号量は35629ビット(符号SB2)であり、スキャンAC63の符号量まで設定される(符号SB63)。これらの符号量の合計値すなわち設定合計符号量は所定値(図13の例では524288ビット)に定められる。
【0037】
この符号量(データ量)は目標値であり、この画像圧縮装置では、後述するように各空間周波数毎の符号量がこの目標値になるように、量子化テーブルQ1が生成される。すなわち、この符号量の分布は、最終的に得られた量子化テーブルQ1を用いた場合のハフマン符号化データにおける、各空間周波数毎の符号量の目標値である。例えば高周波数成分をカットしたい場合には、高周波数成分に関する符号量が相対的に小さくなるように定められ、このような符号量の分布はフィルタリングテーブルFLに基づいて設定される。
【0038】
また空間周波数データ量設定部24では、DCTデータ統計量のうちのスキャン毎の符号量の分布(図12参照)を用いて、各空間周波数毎の符号量の上限値を定めてもよい。例えば、図13においてスキャンAC4 の合計ビット数は28844(符号SB4)に定められているが、DCTデータ統計量の符号量分布に基づいて、28461ビットに制限してもよい(図12の符号DB4参照)。
【0039】
量子化テーブル生成部25では、DCTデータ統計量と空間周波数データ量設定部24からの入力データとに基づいて、量子化テーブルQ1を構成する各量子化係数が生成される。
【0040】
DC成分に関する量子化係数の求め方について説明する。
まず、デフォルトの量子化テーブル(全ての量子化係数が1である量子化テーブル)を用いて、全てのブロックのDC成分が量子化される。そして、現在量子化係数を求めようとしているブロックの量子化DC係数と一つ前のブロックの量子化DC係数との差分値が求められる。
【0041】
この差分値が図3に示すカテゴリの何れに属するかが判断され、そのカテゴリを表す符号語が、図4に示す符号表(DC成分の符号化テーブル)から求められる。また図3のカテゴリ表から、その差分値に対応した付加ビット数が求められる。例えば、差分値のカテゴリが「2」であるとき、符号長は3ビットであり、付加ビット数は2ビットである。したがって、差分値のカテゴリが「2」である量子化DC係数の符号量は5ビットである。
【0042】
このようにして、量子化DC係数の符号量が各ブロック毎に求められ、これらの合計符号量(ビット数)が求められる。この合計符号量が図13に示すDC成分の符号量(符号SB0)以下であれば、その時の量子化係数が最終的なものとして決定される。もし、その合計値が図13の符号量(符号SB0)よりも大きければ、次に量子化係数は2に変更され、この量子化係数を用いて、上述したような合計ビット数の検討が行われる。
【0043】
この新しい量子化係数を用いたときの合計ビット数を求めるために、各カテゴリに該当するブロックの数を予測しておくことが必要である。すなわち図15に示すようなカテゴリ分布の表を、予め求めておく必要がある。このカテゴリ分布の表の求め方の一例を図3を参照して次に説明する。
【0044】
例えばカテゴリ「2」に属する差分値は、−3、−2、2、3である。量子化係数が2になると、差分値「2」は2/2=1となるため、カテゴリ「1」に移る。差分値「−2」も同様である。これに対し、差分値「3」は3/2=1.5≒2となるため、カテゴリ「2」のままである。差分値「−3」も同様である。したがって、この例では、量子化係数が1であるときにカテゴリ「2」に属していた差分値のうち、半分がカテゴリ「1」に変化し、半分がカテゴリ「2」のままである。このようにして、量子化係数が変化した場合のカテゴリ分布が予想され、このカテゴリ分布の表を用いることにより、合計符号量が求められる。
【0045】
次に、AC成分に関する量子化係数の求め方について説明する。
AC成分については、ハフマン符号化データの中にラン長に関するデータが含まれており(図10の例えば符号FA1、FA2、FA4等)、また量子化係数を変化させるとラン長が変化する。したがって、量子化係数を変化させたときの各スキャンのデータ量は、量子化係数を変化させる前のそのスキャンのデータ量だけに基づいて予測することはできない。そこで本実施例では、次に述べるように、カテゴリ分布の表を用いて、量子化係数を変化させたときの各スキャンのデータ量を予測し、この予測値に基づいて量子化係数を決定している。
【0046】
図14は、図11に示すカテゴリ分布を各スキャンについて同時に示す表の一例である。すなわち、このカテゴリ分布の表は、デフォルトの量子化テーブルを用いた時の各空間周波数における、各カテゴリに分類されるブロックの数を示している。なお図14では、DC成分と、スキャンAC1 からスキャンAC11まで示され、スキャンAC12からスキャンAC63までは省略されている。また図14において、最上段の数字はカテゴリを示している。例えばスキャンAC1 において、カテゴリ「0」のブロック数は602、カテゴリ「1」のブロック数は1088である。
【0047】
図15は、図14と異なり、全ての量子化係数が「16」である量子化テーブルを用いた時のカテゴリ分布の表を示している。図7から理解されるように、量子化係数「1」を用いた場合のカテゴリ「0」から「3」までのAC成分値は、量子化係数「16」を用いると0になるため、そのAC成分値のカテゴリは「0」となる。すなわち、図15におけるスキャンAC1 の3479個のカテゴリ「0」のブロックは、図14における、カテゴリ「0」〜「3」の602、1088、1184、605の各ブロックに対応している。
【0048】
同様に量子化係数「1」を用いた場合のカテゴリ「4」のAC成分値は、量子化係数「16」を用いると−1または1になるため、そのAC成分値のカテゴリは「1」となる。一方、量子化係数「1」を用いた場合のカテゴリ「5」のAC成分値は、量子化係数「16」を用いると1になるものと2になるものとがある。したがって、量子化係数「16」を用いた場合、一部のブロックのAC成分値のカテゴリは「1」となり、他のブロックのAC成分値のカテゴリは「2」となる。すなわち、図15におけるスキャンAC1 の866個のカテゴリ「1」のブロックは、図14における、カテゴリ「4」の529のブロックと、カテゴリ「5」の一部のブロックに対応している。このように、量子化係数を変化させると、あるカテゴリに属するブロックがそのまま他のカテゴリに移行するとは限らず、異なるカテゴリに移行することがある。
【0049】
次に、スキャンACi-1 、ACi のカテゴリが共に「0」であるブロック数の予測について、図16〜図19を参照して説明する。
【0050】
図16〜図19において、C〔0〕は、そのスキャンでのカテゴリ「0」のブロック数、C〔1〜〕は、そのスキャンでのカテゴリ「1」以上のブロック数である。Z〔k〕は、ラン長がkであるブロック数の予測値である。C’〔0〕は1つ前のスキャンでのカテゴリ「0」のブロック数、Z’〔0〕は1つ前のスキャンでのラン長が0であるブロック数である。
【0051】
図16はスキャンAC1 のカテゴリ「0」のブロック数と、カテゴリ「1」以上のブロック数を示している。スキャンAC1 では、図15に示すように、カテゴリ「0」のブロック数C〔0〕は3479であり、カテゴリ「1」以上のブロック数C〔1〜〕は1921(=5400−3479)である。したがって、スキャンAC1 において、ラン長が1であるブロック数Z〔1〕は3479、ラン長が0であるブロック数Z〔0〕は1921である。
【0052】
図17は、スキャンAC2 までのラン長が2、1、0であるブロック数を示している。スキャンAC2 では、図15に示すように、カテゴリ「0」のブロック数C〔0〕は3619であり、カテゴリ「1」以上のブロック数C〔1〜〕は1781である。したがってラン長が0であるブロック数Z〔0〕が1781であることは明らかであるが、ラン長が2であるブロック数Z〔2〕とラン長が1であるブロック数Z〔1〕については明らかではない。そこで本実施例では、ブロック数Z〔2〕とブロック数Z〔1〕との比は、スキャンAC1 でのラン長が1であるブロック数Z〔1〕とラン長が0であるブロック数Z’〔0〕との比に等しいと仮定して、ブロック数Z〔2〕とブロック数Z〔1〕のブロック数を予想している。すなわち本実施例では、スキャンAC1 、AC2 において共にカテゴリが「0」であるブロック数は、スキャンAC1 におけるカテゴリ「0」のブロック数に関連すると仮定している。
【0053】
このようにして求められたブロック数Z〔2〕は、スキャンAC1 、AC2 のカテゴリが共に「0」である場合における、スキャンAC2 に対応している。またブロック数Z〔1〕は、スキャンAC1 のカテゴリが「0」以外である場合における、カテゴリが「0」であるスキャンAC2 に対応している。
【0054】
図18は、スキャンAC3 までのラン長が3、2、1、0であるブロック数を示している。スキャンAC3 では、図15に示すように、カテゴリ「0」のブロック数C〔0〕は4366であり、カテゴリ「1」以上のブロック数C〔1〜〕は1034である。したがってブロック数Z〔0〕は1034である。ブロック数Z〔1〕は、スキャンAC2 でのブロック数Z’〔0〕の割合に依存すると仮定し、
Z〔1〕=4366×1781/5400=1440
となる。一方、ブロック数Z〔2〕、〔3〕の比は、スキャンAC2 でのブロック数Z〔1〕、〔2〕の比に等しいと仮定し、
Z〔2〕=4366×1287/5400=1041
Z〔3〕=4366×2332/5400=1885
となる。
【0055】
このブロック数Z〔3〕は、スキャンAC1 、AC2 、AC3 のカテゴリが共に「0」である場合における、スキャンAC3 に対応している。またブロック数Z〔2〕は、スキャンAC1 のカテゴリが「0」以外であり、かつスキャンAC2 のカテゴリが「0」である場合における、カテゴリが「0」であるスキャンAC3 に対応している。ブロック数Z〔1〕は、スキャンAC2 のカテゴリが「0」以外である場合における、カテゴリが「0」であるスキャンAC3 に対応している。
【0056】
図19はスキャンAC4 までのラン長が4、3、2、1、0であるブロックを示している。スキャンAC4 以降においても上述した処理が行われ、ラン長がkであるブロック数Z〔k〕が求められる。
【0057】
このようにしてスキャンAC63までのラン長が求められると、次に、図20〜図23に示すようなラン長・カテゴリの表が各カテゴリ毎に作成される。
【0058】
図20は、スキャンAC1 のラン長・カテゴリの表であり、この表は、ラン長が0であってカテゴリ「0」以外のカテゴリ分布を示している。スキャンAC1 おいて、カテゴリ「0」以外のブロック数は、図16に示すように全部で1921(=Z〔0〕)ある。カテゴリ分布は、図15に示すように、カテゴリ「1」、「2」・・・「5」の順に、866、519、300、212、24であり、カテゴリ「6」以上のブロック数は0である。この数値をそのまま転記することにより、図20の表が作成される。
【0059】
図21は、スキャンAC2 のラン長・カテゴリの表であり、この表は、ラン長が0と1であってカテゴリ「0」以外のカテゴリ分布を示している。スキャンAC2 おいて、カテゴリ「0」以外のブロック数は、図17に示すように全部で1781(=Z〔0〕)ある。カテゴリ分布は、図15に示すように、カテゴリ「1」、「2」・・・「5」の順に、850、487、315、119、10であり、カテゴリ「6」以上のブロック数は0である。カテゴリ「1」の850のブロックは、図17に示すZ〔1〕とZ〔2〕の比、すなわちスキャンAC1 でのラン長が0であるブロック数Z’〔0〕とラン長が1であるブロック数Z〔1〕との比に等しいと仮定して、ラン長が0のブロック数は302、ラン長が1のブロック数は548に定められている。同様に、カテゴリ「2」の487のブロックについては、ラン長が0のブロック数は173、ラン長が1のブロック数は314に定められている。このようにして、図21の表が作成される。
【0060】
図22は、スキャンAC3 のラン長・カテゴリの表であり、この表は、ラン長が0と1と2であってカテゴリ「0」以外のカテゴリ分布を示している。スキャンAC3 おいて、カテゴリ「0」以外のブロック数は、図18に示すように全部で1034(=Z〔0〕)ある。カテゴリ分布は、図15に示すように、カテゴリ「1」、「2」・・・「4」の順に、675、220、121、18であり、カテゴリ「5」以上のブロック数は0である。各カテゴリのブロック数は、図18に示すZ〔1〕とZ〔2〕とZ〔3〕の比に従って、ラン長が0と1と2のブロック数に分配されている。
【0061】
図23は、スキャンAC4 のラン長・カテゴリの表である。この表も上述した処理により、図15と図19を参照して作成される。このようにしてスキャンAC63までのラン長・カテゴリの表が作成される。
【0062】
次に、図20〜図23に示すようなラン長・カテゴリの表を参照して、各スキャンにおけるデータ量(ビット数)が計算される。この計算のため、図24に示す符号長の表が用いられる。この表中の各数値はJPEGにより推奨されたハフマンテーブルの各符号語の符号長を示している。例えば、ラン長が1で、カテゴリが2である符号語の符号長は5である。
【0063】
スキャンAC1 については、図20と図24を参照して全ブロックにおけるラン長・カテゴリの符号語のビット数は、
866 x 2 + 519 x 2 + 300 x 3 + 212 x 4 + 24 x 5 = 4638
となる。一方、付加ビットについては、カテゴリの数値がそのままビット数に対応しているため、付加ビットのビット数は、
866 x 1 + 519 x 2+ 300 x 3 + 212 x 4 + 24 x 5 = 3772
となる。したがってスキャンAC1 の予想データ量は、
4638 + 3772 = 8410(ビット)
である。
【0064】
スキャンAC2 〜スキャンAC63についても、スキャンAC1 と同様な計算によってデータ量が求められる。
【0065】
このようにして得られた各スキャンにおけるデータ量は、図13に示す設定符号量以下でなければならない。例えば、スキャンAC1 については33008ビット以下に抑えられなければならない。上述の例では、実施例の説明のために量子化係数を「16」としたため、データ量は8410ビットであり設定符号量よりもかなり小さい。したがって実際には、量子化係数は「16」よりも小さい数値が適当である。すなわち、量子化係数が「1」である場合の予想データ量が33008ビットよりも大きければ、量子化係数を1だけ大きくして予想データ量を計算し直し、このような操作を行いながら、設定符号量以下になるような量子化係数を求める。
【0066】
上述した量子化テーブルの生成を、図25のフローチャートを用いて説明する。なお、このフローチャートはスキャンAC2 〜AC63に関する量子化係数の生成を示しており、DC成分とスキャンAC1 の量子化係数は既に求められているものとする。
【0067】
ステップ101では、パラメータiが2に定められる。ステップ102では、量子化係数qが初期値として1に定められる。
【0068】
ステップ103では、図14を用いて、図15に示すようなスキャンACi のカテゴリ分布が生成される。例えば、パラメータiが3であり量子化係数qが16である時、このカテゴリ分布は、図15に示す例では、
4366, 675, 220, 121, 18, 0, 0, 0, 0, 0, 0
である。
【0069】
なおステップ103が実行される前に、符号P11で示すように、スキャンACi-1 のカテゴリ「0」のブロック数が求められている。例えばパラメータiが3であり、スキャンAC2 の量子化係数qが16であった場合、スキャンAC2 のカテゴリ「0」のブロック数は図15の例では3619である。また、符号P12で示すように、スキャンACi-1 のカテゴリ「0」のブロック数の分布が求められている。例えばパラメータiが3であり、スキャンAC2 の量子化係数qが16であった場合、スキャンAC2 における図17の例では、ブロック数Z〔2〕は2332、ブロック数Z〔1〕は1287、ブロック数Z〔0〕は1781である。
【0070】
ステップ104では、ステップ103において求められたスキャンACi のカテゴリ分布と、スキャンACi-1 のカテゴリ「0」のブロック数(符号P11)と、スキャンACi-1 のカテゴリ「0」のブロック数の分布(符号P12)とに基づいて、スキャンACi におけるカテゴリ「0」のブロック数の分布が予測される。例えばパラメータiが3であり、量子化係数qが16である時、スキャンAC3 における図18の例では、図15と図17のデータに基づいて、ブロック数Z〔3〕は1885、ブロック数Z〔2〕は1041、ブロック数Z〔1〕は1440である。
【0071】
ステップ105では、スキャンACi における圧縮データの予測データ量が求められる。例えばパラメータiが3であり、量子化係数qが16である時、スキャンAC3 における予測データ量Di は、図22のラン長・カテゴリの表と図24の符号長の表とから、
223 x 2 + 73 x 2 + 40 x 3 + 6 x 4
+ 161 x 4 + 52 x 5 + 29 x 7 + 4 x 9
+ 291 x 5 + 95 x 8 + 52 x 10 + 8 x 12
+ (223 + 161 + 291) + (73 + 52 + 95) x 2
+ (40 + 29 + 52) x 3 + (6 + 4 + 8) x 4
= 6260(ビット)
となる。
【0072】
ステップ106では、ステップ105において計算された予測データ量Di が図13に示すような設定符号量Si であるか否かが判定される。上述したステップ105の説明の例の場合、量子化係数qを16としたため予測データ量Di は6260ビットとなり、図13の設定符号量S3 =24042(符号SB3)よりもかなり小さい。しかし実際には、量子化係数qが1である場合から始めるため、最初のうちは予測データ量Di は設定符号量Si よりも大きい。したがって、ステップ107において量子化係数qがまだ255に達していないことが確認された後、ステップ108において量子化係数qが1だけインクリメントされ、再びステップ103に戻る。
【0073】
そしてステップ103〜105が再び実行され、ステップ106において予測データ量Di が設定符号量Si 以下であると判定されると、これにより量子化係数qが確定する。すなわち、ステップ106からステップ110へ進み、パラメータiが63に達したか否かが判定される。パラメータiが63に達していない時、ステップ111において次のスキャンに関する設定符号量Si+1 が設定符号量Si と予測データ量Di の差だけ加算される。すなわち、次のスキャンの設定符号量Si+1 は、前のスキャン設定符号量Si において用いられなかった分が割り当てられる。
【0074】
次いでステップ112では、パラメータiが1だけインクリメントされ、ステップ102へ戻り、次のスキャンについてステップ102〜108が実行されて量子化係数が求められる。
【0075】
ステップ110においてパラメータiが63に達していると判定されると、ステップ113に進み、量子化係数qに基づいて量子化係数が生成され、このプログラムは終了する。
【0076】
図16〜図23を参照して説明した、各スキャンACi のデータ量の第1の予測方法は、比較的簡単な例であって、必ずしも高精度な予測であるとは言えない。そこで次に、さらに高精度な第2の予測方法について、図26〜図28を参照して説明する。
【0077】
図26は「00」データの分布、すなわちスキャンACi-1 とスキャンACi とが共にカテゴリ「0」であるブロック数を示し、図14のカテゴリ分布の表に対応している。例えば、スキャンAC1 、AC2 が共にカテゴリ「0」のブロック数は120(符号J12)、スキャンAC2 、AC3 が共にカテゴリ「0」のブロック数は159(符号J23)、スキャンAC3 、AC4 が共にカテゴリ「0」のブロック数は186(符号J34)、スキャンAC62、AC63が共にカテゴリ「0」のブロック数は327(符号J6263)である。
【0078】
スキャンACi-1 、ACi がそれぞれカテゴリ「0」であるブロック数が変化すると、スキャンACi-1 、ACi が共にカテゴリ「0」であるブロック数はスキャンACi-1 のブロック数の変化率とスキャンACi の変化率との積に比例すると仮定する。例えば、スキャンACi-1 、ACi のブロック数が共に2倍になったとすると、スキャンACi-1 、ACi が共にカテゴリ「0」であるブロック数は4倍になる。このような仮定の下に、スキャンACi-1 とACi のカテゴリ「0」のブロック数に基づいて、量子化後のスキャンACi-1 、量子化後のスキャンACi が共にカテゴリ「0」のブロック数を予測する。
【0079】
「00」データの分布は、ブロック数の基準値を3500とすることによって正規化され、メモリに格納される。例えば、スキャンAC1 、AC2 が共にカテゴリ「0」であるブロック数は、正規化によって、図27に示すように3823に変換される。図28は、正規化された「00」データの分布の表を示し、例えば、スキャンAC1 、AC2 の「00」データは3823(符号K12)、スキャンAC2 、AC3 の「00」データは3577(符号K23)、スキャンAC3 、AC4 の「00」データは3280(符号K34)、スキャンAC62、AC63の「00」データは2262(符号KJ6263)である。
【0080】
図29は、カテゴリ「0」であるスキャンACi-1 のブロック数を横軸に、またスキャンACi-1 、ACi が共にカテゴリ「0」であるブロック数(すなわち「00」データ)を縦軸にとったグラフである。このグラフにおいて、横座標の最大値は全ブロック数(5400)であり、Slow は上述した基準値3500、Smid は例えば4800、Shighは例えば5150である。縦座標の最大値Omax は可変であり、最大値Omax が基準値3500である時、Ohighは例えば3403、Omid は例えば3144、Olow は例えば2463である。折れ点f、g、hは、再生画像の画質が原画像に近くなるように、例えば試行錯誤によって求められるが、折れ点bは、次に述べるようにスキャンACi-1 、ACi のカテゴリ「0」のブロック数に応じて変化する。
【0081】
折れ点bの求め方を、図15の場合を例にとり説明する。
例えば、スキャンAC3 のカテゴリ「0」のブロック数は4366であり、スキャンAC4 のカテゴリ「0」のブロック数は4108である。
【0082】
まず図28の表を参照し、スキャンAC3 、AC4 の「00」データとして、K34=3280が得られる。次に、図29において、最大値Omax を基準値3500に定めた状態で、Slow (3500)に対応する縦座標を読むと、点cが得られる。原点aと点cを結んだ直線L1と、Olow から横方向に延びる直線L2との交点bを求めると、折れ線abfghが得られる。
【0083】
次に、縦座標の最大値Omax をスキャンAC4 のブロック数4108に合わせると、Ohighは3994、Omid は3690、Olow は2891となる。この状態で、横座標においてスキャンAC3 のブロック数4366に対応する折れ線bf上の点P3の縦座標を読むと、3530がスキャンAC3 、AC4 の「00」データとして得られる。この数値は、図19においてZ〔2〕とZ〔3〕とZ〔4〕の和(=3321)に相当し、図19の例よりも大きい。すなわち第2の予測方法によれば、スキャンAC3 、AC4 の「00」データは第1の予測方法の場合よりも多い。
【0084】
このようにして得られた「00」データは、次に述べる方法によって、Z〔2〕とZ〔3〕とZ〔4〕に分配される。
【0085】
この分配のためには、図18に示すようなスキャンAC2 、AC3 の「00」データに関するZ〔1〕、Z〔2〕、Z〔3〕の値が必要であり、また、これらのZ〔1〕、Z〔2〕、Z〔3〕を求めるためには、図17に示すようなスキャンAC1 、AC2 の「00」データに関するZ〔1〕、Z〔2〕の値が必要である。
【0086】
スキャンAC1 、AC2 のZ〔1〕、Z〔2〕は、図29と同様にして折れ線abfghを作成し、この折れ線上の点を読むことによって求められる。Z〔2〕は折れ線から直接求められ、Z〔1〕はC〔0〕とZ〔2〕の差として求められる。スキャンAC2 、AC3 に関しては、Z〔2〕とZ〔3〕の和が、折れ線abfghを作成してこの折れ線上の点を読むことによって求められ、Z〔1〕は、Z〔2〕とZ〔3〕の和をC〔0〕から引くことにより求められる。Z〔2〕とZ〔3〕の各値は、スキャンAC1 、AC2 のZ〔1〕、Z〔2〕の比に従って分配される。すなわち、スキャンAC2 、AC3 に関するZ〔1〕、Z〔2〕、Z〔3〕の各値が得られる。
【0087】
同様にして、スキャンAC3 、AC4 のZ〔2〕、Z〔3〕、Z〔4〕の各値は、スキャンAC2 、AC3 のZ〔1〕、Z〔2〕、Z〔3〕の比に従って分配される。これにより、図23に示すようなラン長・カテゴリの表が得られ、スキャンAC4 における圧縮データの予測データ量が計算される。他のスキャンについても同様な計算が行われ、予測データ量が求められる。
【0088】
次にスキャンACi のデータ量の第3の予測方法について説明する。
スキャンACi-1 においてラン長がkであるブロック数をZ〔k〕、スキャンACi-1 におけるカテゴリ「0」である全ブロック数をZALL 、スキャンACi-1 においてカテゴリ「0」であり、かつスキャンACi においてカテゴリ「j」であるブロック数をCTj とする。また修正係数をZWとする。
【0089】
スキャンACi におけるラン長がkでカテゴリがjであるブロック数B〔k,j〕は、

Figure 0003746804
により求められる。スキャンACi におけるラン長が(k+1)であるブロック数Z〔k+1〕(すなわちラン長がkでカテゴリが0であるブロック数)は、
Figure 0003746804
により求められる。
【0090】
修正係数ZWは、0から1000までの値をとりうる。例えばZW=0のとき、
Z〔k+1〕=CTj × Z〔k〕/ZALL
となり、これは第2の予測方法と同じ結果になる。ZW=1000とすると、
Z〔k+1〕=Z〔k〕
となり、これは、スキャンACi-1 のラン長kのブロックが、スキャンACi において全てカテゴリ「0」となることを示している。以下に説明する例では、ZW=50としている。
【0091】
ここで、スキャンAC3 において、Z〔0〕=1034、Z〔1〕=1440、Z〔2〕=1041、Z〔3〕=1885であり、またスキャンAC4 におけるカテゴリ分布として、図30のような表が得られているとする。すなわち、スキャンAC3 がカテゴリ「0」である4366ブロックにおいて、スキャンAC4 では、カテゴリ「0」のブロック数CT0 は3321、カテゴリ「1」のブロック数CT1 は655、カテゴリ「2」のブロック数CT2 は276、カテゴリ「3」のブロック数CT3 は101、カテゴリ「4」のブロック数CT4 は13、カテゴリ「5」以上のブロック数は0であるとする。
【0092】
次に述べるように、ラン長が1であるデータからブロック数が求められ、図31に示すようなラン長・カテゴリの分布表が求められる。
【0093】
スキャンAC4 において、ラン長が1であり、かつカテゴリ「1」であるブロック数は、(1)式より、
Figure 0003746804
となる。同様に、ラン長が1であり、かつカテゴリ「2」であるブロック数は、(1)式より、
Figure 0003746804
となる。
【0094】
ラン長が1であり、かつカテゴリ「3」であるブロック数については、(1)式より、
Figure 0003746804
となるが、図30に示されるようにCT3 =C〔3〕=101である。したがって、104ではなく、強制的に101に定められる。
【0095】
ラン長が1であり、かつカテゴリ「4」であるブロック数についても同様に、B〔1,4〕は強制的に13に定められる。
【0096】
スキャンAC4 においてラン長が2であるブロック数Z〔2〕(すなわちラン長が1であり、かつカテゴリが0であるブロック数)は、
Z〔2〕=Z〔1〕−(277 + 158 + 101 + 13) = 891
となる。
【0097】
ラン長が2であり、かつカテゴリ「1」であるブロック数については、
Figure 0003746804
となる。ラン長が2であり、かつカテゴリ「2」であるブロック数については、B〔2,2〕= 66 + 49 = 115
となる。
【0098】
ラン長が2であり、かつカテゴリ「3」であるブロック数B〔2,3〕は、B〔1,3〕の結果に従って0であり、またラン長が2であり、かつカテゴリ「4」であるブロック数B〔2,4〕は、B〔1,4〕の結果に従って0である。
【0099】
スキャンAC4 においてラン長が3であるブロック数Z〔3〕(すなわちラン長が2であり、かつカテゴリが0であるブロック数)は、
Z〔3〕=Z〔2〕−(200 + 115 + 0 + 0)= 726
となる。
【0100】
ラン長が3であり、かつカテゴリ「1」であるブロック数については、
Figure 0003746804
となる。しかし、カテゴリ「1」であるブロック数CT1 の総数が655であるため、
B〔3,1〕= 655 - 277 - 200= 178
となる。
【0101】
ラン長が3であり、かつカテゴリ「2」であるブロック数については、
Figure 0003746804
となる。しかし、カテゴリ「2」であるブロック数CT2 の総数が276であるため、
B〔3,2〕= 276 - 158 - 115= 3
となる。
【0102】
ラン長が3であり、かつカテゴリ「3」であるブロック数は、B〔1,3〕、B〔2,3〕の結果に従って0であり、またラン長が3であり、かつカテゴリ「4」であるブロック数は、B〔1,4〕、B〔2,4〕の結果に従って0である。
【0103】
スキャンAC4 においてラン長が4であるブロック数Z〔4〕(すなわちラン長が3であり、かつカテゴリが0であるブロック数)は、
Z〔4〕=Z〔3〕−(178 + 3 + 0 + 0)= 1704
となる。
【0104】
ラン長が0であるブロック数において、カテゴリ「1」〜「4」のブロック数は、図30より、155、65、24、3となる。また、ラン長が1であるブロック数Z〔1〕(すなわちラン長が0であり、かつカテゴリが0であるブロック数)は、図30より、
Z〔1〕=787
となる。
【0105】
図32は、このようにして求められたラン長・カテゴリの分布の表であり、第1の予測方法における図23に対応している。また図31に示されるように、ラン長が4であるブロック数(ラン長が3であり、かつカテゴリが0であるブロック数)は1704であり、これは第1の予測方法において得られたZ〔4〕=1434よりも大きくなっている。すなわち第3の予測方法によれば、ラン長が伸びることが理解される。
【0106】
次に、図30に示されるようなカテゴリ分布表において、スキャンACi-1 のカテゴリが「0」で、かつスキャンACi のカテゴリが「1」以上のブロック数を図29の折れ線abfghを用いて求める方法を説明する。
【0107】
この場合、図29において横軸はスキャンACi-1 のカテゴリ「0」のブロック数を示し、縦軸はスキャンACi におけるカテゴリ「0」とカテゴリ「1」のブロック数の和を示す。まず、縦軸のOmax をC〔0〕とC〔1〕の和(=4108+810=4918)に定め、これに伴いOhigh、Omid 、Olow を求める。次に、横座標の4366に対応した折れ線上の点(例えばP3)を読み、この点に対応した縦座標を読むと、この値はスキャンAC4 におけるカテゴリ「0」とカテゴリ「1」のブロック数の和である。したがって、この和から、既に求められているカテゴリ「0」の値を引けば、スキャンACi-1 のカテゴリが「0」でかつスキャンACi のカテゴリが「1」のブロック数が求められる。以下、同様にして、スキャンACi-1 のカテゴリが「0」でかつスキャンACi のカテゴリが「2」以上のブロック数が求められる。
【0108】
次に、図33のフローチャートを参照して、図25のステップ106において用いられた設定符号量Si の分布(図13参照)の生成について説明する。
【0109】
ステップ201では、1つの画像の全ブロックに関して、DC成分とスキャンAC63の符号化データの最小限の合計符号量(ビット数)が求められる。DC成分の合計符号量CD0 は、ハフマン符号量とこれに対応する付加ビット数との合計値の最小値HN(0)=2に、全ブロック数を乗じることにより得られる。なお、通常は、カテゴリ「0」においてハフマン符号量と付加ビット数との合計値が最小値をとるので、ここでは最小値HN(0)という符号を用いている。一方、スキャンAC63の合計符号量CD63は、ハフマン符号化における終端データ(EOB)の符号量HN(“EOB”)=4に全ブロック数を乗じることにより得られる。
【0110】
ステップ202では、デフォルトの量子化テーブルを用いた場合における、スキャンAC63を除いた全てのブロックに関する合計符号量CDAが
CDA=Σ(COi /FTi ) (3)
により求められる。ただし、COi は、デフォルトの量子化テーブルを用いた時のスキャンACi の符号量(ビット数)(図12参照)であり、FTi は、スキャンACi のフィルタリングテーブルFL(図34参照)のテーブル値、すなわちフィルタリング係数を示す。なお、Σはパラメータiについて0から62まで加算することを示す。
【0111】
フィルタリングテーブルFLは、例えば図34に示すように各空間周波数に対応したフィルタリング係数FTi から成る。フィルタリング係数FT0 はDC成分に対応し、フィルタリング係数FT1 、FT2 ・・・FT63はスキャンAC1 、AC2 ・・・AC63に対応する。またフィルタリング係数は、データ圧縮の度合いが大きい空間周波数ほど大きい値を有し、したがって図34の例は高周波成分をカットするフィルタを示している。すなわち、高周波成分のフィルタリング係数は20000あるいは30000であり、高周波成分は、(3)式によって大きく圧縮される。
【0112】
ステップ203では、修正係数CDRが
CDR=(SETIM−CD0 −CD63)/CDA (4)
により求められる。ただしSETIMは設定合計符号量であり、例えば524288ビット(64Kbyte)である。修正係数CDRの値は、(3)式によって得られた合計符号量CDAが小さいほど大きくなり、例えば約100である。
【0113】
ステップ204においてパラメータiが0にクリアされた後、ステップ205において、
CODEi =(COi /FTi )×CDR (5)
により、各空間周波数(スキャンACi )における圧縮データの量(ビット数)が求められる。(5)式に示されるように圧縮データ量CODEi は、デフォルトの量子化テーブルを用いた時の符号量COi をフィルタリング係数FTi で割った結果に、修正係数CDRを乗じることによって得られる。
【0114】
ステップ206では、圧縮データ量CODEi がデフォルトの量子化テーブルを用いた時の符号量COi よりも大きいか否かが判定される。圧縮データ量CODEi の方が大きい場合、ステップ207において符号量COi が圧縮データ量CODEi として設定される。換言すると、この場合、量子化係数qがいくらであっても圧縮符号量は符号量COi を越える可能性が低いため、その符号量COi が圧縮データ量CODEi として定められる。
【0115】
これに対し、圧縮データ量CODEi の方が小さい場合、ステップ208においてパラメータiが1だけインクリメントされた後、ステップ209においてパラメータが62より大きいか否かが判定される。パラメータiが62を越えていない場合、ステップ205に戻り、上述した処理が再び実行される。このようにしてスキャンAC62までの圧縮データ量CODEi が設定されると、ステップ210においてスキャンAC63の圧縮データ量CODE63がCD63に設定され、このプログラムは終了する。
【0116】
以上のようにして得られた圧縮データ量CODEi が、図25のステップ106において用いられる設定符号量Si である。
【0117】
図35は、図34に示すフィルタリングテーブルFLにおける各スキャンACi の割当比率を示している。この割当比率は、各AC成分のフィルタリング係数FTi とDC成分のフィルタリング係数FT0 との比の逆数に100を乗じたものであり、例えばスキャンAC2 の場合、フィルタリング係数FT2 は98であるので、割当比率は符号RAにより示すように100よりも大きい。この図から理解されるように、図34のフィルタリングテーブルFLは、高周波成分に対する割当比率が小さく、ローパスフィルタを示している。逆に、ハイパスフィルタのテーブルFLを生成するには、図35の割当比率において、低周波成分に対する割当比率を小さくするようにしてフィルタリング係数を決定すればよい。
【0118】
図36は、第1のローパスフィルタに対応したフィルタリングテーブルを示している。符号(a)は輝度用のフィルタリングテーブルを示し、これは図34のフィルタリングテーブルと同じである。符号(b)は色差用のフィルタリングテーブルを示している。図37は、平均化フィルタに対応したフィルタリングテーブルであり、符号(a)は輝度用のフィルタリングテーブルを示し、符号(b)は色差用のフィルタリングテーブルを示している。図38は、第2のローパスフィルタに対応したフィルタリングテーブルを示している。この例では、輝度用と色差用のフィルタリングテーブルは共通である。図39は、ハイパスフィルタに対応したフィルタリングテーブルを示し、このテーブルも、輝度用と色差用において共通である。
【0119】
【発明の効果】
以上のように本発明によれば、個々の画像の画質に応じた画像圧縮を達成することができるという効果が得られる。
【図面の簡単な説明】
【図1】本発明の一実施例の画像圧縮装置を示すブロック図である。
【図2】画像データP(Y)xy 、DCT変換係数S(Y)uv 、量子化DCT係数R(Y)uv 、量子化テーブルQ(Y)uv の例を示す図である。
【図3】DC係数の差分値のカテゴリを示す図である。
【図4】DC係数の符号化テーブルを示す図である。
【図5】量子化AC係数の符号化を行う処理ルーチンを示すフローチャートである。
【図6】AC係数をハフマン符号化する際に行われるジグザグスキャンを示す図である。
【図7】AC係数のカテゴリを示す図である。
【図8】JPEGにより推奨されたハフマンテーブルを示す図である。
【図9】ハフマン符号化による符号化データの一例を示す図である。
【図10】符号化データの構成要素を示す図である。
【図11】全ての量子化係数が「1」である量子化テーブルを用いた時の所定の空間周波数でのカテゴリ分布の例を示す図である。
【図12】全ての量子化係数が「1」である量子化テーブルを用いた時の、各スキャンにおける符号化データのビット数の分布の例を示す図である。
【図13】空間周波数データ量設定部において設定される各空間周波数毎(すなわちスキャン毎)の符号量の分布の例を示す図である。
【図14】図11に示すカテゴリ分布を各スキャンについて同時に示す図である。
【図15】全ての量子化係数が「16」である量子化テーブルを用いた時のカテゴリ分布の表を示す図である。
【図16】スキャンAC1 のカテゴリ「0」のブロック数と、カテゴリ「1」以上のブロック数を示す図である。
【図17】スキャンAC2 までのラン長が2、1、0であるブロック数を示す図である。
【図18】スキャンAC3 までのラン長が3、2、1、0であるブロック数を示す図である。
【図19】スキャンAC4 までのラン長が4、3、2、1、0であるブロック数を示す図である。
【図20】スキャンAC1 のラン長・カテゴリの表を示す図である。
【図21】スキャンAC2 のラン長・カテゴリの表を示す図である。
【図22】スキャンAC3 のラン長・カテゴリの表を示す図である。
【図23】スキャンAC4 のラン長・カテゴリの表を示す図である。
【図24】JPEGにより推奨されたハフマンテーブルの各符号語の符号長を示す図である。
【図25】量子化テーブルを生成するプログラムのフローチャートである。
【図26】「00」データの分布を示す図である。
【図27】スキャンAC1 とスキャンAC2 の「00」データの正規化を示す図である。
【図28】正規化された「00」データの分布の表を示す図である。
【図29】スキャンACi-1 のカテゴリ「0」のブロック数とスキャンACi-1 とスキャンACi の「00」データとの関係を示す図である。
【図30】スキャンAC4 におけるカテゴリ分布の例を示す図である。
【図31】第3の予測方法によって得られたラン長・カテゴリの分布の例を示す図である。
【図32】図31のラン長・カテゴリの分布の表を図23に対応した形式で表した図である。
【図33】設定符号量Si の分布を生成するプログラムのフローチャートである。
【図34】フィルタリングテーブルの一例を示す図である。
【図35】図34のフィルタリングテーブルにおける各スキャンの割当比率を示す図である。
【図36】第1のローパスフィルタのフィルタリングテーブルを示す図である。
【図37】平均化フィルタのフィルタリングテーブルを示す図である。
【図38】第2のローパスフィルタのフィルタリングテーブルを示す図である。
【図39】ハイパスフィルタのフィルタリングテーブルを示す図である。
【符号の説明】
M ICメモリカード[0001]
[Industrial application fields]
The present invention relates to an image compression apparatus that compresses information of a color still image according to a JPEG algorithm.
[0002]
[Prior art]
A standardized algorithm that encodes a high-resolution image and exchanges information via a communication transmission path is recommended by JPEG (Joint Photographic Expert Group). In the JPEG recommended algorithm, that is, the baseline process of the JPEG algorithm, in order to perform significant information compression, the original image data is first decomposed into components on the spatial frequency axis by two-dimensional DCT transformation, and Each data represented on the spatial frequency axis is quantized using a quantization table, and each quantized data is encoded. JPEG recommends a predetermined Huffman table for this encoding.
[0003]
In a conventional image compression apparatus, a default quantization table is usually used, and a modified quantization table is created as necessary by multiplying each quantization coefficient of the quantization table by a single coefficient. Yes.
[0004]
[Problems to be solved by the invention]
In this way, the modified quantization table is obtained by uniformly multiplying each spatial frequency by a coefficient. Therefore, characteristics of individual images (for example, there are many high frequency components compared to low frequency components, etc.) Therefore, it is difficult to say that the image data is compressed without degrading the image quality.
[0005]
In view of the above problems, an object of the present invention is to provide an image compression apparatus that can achieve image compression according to the image quality of each image.
[0006]
[Means for Solving the Problems]
An image compression apparatus according to the present invention performs orthogonal transformation on original image data to obtain an orthogonal transformation coefficient for each spatial frequency, and quantizes the orthogonal transformation coefficient by a quantization table composed of predetermined quantization coefficients. Quantization means for obtaining a quantized orthogonal transform coefficient, and after rearranging the quantized orthogonal transform coefficient into predetermined one-dimensional array data with respect to the spatial frequency, encoding is performed based on the quantized orthogonal transform coefficient. Based on the encoding means to be obtained, the quantized orthogonal transform coefficient obtained by quantization with the default quantization table in which all the quantization coefficients are 1, and a predetermined filtering table, the encoded data for each spatial frequency A means for setting a target value for the data amount and a quantizer for determining a quantization coefficient corresponding to the spatial frequency so that the data amount for each spatial frequency is less than the target value. It is characterized in that an arithmetic unit.
[0007]
【Example】
Hereinafter, the present invention will be described based on illustrated embodiments.
FIG. 1 is a block diagram of an image compression apparatus according to an embodiment of the present invention.
[0008]
Light coming from the subject S is collected by the condenser lens 11, and a subject image is formed on a light receiving surface of a CCD (solid-state imaging device) 12. A large number of photoelectric conversion elements are arranged on the light receiving surface of the CCD 12, and a color filter made up of, for example, R, G, and B color filter elements is provided on the upper surface of the photoelectric conversion elements. Each photoelectric conversion element corresponds to one pixel. The subject image is converted into an electrical signal corresponding to a predetermined color by each photoelectric conversion element and input to the A / D converter 13. In the configuration of FIG. 1, only one CCD 12 is provided, but a configuration in which two or more CCDs are provided may be used.
[0009]
The signal A / D converted by the A / D converter 13 is converted into a luminance signal Y and color difference signals Cb and Cr by a signal processing circuit (not shown) and input to the image memory 14. The image memory 14 is divided into mutually independent memory areas for storing the luminance signal Y and the color difference signals Cb and Cr, and each memory area has a storage capacity for one image.
[0010]
The luminance signal Y and the color difference signals Cb and Cr read from the image memory 14 are input to the DCT processing circuit 21 for data compression processing. In the DCT processing circuit 21, the original image data such as the luminance signal Y is subjected to discrete cosine transform (hereinafter referred to as DCT). That is, in this embodiment, DCT transformation is used as orthogonal transformation of original image data. In FIG. 1, the DCT processing circuit 21 is shown as one processing circuit, but actually, an independent DCT processing circuit is provided for each of the luminance signal Y and the color difference signals Cb and Cr.
[0011]
The image compression apparatus includes a DCT processing circuit 21, a quantization processing circuit 22, a Huffman coding processing circuit 23, a spatial frequency data amount setting unit 24, a quantization table generation unit 25, and the like. In the DCT processing circuit 21, the quantization processing circuit 22, and the Huffman coding processing circuit 23, image data such as the luminance signal Y is divided into a plurality of blocks for one screen and processed in units of blocks. Each block is composed of 8 × 8 pixel data.
[0012]
The luminance signal Y and the DCT coefficients of the color difference signals Cb and Cr obtained in the DCT processing circuit 21 are respectively input to the quantization processing circuit 22. Similarly to the DCT processing circuit 21, the quantization processing circuit 22 is also provided for each signal. The DCT coefficients of the luminance signal Y and the color difference signals Cb and Cr input to the quantization processing circuit 22 are respectively quantized by a quantization table Q1 configured by 8 × 8 quantization coefficients. This quantization is linear quantization, i.e. each DCT coefficient is divided by the corresponding quantization coefficient.
[0013]
In this embodiment, the quantization table Q1 for quantizing the DCT coefficients of the luminance signal Y and the quantization table Q1 for quantizing the DCT coefficients of the color difference signals Cb and Cr are different from each other in accordance with the JPEG algorithm. However, the same quantization table Q1 may be used for each signal. As will be described later, these quantization tables Q1 are generated by the spatial frequency data amount setting unit 24 and the quantization table generation unit 25 according to the properties such as the spatial frequency distribution of the original image data.
[0014]
The quantized DCT coefficients of the luminance signal Y and the color difference signals Cb and Cr output from the quantization processing circuit 22 are input to the Huffman encoding processing circuit 23 and are Huffman encoded by a predetermined algorithm using the Huffman table Q2.
[0015]
An image signal (compressed image data) obtained by Huffman coding is recorded on a recording medium such as an IC memory card.
[0016]
FIG. 2 shows, as an example, image data P (Y) xy of a block of 8 × 8 pixels, DCT coefficient S (Y) uv, quantized DCT coefficient R (Y) uv, and quantization table Q (Y). uv.
[0017]
The image data P (Y) xy in FIG. 2A is converted into 8 × 8 = 64 DCT coefficients S (Y) uv shown in FIG. 2B by two-dimensional DCT conversion. Among these DCT coefficients, the DCT coefficient S (Y) at the position (0, 0)00Is a DC component, and the remaining 63 DCT coefficients S (Y) uv are AC components. The AC component is the coefficient S (Y)01Or coefficient S (Y)TenTo coefficient S (Y)77FIG. 9 shows how much higher spatial frequency components exist in the image data of the 8 × 8 pixel block. The DC component represents an average value (DC component) of pixel values of the entire 8 × 8 pixel block. That is, each DCT coefficient S (Y) uv corresponds to a predetermined spatial frequency.
[0018]
FIG. 2D shows an example of the quantization table Q (Y) uv used in the quantization processing circuit 21. Such a quantization table Q (Y) uv may be different for the luminance signal Y and the color difference signals Cb and Cr as described above. The quantization table Q (Y) uv is stored in the position corresponding to each signal when the image data in the JPEG format is recorded on the recording medium, in the quantization table Q (Y) uv used for quantization of the signal. The contents are recorded.
[0019]
An expression for quantizing the DCT coefficient S (Y) uv using the quantization table Q (Y) uv is defined as follows.
R (Y) uv = round (S (Y) uv / Q (Y) uv) {0 ≦ u, v ≦ 7}
Round in this equation means an approximation to the nearest integer. That is, the quantized DCT coefficient R (Y) uv as shown in FIG. 2C is obtained by dividing and rounding the elements of the DCT coefficient S (Y) uv and the quantization table Q (Y) uv. It is done.
[0020]
The quantized DCT coefficients R (Y) uv, R (Cb) uv, and R (Cr) uv obtained by the quantization processing circuit 22 in this way are input to the Huffman coding processing circuit 23.
[0021]
Next, Huffman coding in the Huffman coding processing circuit 23 will be described with reference to FIGS. In the following description, a quantized DC coefficient refers to a quantized DC component, and a quantized AC coefficient refers to a quantized AC component.
[0022]
Quantized DC coefficient R (Y)00And quantized AC coefficient (quantized DC coefficient R (Y)00Quantization DCT coefficients (R (Y) uv) other than are different in encoding method. Quantized DC coefficient R (Y)00Is encoded as follows.
[0023]
First, the quantized DC coefficient R (Y) of the block to be encoded at present00And the quantized DC coefficient R (Y) of the previously coded block00The difference is obtained. It is determined to which of the categories shown in FIG. 3 this difference value belongs, and a code word representing the category is obtained from the code table (DC component coding table) shown in FIG. For example, the quantized DC coefficient R (Y) of the block to be encoded at present00Is “16”, and the quantized DC coefficient R (Y) of the block previously encoded is003 is “−9”, the category to which the difference value = −9 belongs is determined to be “4” from the category table of FIG. From the code table of 4, it is determined as “101”.
[0024]
Next, in the category table of FIG. 3, the difference value is what number in the category is represented by an additional bit. For example, since the difference value = −9 is the seventh from the smallest in the category = 4 group, the additional bit is “0110”. That is, the quantized DC coefficient R (Y) of the currently encoded block00The Huffman codeword is “1010110”.
[0025]
On the other hand, encoding of the quantized AC coefficient is performed by a processing routine shown in FIG. First, in step 120, 63 quantized AC coefficients are zigzag scanned in the order shown in FIG. 6 and rearranged into one-dimensional array data. The quantized AC coefficients are scanned according to the zigzag scan order.1, AC2... AC63I will call it. Next, in step 122, it is determined whether or not each quantized AC coefficient arranged in one dimension is “0”. When the quantized AC coefficient is “0”, the number of consecutive quantized AC coefficients that are “0” is counted in step 124. Thus, a length in which “0” continues, that is, a run length is obtained.
[0026]
On the other hand, when it is determined in step 122 that the quantized AC coefficient is not “0”, in step 126, grouping similar to the quantized DC coefficient is performed and additional bits are obtained. This grouping of quantized AC coefficients is performed on the quantized AC coefficients themselves, unlike the grouping of quantized DC coefficients. That is, when the quantized AC coefficient is “4”, for example, the category “3” is obtained with reference to the table shown in FIG. Further, since the quantized AC coefficient “4” is the fifth smallest from the category = 3 group, the additional bit is “100”.
[0027]
In step 130, referring to the AC code table of the Huffman table (FIG. 8), for example, when the run length of the data immediately before the quantized AC coefficient “4” is “0”, the run length and category = 3 are set. Based on this, the code word “100” is obtained. Then, the two-dimensional Huffman code word “100100” is obtained by combining this code word “100” and the additional bit “100” obtained in step 126.
[0028]
The result of Huffman encoding the quantized DCT coefficient in FIG. 2C is shown as encoded data HF in FIG.
[0029]
FIG. 10 shows the encoded data HF shown in FIG. 9 again. Such encoded data HF is obtained for each block. When one screen is composed of 5400 blocks, only 5400 encoded data HF is obtained. As described above, the encoded data HF includes encoded data relating to one quantized DC coefficient and encoded data relating to 63 quantized AC coefficients.
[0030]
The encoded data related to the quantized DC coefficient includes a category code word FA0 and an additional bit FB0. The encoded data related to the quantized AC coefficient includes a run length / category code word and additional bits. Next, the encoded data regarding the quantized AC coefficient will be described in more detail.
[0031]
In the example of FIG. 9, the scan AC1Is encoded data based on the fact that the run length is 0 and the run length / category code word FA1 and the additional bit FB1 are generated, and the scan AC2Is encoded data based on the fact that the run length is 0 and the run length / category code word FA2 and the additional bit FB2 are generated. Scan ACThreeIs 0, and therefore, after the additional bit FB2, the scan ACFourAs the encoded data based on the fact that the run length is 1 and the run length is 1, the run length / category code word FA4 and the additional bit FB4 are generated. Similarly, a run length / category code word FA5 and additional bits FB5, a run length / category code word FA8 and additional bits FB8, and a run length / category code word FA9 and additional bits FB9 are generated. End data (EOB) is scan ACTenThereafter, all indicate that 0 continues.
[0032]
Next, generation of the quantization table Q1 will be described.
As shown in FIG. 1, the quantization table Q1 is generated based on the set total code amount, the DCT data statistic, and the filtering table FL.
[0033]
The set total code amount is the total number of bits of the encoded data HF for one screen recorded on the recording medium, and is, for example, 524288 bits (64 Kbytes). The DCT data statistic is obtained based on the output data of the DCT processing circuit 21. The output data of the DCT processing circuit 21 is obtained by DCT transforming the original image data, and a quantization table Q1 (hereinafter referred to as a default quantization table) in which 8 × 8 quantization coefficients are all “1” is used. Is equivalent to the quantized one. The output data is zigzag scanned (see FIG. 6), the run length and the category are obtained (see FIG. 5), and then the bit length for each spatial frequency is obtained with reference to the table shown in FIG. Data statistics are obtained. That is, the DCT data statistics are a category distribution as shown in FIG. 11 and a code amount distribution for each scan as shown in FIG. The filtering table FL determines the degree of data compression at each spatial frequency. As will be described later, the filtering table FL has a filtering coefficient corresponding to each spatial frequency, and each filtering coefficient has a larger value as the spatial frequency has a higher degree of data compression.
[0034]
FIG. 11 shows a predetermined spatial frequency (for example, scan AC) when the default quantization table is used.1) Category distribution, that is, an example of the number of blocks classified into each category. As for the category distribution as shown in this figure, in one image, those relating to DC components and those relating to 63 AC components are generated, that is, only 64 category distributions are generated in total. In this embodiment, the original image data is divided into 5400 blocks. In the example of FIG. 11, the number of blocks whose category is 0 is 602, and the number of blocks whose category is 1 is 1088.
[0035]
FIG. 12 is an example of the distribution of the number of bits of the encoded data HF in each scan when the default quantization table is used. This is the total number of bits for each spatial frequency for all blocks of one image. Show. For example, in the case of a DC component, the total number of bits of the category code word FA0 and the additional bits FB0 (see FIG. 10) is 42238 (code DB0). Scan AC1In this case, the total number of bits of the run length / category code word FA1 and the additional bit FB1 is 34,010 (code DB1), and scan AC2In this case, the total number of bits of the run length / category code word FA2 and the additional bits FB2 is 33833 (code DB2). In the example of FIG. 10, scan ACThreeThere are no run-length / category codewords and additional bits for scan AC in other blocksThreeTherefore, the total number of bits is 25920 (code DB3). In this way, the scan AC63The total number of bits up to 20909 (code DB 63) is generated.
[0036]
The set total code amount, DCT data statistic, and filtering table FL are input to the spatial frequency data amount setting unit 24. The spatial frequency data amount setting unit 24 sets the distribution of code amounts for each spatial frequency (ie, for each scan) as shown in FIG. 13, for example, based on the set total code amount, the DCT data statistic, and the filtering table FL. Is done. That is, the code amount of the DC component is 44240 bits (code SB0), scan AC1Code amount is 33008 bits (code SB1), scan AC2The code amount is 35629 bits (code SB2), and the scan AC63Is set up to the code amount (reference SB63). The total value of these code amounts, that is, the set total code amount is determined to be a predetermined value (524288 bits in the example of FIG. 13).
[0037]
This code amount (data amount) is a target value, and in this image compression apparatus, the quantization table Q1 is generated so that the code amount for each spatial frequency becomes this target value, as will be described later. That is, this code amount distribution is the target value of the code amount for each spatial frequency in the Huffman encoded data when the finally obtained quantization table Q1 is used. For example, when it is desired to cut a high frequency component, the code amount related to the high frequency component is determined to be relatively small, and the distribution of the code amount is set based on the filtering table FL.
[0038]
Further, the spatial frequency data amount setting unit 24 may determine the upper limit value of the code amount for each spatial frequency by using the code amount distribution for each scan (see FIG. 12) in the DCT data statistics. For example, in FIG.FourIs defined as 28844 (code SB4), but may be limited to 28461 bits based on the code amount distribution of the DCT data statistics (see code DB4 in FIG. 12).
[0039]
In the quantization table generation unit 25, each quantization coefficient constituting the quantization table Q1 is generated based on the DCT data statistic and the input data from the spatial frequency data amount setting unit 24.
[0040]
A method for obtaining the quantization coefficient for the DC component will be described.
First, DC components of all blocks are quantized using a default quantization table (a quantization table in which all quantization coefficients are 1). Then, the difference value between the quantized DC coefficient of the block for which the current quantized coefficient is to be obtained and the quantized DC coefficient of the previous block is obtained.
[0041]
It is determined to which of the categories shown in FIG. 3 this difference value belongs, and a code word representing the category is obtained from the code table (DC component coding table) shown in FIG. Further, the number of additional bits corresponding to the difference value is obtained from the category table of FIG. For example, when the category of the difference value is “2”, the code length is 3 bits and the number of additional bits is 2 bits. Therefore, the code amount of the quantized DC coefficient whose difference value category is “2” is 5 bits.
[0042]
In this way, the code amount of the quantized DC coefficient is obtained for each block, and the total code amount (number of bits) is obtained. If this total code amount is equal to or less than the DC component code amount (code SB0) shown in FIG. 13, the quantization coefficient at that time is determined as the final one. If the total value is larger than the code amount (code SB0) in FIG. 13, then the quantization coefficient is changed to 2, and the total number of bits as described above is examined using this quantization coefficient. Is called.
[0043]
In order to obtain the total number of bits when this new quantization coefficient is used, it is necessary to predict the number of blocks corresponding to each category. That is, it is necessary to obtain a category distribution table as shown in FIG. An example of how to obtain this category distribution table will now be described with reference to FIG.
[0044]
For example, the difference values belonging to the category “2” are −3, −2, 2, and 3. When the quantization coefficient is 2, since the difference value “2” is 2/2 = 1, the process moves to the category “1”. The same applies to the difference value “−2”. On the other hand, since the difference value “3” is 3/2 = 1.5≈2, the category “2” remains unchanged. The same applies to the difference value “−3”. Accordingly, in this example, of the difference values belonging to the category “2” when the quantization coefficient is 1, half changes to the category “1” and half remains the category “2”. In this way, the category distribution when the quantization coefficient changes is predicted, and the total code amount is obtained by using this category distribution table.
[0045]
Next, how to obtain the quantization coefficient for the AC component will be described.
As for the AC component, data relating to run length is included in the Huffman encoded data (eg, codes FA1, FA2, FA4, etc. in FIG. 10), and the run length changes when the quantization coefficient is changed. Therefore, the data amount of each scan when the quantization coefficient is changed cannot be predicted based only on the data amount of the scan before changing the quantization coefficient. Therefore, in this embodiment, as described below, the data amount of each scan when the quantization coefficient is changed is predicted using a category distribution table, and the quantization coefficient is determined based on the predicted value. ing.
[0046]
FIG. 14 is an example of a table that simultaneously shows the category distribution shown in FIG. 11 for each scan. That is, this category distribution table indicates the number of blocks classified into each category at each spatial frequency when the default quantization table is used. In FIG. 14, the DC component and the scan AC1To scan AC11Scan AC shown12To scan AC63Up to is omitted. In FIG. 14, the uppermost number indicates a category. For example, scan AC1, The number of blocks in category “0” is 602, and the number of blocks in category “1” is 1088.
[0047]
Unlike FIG. 14, FIG. 15 shows a table of category distribution when using a quantization table in which all quantization coefficients are “16”. As can be understood from FIG. 7, the AC component values in the categories “0” to “3” when the quantization coefficient “1” is used are 0 when the quantization coefficient “16” is used. The category of the AC component value is “0”. That is, the scan AC in FIG.1The 3479 category “0” blocks correspond to the blocks 602, 1088, 1184, and 605 of categories “0” to “3” in FIG. 14.
[0048]
Similarly, when the quantization coefficient “1” is used, the AC component value of the category “4” is −1 or 1 when the quantization coefficient “16” is used. Therefore, the category of the AC component value is “1”. It becomes. On the other hand, the AC component value of the category “5” when the quantization coefficient “1” is used may be 1 or 2 when the quantization coefficient “16” is used. Therefore, when the quantization coefficient “16” is used, the category of AC component values of some blocks is “1”, and the category of AC component values of other blocks is “2”. That is, the scan AC in FIG.1The 866 category “1” blocks correspond to the 529 block of the category “4” and the partial block of the category “5” in FIG. As described above, when the quantization coefficient is changed, a block belonging to a certain category does not always move to another category but may move to a different category.
[0049]
Next, scan ACi-1, ACiThe prediction of the number of blocks in which both categories are “0” will be described with reference to FIGS.
[0050]
16 to 19, C [0] is the number of blocks of category “0” in the scan, and C [1] is the number of blocks of category “1” or more in the scan. Z [k] is a predicted value of the number of blocks whose run length is k. C ′ [0] is the number of blocks of category “0” in the previous scan, and Z ′ [0] is the number of blocks whose run length is 0 in the previous scan.
[0051]
FIG. 16 shows scan AC1The number of blocks in category “0” and the number of blocks in category “1” or more are shown. Scan AC1As shown in FIG. 15, the number of blocks C [0] in the category “0” is 3479, and the number of blocks C [1] in the category “1” or more is 1921 (= 5400-3479). Therefore, scan AC1The number of blocks Z [1] whose run length is 1 is 3479, and the number of blocks Z [0] whose run length is 0 is 1921.
[0052]
FIG. 17 shows a scan AC2The number of blocks whose run lengths are 2, 1, 0 are shown. Scan AC2As shown in FIG. 15, the number of blocks C [0] in the category “0” is 3619, and the number of blocks C [1] in the category “1” or more is 1781. Therefore, it is clear that the number of blocks Z [0] whose run length is 0 is 1781, but the number of blocks Z [2] whose run length is 2 and the number of blocks Z [1] whose run length is 1 Is not clear. Therefore, in this embodiment, the ratio of the number of blocks Z [2] to the number of blocks Z [1]1Assuming that the number of blocks Z [1] whose run length is 1 and the number of blocks Z ′ [0] whose run length is 0 is equal to the ratio of the number of blocks Z [2] and the number of blocks Z [1] ] Is expected. That is, in this embodiment, the scan AC1, AC2The number of blocks whose category is “0” in both1Is related to the number of blocks of category “0” in FIG.
[0053]
The number of blocks Z [2] obtained in this way is the scan AC1, AC2Scan AC when both categories are “0”2It corresponds to. The number of blocks Z [1] is the scan AC1Scan AC with category “0” when category is other than “0”2It corresponds to.
[0054]
FIG. 18 shows a scan ACThreeThe number of blocks with run lengths up to 3, 2, 1, 0 is shown. Scan ACThreeAs shown in FIG. 15, the number of blocks C [0] in the category “0” is 4366, and the number of blocks C [1] in the category “1” or more is 1034. Therefore, the number of blocks Z [0] is 1034. The number of blocks Z [1] is the scan AC2Assuming that it depends on the ratio of the number of blocks Z ′ [0] at
Z [1] = 4366 × 1781/5400 = 1440
It becomes. On the other hand, the ratio of the number of blocks Z [2], [3]2Is equal to the ratio of the number of blocks Z [1], [2] at
Z [2] = 4366 × 1287/5400 = 1041
Z [3] = 4366 × 2332/5400 = 1888
It becomes.
[0055]
The number of blocks Z [3] is the scan AC1, AC2, ACThreeScan AC when both categories are “0”ThreeIt corresponds to. The number of blocks Z [2] is the scan AC1Category other than "0" and scan AC2Scan AC with category “0” when category is “0”ThreeIt corresponds to. The number of blocks Z [1] is the scan AC2Scan AC with category “0” when category is other than “0”ThreeIt corresponds to.
[0056]
Figure 19 shows Scan ACFourBlocks with run lengths up to 4, 3, 2, 1, 0 are shown. Scan ACFourThereafter, the above-described processing is performed, and the number of blocks Z [k] whose run length is k is obtained.
[0057]
In this way, scan AC63When the run lengths up to are calculated, run length / category tables as shown in FIGS. 20 to 23 are created for each category.
[0058]
FIG. 20 shows a scan AC1The run length / category table of FIG. 5 shows a category distribution other than the category “0” in which the run length is 0. Scan AC1The total number of blocks other than the category “0” is 1921 (= Z [0]) as shown in FIG. As shown in FIG. 15, the category distribution is 866, 519, 300, 212, 24 in the order of categories “1”, “2”... “5”, and the number of blocks of category “6” or more is 0. It is. By transcribing this numerical value as it is, the table of FIG. 20 is created.
[0059]
FIG. 21 shows a scan AC2The run length / category table of FIG. 2 shows a category distribution with run lengths of 0 and 1 and a category other than category “0”. Scan AC2The total number of blocks other than the category “0” is 1781 (= Z [0]) as shown in FIG. As shown in FIG. 15, the category distribution is 850, 487, 315, 119, 10 in the order of categories “1”, “2”... “5”, and the number of blocks of category “6” or more is 0. It is. The 850 block of category “1” has a ratio of Z [1] and Z [2] shown in FIG.1Assuming that the number of blocks Z ′ [0] with a run length of 0 is equal to the ratio of the number of blocks Z [1] with a run length of 1, the number of blocks with a run length of 0 is 302, The number of blocks with 1 is set to 548. Similarly, for the 487 blocks in category “2”, the number of blocks with a run length of 0 is 173, and the number of blocks with a run length of 1 is 314. In this way, the table of FIG. 21 is created.
[0060]
FIG. 22 shows a scan ACThreeThe run length / category table of FIG. 1 shows a category distribution with run lengths of 0, 1, and 2 and a category other than “0”. Scan ACThreeThe number of blocks other than the category “0” is 1034 (= Z [0]) in total as shown in FIG. As shown in FIG. 15, the category distribution is 675, 220, 121, 18 in the order of categories “1”, “2”... “4”, and the number of blocks of category “5” or more is 0. . The number of blocks in each category is distributed to 0, 1 and 2 blocks according to the ratio of Z [1], Z [2] and Z [3] shown in FIG.
[0061]
FIG. 23 shows a scan ACFourIt is a table of run length and category. This table is also created with reference to FIGS. 15 and 19 by the processing described above. In this way, scan AC63A run length / category table is created.
[0062]
Next, the data amount (number of bits) in each scan is calculated with reference to the run length / category tables as shown in FIGS. For this calculation, the code length table shown in FIG. 24 is used. Each numerical value in this table indicates the code length of each codeword of the Huffman table recommended by JPEG. For example, the code length of a codeword having a run length of 1 and a category of 2 is 5.
[0063]
Scan AC1For FIG. 20 and FIG. 24, the run length / category codeword bits in all blocks are
866 x 2 + 519 x 2 + 300 x 3 + 212 x 4 + 24 x 5 = 4638
It becomes. On the other hand, for additional bits, the category number directly corresponds to the number of bits, so the number of additional bits is
866 x 1 + 519 x 2+ 300 x 3 + 212 x 4 + 24 x 5 = 3772
It becomes. Therefore scan AC1Expected data volume is
  4638 + 3772 = 8410 (bits)
It is.
[0064]
Scan AC2~ Scan AC63Also about scan AC1The amount of data can be obtained by the same calculation as.
[0065]
The amount of data in each scan obtained in this way must be less than or equal to the set code amount shown in FIG. For example, scan AC1Must be limited to 33008 bits or less. In the above example, since the quantization coefficient is set to “16” for the purpose of explaining the embodiment, the data amount is 8410 bits, which is considerably smaller than the set code amount. Therefore, in practice, a numerical value smaller than “16” is appropriate for the quantization coefficient. That is, if the expected data amount when the quantized coefficient is “1” is larger than 33008 bits, the quantized coefficient is increased by 1 and the expected data amount is recalculated. A quantization coefficient that is less than the code amount is obtained.
[0066]
The generation of the quantization table described above will be described with reference to the flowchart of FIG. This flowchart shows the scan AC2~ AC63Shows the generation of quantization coefficients for the DC component and the scan AC1It is assumed that the quantization coefficient of is already obtained.
[0067]
In step 101, the parameter i is set to 2. In step 102, the quantization coefficient q is set to 1 as an initial value.
[0068]
In step 103, the scan AC as shown in FIG.iA category distribution is generated. For example, when the parameter i is 3 and the quantization coefficient q is 16, this category distribution is as shown in FIG.
  4366, 675, 220, 121, 18, 0, 0, 0, 0, 0, 0
It is.
[0069]
Before step 103 is executed, as shown by reference numeral P11, scan ACi-1The number of blocks of category “0” is calculated. For example, parameter i is 3 and scan AC2If the quantization coefficient q of the scan AC is 16, the scan AC2The number of blocks in category “0” is 3619 in the example of FIG. Further, as indicated by reference numeral P12, the scan ACi-1The distribution of the number of blocks of category “0” is calculated. For example, parameter i is 3 and scan AC2If the quantization coefficient q of the scan AC is 16, the scan AC2In the example of FIG. 17, the number of blocks Z [2] is 2332, the number of blocks Z [1] is 1287, and the number of blocks Z [0] is 1781.
[0070]
In step 104, the scan AC obtained in step 103 is obtained.iCategory distribution and scan ACi-1Number of blocks of category “0” (symbol P11) and scan ACi-1Based on the distribution of the number of blocks of the category “0” (symbol P12)iThe distribution of the number of blocks of category “0” in is predicted. For example, when the parameter i is 3 and the quantization coefficient q is 16, the scan ACThreeIn the example of FIG. 18, the number of blocks Z [3] is 1885, the number of blocks Z [2] is 1041, and the number of blocks Z [1] is 1440 based on the data of FIGS.
[0071]
In step 105, the scan ACiThe predicted data amount of the compressed data is calculated. For example, when the parameter i is 3 and the quantization coefficient q is 16, the scan ACThreePredicted data amount DiFrom the run length / category table of FIG. 22 and the code length table of FIG.
    223 x 2 + 73 x 2 + 40 x 3 + 6 x 4
+ 161 x 4 + 52 x 5 + 29 x 7 + 4 x 9
+ 291 x 5 + 95 x 8 + 52 x 10 + 8 x 12
+ (223 + 161 + 291) + (73 + 52 + 95) x 2
+ (40 + 29 + 52) x 3 + (6 + 4 + 8) x 4
= 6260 (bit)
It becomes.
[0072]
In step 106, the predicted data amount D calculated in step 105 is displayed.iIs the set code amount S as shown in FIG.iIt is determined whether or not. In the example of the description of step 105 described above, since the quantization coefficient q is 16, the predicted data amount DiBecomes 6260 bits, and the set code amount S in FIG.Three= 24042 (reference SB3). However, in practice, since the quantization coefficient q is started from 1, the predicted data amount D is initially set.iIs the set code amount SiBigger than. Therefore, after it is confirmed in step 107 that the quantization coefficient q has not yet reached 255, the quantization coefficient q is incremented by 1 in step 108 and the process returns to step 103 again.
[0073]
Then, Steps 103 to 105 are executed again. In Step 106, the predicted data amount DiIs the set code amount SiIf it is determined that it is the following, the quantization coefficient q is determined thereby. That is, the process proceeds from step 106 to step 110, and it is determined whether or not the parameter i has reached 63. When the parameter i does not reach 63, in step 111, the set code amount S for the next scani + 1Is the set code amount SiAnd predicted data amount DiOnly the difference is added. That is, the set code amount S of the next scani + 1Is the previous scan set code amount SiThe amount not used in is allocated.
[0074]
Next, in step 112, the parameter i is incremented by 1, and the process returns to step 102, and steps 102 to 108 are executed for the next scan to obtain the quantization coefficient.
[0075]
If it is determined in step 110 that the parameter i has reached 63, the process proceeds to step 113, where a quantized coefficient is generated based on the quantized coefficient q, and this program ends.
[0076]
Each scan AC described with reference to FIGS.iThe first method of predicting the amount of data is a relatively simple example, and is not necessarily a highly accurate prediction. Therefore, the second prediction method with higher accuracy will be described next with reference to FIGS.
[0077]
FIG. 26 shows the distribution of “00” data, that is, scan AC.i-1And scan ACiBoth indicate the number of blocks of category “0”, and corresponds to the category distribution table of FIG. For example, scan AC1, AC2The number of blocks in category “0” is 120 (reference code J12), Scan AC2, ACThreeAre 159 (symbol Jtwenty three), Scan ACThree, ACFourAre 186 (symbol J34), Scan AC62, AC63The number of blocks in category “0” is 327 (reference code J6263).
[0078]
Scan ACi-1, ACiWhen the number of blocks each of which is in category “0” changes, scan ACi-1, ACiThe number of blocks whose category is category “0” is scan ACi-1Rate of change in the number of blocks and scan ACiIs proportional to the product of the rate of change of For example, scan ACi-1, ACiAssuming that the number of blocks has doubled, scan ACi-1, ACiThe number of blocks in which both are in category “0” is quadrupled. Under such assumption, scan ACi-1And ACiBased on the number of blocks of category “0”, the scan AC after quantizationi-1, Scan AC after quantizationiBoth predict the number of blocks of category “0”.
[0079]
The distribution of “00” data is normalized by setting the reference value of the number of blocks to 3500, and is stored in the memory. For example, scan AC1, AC2The number of blocks in which both are in category “0” is converted into 3823 as shown in FIG. 27 by normalization. FIG. 28 shows a table of normalized “00” data distribution, eg, scan AC1, AC2“00” data of 3823 (symbol K12), Scan AC2, ACThree"00" data of 3577 (reference code Ktwenty three), Scan ACThree, ACFour“00” data of 3280 (code K34), Scan AC62, AC63"00" data is 2262 (code KJ6263).
[0080]
FIG. 29 shows a scan AC of category “0”.i-1The number of blocks on the horizontal axis and scan ACi-1, ACiAre graphs with the vertical axis representing the number of blocks of category “0” (ie, “00” data). In this graph, the maximum value of the abscissa is the total number of blocks (5400), and SlowIs the above-mentioned reference value 3500, SmidFor example 4800, ShighFor example, 5150. Maximum value of ordinate OmaxIs variable, maximum value OmaxWhen the reference value is 3500, OhighFor example 3403, OmidFor example 3144, OlowFor example, 2463. The break points f, g, and h are obtained by trial and error, for example, so that the quality of the reproduced image is close to that of the original image, but the break point b is the scan AC as described below.i-1, ACiVaries according to the number of blocks of category “0”.
[0081]
The method for obtaining the break point b will be described by taking the case of FIG. 15 as an example.
For example, scan ACThreeThe number of blocks in category “0” is 4366, and scan ACFourThe number of blocks in category “0” is 4108.
[0082]
First, referring to the table of FIG.Three, ACFourAs “00” data of K,34= 3280 is obtained. Next, in FIG. 29, the maximum value OmaxWith the reference value 3500 set to SlowReading the ordinate corresponding to (3500) gives point c. A straight line L1 connecting the origin a and the point c, and OlowWhen the intersection point b with the straight line L2 extending in the horizontal direction from is obtained, a broken line abfgh is obtained.
[0083]
Next, the maximum ordinate OmaxScan ACFourTo match the number of blocks 4108, OhighIs 3994, OmidIs 3690, OlowBecomes 2891. In this state, scan AC in the abscissaThreeWhen reading the ordinate of the point P3 on the polygonal line bf corresponding to the number of blocks 4366, 3530 is a scan ACThree, ACFourObtained as “00” data. This numerical value corresponds to the sum of Z [2], Z [3], and Z [4] (= 3321) in FIG. 19, and is larger than the example of FIG. That is, according to the second prediction method, scan ACThree, ACFourThere are more “00” data than in the first prediction method.
[0084]
The “00” data obtained in this way is distributed to Z [2], Z [3] and Z [4] by the method described below.
[0085]
For this distribution, a scan AC as shown in FIG.2, ACThreeZ [1], Z [2], Z [3] values related to the "00" data are required, and in order to obtain these Z [1], Z [2], Z [3] Scan AC as shown in FIG.1, AC2Z [1] and Z [2] values related to “00” data are required.
[0086]
Scan AC1, AC2Z [1] and Z [2] are obtained by creating a broken line abfgh in the same manner as in FIG. 29 and reading the points on the broken line. Z [2] is obtained directly from the broken line, and Z [1] is obtained as the difference between C [0] and Z [2]. Scan AC2, ACThreeFor Z, the sum of Z [2] and Z [3] is obtained by creating a broken line abfgh and reading the points on this broken line, and Z [1] is the Z [2] and Z [3] It is obtained by subtracting the sum from C [0]. Each value of Z [2] and Z [3]1, AC2Are distributed according to the ratio of Z [1] and Z [2]. That is, scan AC2, ACThreeEach value of Z [1], Z [2], Z [3] is obtained.
[0087]
Similarly, scan ACThree, ACFourZ [2], Z [3], and Z [4] values of the scan AC2, ACThreeAre distributed according to the ratio of Z [1], Z [2] and Z [3]. As a result, a run length / category table as shown in FIG. 23 is obtained.FourThe predicted data amount of the compressed data at is calculated. Similar calculations are performed for other scans to obtain the predicted data amount.
[0088]
Next, scan ACiA third method for predicting the data amount will be described.
Scan ACi-1The number of blocks whose run length is k in Z [k] and scan ACi-1The total number of blocks with category “0” in ZALL, Scan ACi-1Category “0” and scan ACiThe number of blocks of category “j” in CTjAnd The correction coefficient is ZW.
[0089]
Scan ACiThe number of blocks B [k, j] whose run length is k and category is j is
Figure 0003746804
It is calculated by. Scan ACiThe number of blocks Z [k + 1] whose run length is (k + 1) in (i.e., the number of blocks whose run length is k and whose category is 0) is
Figure 0003746804
It is calculated by.
[0090]
The correction coefficient ZW can take a value from 0 to 1000. For example, when ZW = 0,
Z [k + 1] = CTj× Z [k] / ZALL
This is the same result as the second prediction method. If ZW = 1000,
Z [k + 1] = Z [k]
This is a scan ACi-1The block of run length k is Scan ACiIndicates that all of them are in category “0”. In the example described below, ZW = 50.
[0091]
Where scan ACThree, Z [0] = 1034, Z [1] = 1440, Z [2] = 1041, Z [3] = 1888, and scan ACFourAssume that a table as shown in FIG. 30 is obtained as the category distribution in FIG. That is, scan ACThreeIn block 4366 where is category “0”, scan ACFourThen, the number of blocks of category “0” CT0Is the number of blocks of 3321, category “1” CT1Is the number of blocks CT of 655, category “2”2Is 276, the number of blocks in category “3” CTThreeIs the number of blocks in category 101 and category “4” CTFour13 and the number of blocks of category “5” or more is 0.
[0092]
As will be described below, the number of blocks is obtained from data having a run length of 1, and a run length / category distribution table as shown in FIG. 31 is obtained.
[0093]
Scan ACFour, The number of blocks whose run length is 1 and category “1” is
Figure 0003746804
It becomes. Similarly, the number of blocks whose run length is 1 and whose category is “2” is as follows from the equation (1):
Figure 0003746804
It becomes.
[0094]
For the number of blocks whose run length is 1 and category “3”, from equation (1):
Figure 0003746804
However, as shown in FIG.Three= C [3] = 101. Therefore, it is forcibly set to 101, not 104.
[0095]
Similarly, B [1,4] is forcibly set to 13 for the number of blocks having a run length of 1 and a category of “4”.
[0096]
Scan ACFourThe number of blocks Z [2] in which the run length is 2 (that is, the number of blocks in which the run length is 1 and the category is 0) is
Z [2] = Z [1]-(277 + 158 + 101 + 13) = 891
It becomes.
[0097]
For the number of blocks with run length 2 and category “1”,
Figure 0003746804
It becomes. For the number of blocks with run length 2 and category “2”, B [2,2] = 66 + 49 = 115
It becomes.
[0098]
The number of blocks B [2,3] having a run length of 2 and category “3” is 0 according to the result of B [1,3], the run length is 2, and category “4”. The number of blocks B [2,4] is 0 according to the result of B [1,4].
[0099]
Scan ACFourThe number of blocks Z [3] whose run length is 3 (that is, the number of blocks whose run length is 2 and whose category is 0) is
Z [3] = Z [2]-(200 + 115 + 0 + 0) = 726
It becomes.
[0100]
For the number of blocks with run length 3 and category “1”,
Figure 0003746804
It becomes. However, the number of blocks in category “1” CT1Because the total number of
B [3,1] = 655-277-200 = 178
It becomes.
[0101]
For the number of blocks with a run length of 3 and category “2”,
Figure 0003746804
It becomes. However, the number of blocks in category “2” CT2Because the total number of is 276,
B [3,2] = 276-158-115 = 3
It becomes.
[0102]
The number of blocks whose run length is 3 and category “3” is 0 according to the results of B [1,3] and B [2,3], run length is 3, and category “4”. The number of blocks is “0” according to the results of B [1,4] and B [2,4].
[0103]
Scan ACFourThe number of blocks Z [4] whose run length is 4 (that is, the number of blocks whose run length is 3 and whose category is 0) is
Z [4] = Z [3]-(178 + 3 + 0 + 0) = 1704
It becomes.
[0104]
In the number of blocks whose run length is 0, the numbers of blocks of categories “1” to “4” are 155, 65, 24, and 3 from FIG. Further, the number of blocks Z [1] whose run length is 1 (that is, the number of blocks whose run length is 0 and whose category is 0) is as shown in FIG.
Z [1] = 787
It becomes.
[0105]
FIG. 32 is a table of run length / category distributions obtained in this manner, and corresponds to FIG. 23 in the first prediction method. As shown in FIG. 31, the number of blocks having a run length of 4 (the number of blocks having a run length of 3 and a category of 0) is 1704, which was obtained in the first prediction method. It is larger than Z [4] = 1434. That is, according to the third prediction method, it is understood that the run length increases.
[0106]
Next, in the category distribution table as shown in FIG.i-1Category is “0” and scan ACiA method for obtaining the number of blocks whose category is “1” or more using the broken line abfgh in FIG. 29 will be described.
[0107]
In this case, the horizontal axis in FIG.i-1Indicates the number of blocks of category “0”, and the vertical axis indicates scan ACiThe sum of the number of blocks of category “0” and category “1” in FIG. First, the vertical axis OmaxIs defined as the sum of C [0] and C [1] (= 4108 + 810 = 4918).high, Omid, OlowAsk for. Next, when a point on the polygonal line corresponding to the abscissa 4366 (for example, P3) is read and the ordinate corresponding to this point is read, this value is calculated as scan AC.FourIs the sum of the number of blocks of category “0” and category “1”. Therefore, if the value of the category “0” already obtained is subtracted from this sum, the scan ACi-1Category is “0” and scan ACiThe number of blocks whose category is “1” is obtained. Similarly, scan ACi-1Category is “0” and scan ACiThe number of blocks whose category is “2” or more is obtained.
[0108]
Next, referring to the flowchart of FIG. 33, the set code amount S used in step 106 of FIG.iThe generation of the distribution (see FIG. 13) will be described.
[0109]
In step 201, the DC component and the scan AC for all blocks of one image.63The minimum total code amount (number of bits) of the encoded data is obtained. Total code amount CD of DC component0Is obtained by multiplying the minimum value HN (0) = 2 of the total value of the Huffman code amount and the number of additional bits corresponding thereto by the total number of blocks. Normally, the total value of the Huffman code amount and the number of additional bits takes the minimum value in category “0”, and therefore, the code of the minimum value HN (0) is used here. On the other hand, scan AC63Total code amount CD63Is obtained by multiplying the code amount HN (“EOB”) = 4 of the end data (EOB) in Huffman coding by the total number of blocks.
[0110]
In step 202, the scan AC when using the default quantization table is used.63The total code amount CDA for all blocks except for
CDA = Σ (COi/ FTi(3)
It is calculated by. However, COiIs the scan AC when using the default quantization tableiCode amount (number of bits) (see FIG. 12), and FTiScan ACiThe table value of the filtering table FL (see FIG. 34), that is, the filtering coefficient. Note that Σ indicates that the parameter i is added from 0 to 62.
[0111]
The filtering table FL includes, for example, a filtering coefficient FT corresponding to each spatial frequency as shown in FIG.iConsists of. Filtering coefficient FT0Corresponds to the DC component and the filtering coefficient FT1, FT2... FT63Is scan AC1, AC2... AC63Corresponding to Further, the filtering coefficient has a larger value as the spatial frequency with a higher degree of data compression. Therefore, the example of FIG. 34 shows a filter that cuts high frequency components. That is, the filtering coefficient of the high frequency component is 20000 or 30000, and the high frequency component is greatly compressed by the equation (3).
[0112]
In step 203, the correction coefficient CDR is
CDR = (SETIM-CD0-CD63/ CDA (4)
It is calculated by. However, SETIM is a set total code amount, for example, 524288 bits (64 Kbytes). The value of the correction coefficient CDR becomes larger as the total code amount CDA obtained by the equation (3) is smaller, and is about 100, for example.
[0113]
After parameter i is cleared to 0 in step 204, in step 205,
CODEi= (COi/ FTi) X CDR (5)
By means of each spatial frequency (scan ACi) For the amount of compressed data (number of bits). As shown in the equation (5), the compressed data amount CODEiIs the code amount CO when the default quantization table is used.iFiltering coefficient FTiThe result of dividing by is multiplied by the correction factor CDR.
[0114]
In step 206, the compressed data amount CODEiCode amount CO when using the default quantization tableiIt is determined whether or not the value is greater than. Compressed data amount CODEiIs larger, in step 207, the code amount COiCompressed data amount CODEiSet as In other words, in this case, the compression code amount is equal to the code amount CO regardless of the quantization coefficient q.iThe code amount CO is low.iCompressed data amount CODEiIt is determined as
[0115]
On the other hand, the compressed data amount CODEiIf it is smaller, after the parameter i is incremented by 1 in step 208, it is determined in step 209 whether or not the parameter is greater than 62. If the parameter i does not exceed 62, the process returns to step 205 and the above-described processing is executed again. In this way, scan AC62Compressed data volume up to CODEiIs set, in step 210, the scan AC63Compressed data amount CODE63Is CD63This program ends.
[0116]
Compressed data amount CODE obtained as described aboveiIs the set code amount S used in step 106 of FIG.iIt is.
[0117]
FIG. 35 shows each scan AC in the filtering table FL shown in FIG.iShows the allocation ratio. This allocation ratio is the filtering coefficient FT of each AC component.iAnd DC component filtering coefficient FT0Is obtained by multiplying the reciprocal of the ratio by 100 with, for example, scan AC2In the case of the filtering coefficient FT2Is 98, the allocation ratio is greater than 100 as indicated by the symbol RA. As can be understood from this figure, the filtering table FL in FIG. 34 shows a low-pass filter with a small allocation ratio for high-frequency components. On the other hand, in order to generate the table FL of the high-pass filter, it is only necessary to determine the filtering coefficient so as to reduce the allocation ratio for the low frequency component in the allocation ratio of FIG.
[0118]
FIG. 36 shows a filtering table corresponding to the first low-pass filter. Reference numeral (a) denotes a luminance filtering table, which is the same as the filtering table of FIG. Reference numeral (b) represents a filtering table for color difference. FIG. 37 shows a filtering table corresponding to the averaging filter, where symbol (a) indicates a luminance filtering table and symbol (b) indicates a color difference filtering table. FIG. 38 shows a filtering table corresponding to the second low-pass filter. In this example, the luminance and color difference filtering tables are common. FIG. 39 shows a filtering table corresponding to the high-pass filter, and this table is also common for luminance and color difference.
[0119]
【The invention's effect】
As described above, according to the present invention, it is possible to achieve the effect that image compression corresponding to the image quality of each image can be achieved.
[Brief description of the drawings]
FIG. 1 is a block diagram illustrating an image compression apparatus according to an embodiment of the present invention.
FIG. 2 is a diagram showing an example of image data P (Y) xy, DCT transform coefficient S (Y) uv, quantized DCT coefficient R (Y) uv, and quantization table Q (Y) uv.
FIG. 3 is a diagram showing categories of DC coefficient difference values;
FIG. 4 is a diagram illustrating a coding table of DC coefficients.
FIG. 5 is a flowchart showing a processing routine for encoding quantized AC coefficients.
FIG. 6 is a diagram illustrating a zigzag scan performed when Huffman coding is performed on an AC coefficient.
FIG. 7 is a diagram showing categories of AC coefficients.
FIG. 8 is a diagram showing a Huffman table recommended by JPEG.
FIG. 9 is a diagram illustrating an example of encoded data by Huffman encoding.
FIG. 10 is a diagram illustrating components of encoded data.
FIG. 11 is a diagram illustrating an example of category distribution at a predetermined spatial frequency when a quantization table having all quantization coefficients of “1” is used.
FIG. 12 is a diagram illustrating an example of a distribution of the number of bits of encoded data in each scan when a quantization table in which all quantization coefficients are “1” is used.
FIG. 13 is a diagram illustrating an example of code amount distribution for each spatial frequency (that is, for each scan) set in a spatial frequency data amount setting unit;
14 is a diagram showing the category distribution shown in FIG. 11 for each scan at the same time. FIG.
FIG. 15 is a diagram showing a table of category distribution when using a quantization table in which all quantization coefficients are “16”.
FIG. 16 Scan AC1It is a figure which shows the number of blocks of category "0" and the number of blocks of category "1" or more.
FIG. 17: Scan AC2It is a figure which shows the number of blocks whose run length is 2, 1, and 0.
FIG. 18 Scan ACThreeIt is a figure which shows the number of blocks whose run length is 3, 2, 1, 0.
FIG. 19: Scan ACFourIt is a figure which shows the number of blocks whose run length is 4, 3, 2, 1, 0.
FIG. 20 Scan AC1It is a figure which shows the table | surface of run length and category.
FIG. 21: Scan AC2It is a figure which shows the table | surface of run length and category.
FIG. 22 Scan ACThreeIt is a figure which shows the table | surface of run length and category.
FIG. 23: Scan ACFourIt is a figure which shows the table | surface of run length and category.
FIG. 24 is a diagram illustrating the code length of each codeword in the Huffman table recommended by JPEG.
FIG. 25 is a flowchart of a program for generating a quantization table.
FIG. 26 is a diagram showing a distribution of “00” data.
FIG. 27: Scan AC1And scan AC2It is a figure which shows normalization of "00" data.
FIG. 28 is a diagram showing a distribution table of normalized “00” data.
FIG. 29: Scan ACi-1Of category “0” and scan ACi-1And scan ACiIt is a figure which shows the relationship with "00" data.
FIG. 30: Scan ACFourIt is a figure which shows the example of the category distribution in.
FIG. 31 is a diagram showing an example of run length / category distribution obtained by the third prediction method;
32 is a diagram showing the run length / category distribution table of FIG. 31 in a format corresponding to FIG.
FIG. 33: Setting code amount SiIt is a flowchart of the program which produces | generates distribution of.
FIG. 34 is a diagram illustrating an example of a filtering table.
35 is a diagram showing an allocation ratio of each scan in the filtering table of FIG. 34. FIG.
FIG. 36 is a diagram illustrating a filtering table of a first low-pass filter.
FIG. 37 is a diagram showing a filtering table of an averaging filter.
FIG. 38 is a diagram illustrating a filtering table of a second low-pass filter.
FIG. 39 is a diagram illustrating a filtering table of a high-pass filter.
[Explanation of symbols]
M IC memory card

Claims (3)

2次元の原画像データを複数のブロックに分割し、直交変換を施して空間周波数毎に直交変換係数を求める直交変換手段と、
前記直交変換係数を所定の量子化係数から成る2次元の量子化テーブルにより量子化して量子化直交変換係数を求める量子化手段と、
前記量子化直交変換係数を空間周波数に応じた順序でスキャンすることにより、1次元配列データに並びかえた後、前記スキャンの順序に従った前記量子化直交変換係数に基づいて符号化を行って符号化データを求める符号化手段と、
全ての量子化係数が1であるデフォルトの量子化テーブルにより量子化された量子化直交変換係数に基づいて前記符号化手段により得られた前記符号化データと、データ圧縮の度合いが大きい前記空間周波数ほど大きい値を有する、前記空間周波数毎のフィルタリング係数を有するフィルタリングテーブルとから、前記空間周波数毎に、前記符号化データの符号量を前記フィルタリング係数で除算した値を合計して合計符号量を求め、この合計符号量と、前記符号化データの1画面分の合計ビット数の目標値である設定合計符号量との比である修正係数と、前記デフォルトの量子化テーブルにより量子化された量子化直交変換係数と、前記フィルタリング係数とに基づいて、前記符号化データの符号量を前記フィルタリング係数で除算し、さらに前記修正係数を乗算することにより、前記空間周波数毎に符号化データの符号量の目標値を設定する手段と、
各空間周波数の符号量が前記目標値以下になるように、その空間周波数に対応した量子化係数を定める量子化係数演算手段と
前記デフォルトの量子化テーブルにより量子化された前記量子化直交変換係数を所定のデータ量を有するカテゴリに分類し、各空間周波数における各カテゴリに分類されるブロック数を示すカテゴリ分布表を求め、前記1次元配列データにおいてAC成分の先頭に位置する空間周波数については、前記カテゴリ分布表に基づいて、前記量子化係数を変化させて前記符号化データの符号量を予測し、前記1次元配列データにおいてAC成分の先頭以外に位置する空間周波数については、前記カテゴリ分布表と少なくとも第1の空間周波数の符号化データの統計量とに基づいて量子化係数を変化させ、前記第1の空間周波数における0の量子化直交変換係数に対応するカテゴリ「0」のブロック数を用いて、第2の空間周波数の符号化データの符号量を予測する予測手段とを備え
前記量子化係数演算手段は、前記予測手段によって予測された前記第2の空間周波数の符号化データの符号量が前記目標値以下になるように、前記第2の空間周波数に対応した量子化係数を定めることを特徴とする画像圧縮装置。
Orthogonal transformation means for dividing the two-dimensional original image data into a plurality of blocks and performing orthogonal transformation to obtain orthogonal transformation coefficients for each spatial frequency;
Quantization means for quantizing the orthogonal transform coefficient with a two-dimensional quantization table including predetermined quantization coefficients to obtain a quantized orthogonal transform coefficient;
By scanning the quantized orthogonal transform coefficients in an order corresponding to the spatial frequency, the quantized orthogonal transform coefficients are rearranged into one-dimensional array data, and then encoded based on the quantized orthogonal transform coefficients according to the scan order. Encoding means for obtaining encoded data;
The coded data obtained by the coding means based on the quantized orthogonal transform coefficient quantized by a default quantization table in which all the quantization coefficients are 1, and the spatial frequency with a high degree of data compression From the filtering table having the filtering coefficient for each spatial frequency having a large value, the total code amount is obtained by summing the values obtained by dividing the code amount of the encoded data by the filtering coefficient for each spatial frequency. A correction coefficient that is a ratio between the total code amount and a set total code amount that is a target value of the total number of bits for one screen of the encoded data, and a quantization quantized by the default quantization table orthogonal transform coefficients, based on said filtering coefficients, by dividing the code amount of the coded data in the filtering coefficients, and Wherein by multiplying the correction coefficient, and means for setting a target value of the code amount of the coded data for each of the spatial frequencies,
Quantization coefficient calculation means for determining a quantization coefficient corresponding to the spatial frequency so that the code amount of each spatial frequency is equal to or less than the target value ;
Classifying the quantized orthogonal transform coefficients quantized by the default quantization table into categories having a predetermined amount of data, obtaining a category distribution table indicating the number of blocks classified into each category in each spatial frequency, and For the spatial frequency located at the head of the AC component in the one-dimensional array data, the code amount of the encoded data is predicted by changing the quantization coefficient based on the category distribution table. For spatial frequencies located at positions other than the head of the AC component, the quantization coefficient is changed based on the category distribution table and at least the statistic of the encoded data of the first spatial frequency, and 0 at the first spatial frequency is obtained. Using the number of blocks of category “0” corresponding to the quantized orthogonal transform coefficient of the second spatial frequency, And a prediction means for predicting the amount,
The quantization coefficient calculation means is a quantization coefficient corresponding to the second spatial frequency so that a code amount of the encoded data of the second spatial frequency predicted by the prediction means is equal to or less than the target value. image compression apparatus characterized by determining the.
前記予測手段が、前記1次元配列データにおいてAC成分の先頭以外に位置する空間周波数については、前記カテゴリ分布表と前記第1の空間周波数および前記第1の空間周波数よりも低い空間周波数の符号化データの統計量とに基づいて、前記第2の空間周波数の符号化データの符号量を予測することを特徴とする請求項1に記載の画像圧縮装置。 For the spatial frequency located at a position other than the head of the AC component in the one-dimensional array data, the prediction means encodes the category distribution table, the first spatial frequency, and a spatial frequency lower than the first spatial frequency. The image compression apparatus according to claim 1 , wherein the code amount of the encoded data of the second spatial frequency is predicted based on a data statistic . 前記第2の空間周波数に対応した量子化直交変換係数は、前記1次元配列データにおいて、前記第1の空間周波数に対応した量子化直交変換係数に隣接していることを特徴とする請求項に記載の画像圧縮装置。The quantized orthogonal transform coefficients corresponding to a second spatial frequency, claim, characterized in that in the one-dimensional array data, it is adjacent to the quantized orthogonal transformation coefficients corresponding to the first spatial frequency 1 The image compression apparatus described in 1.
JP04133495A 1995-02-06 1995-02-06 Image compression device Expired - Fee Related JP3746804B2 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP04133495A JP3746804B2 (en) 1995-02-06 1995-02-06 Image compression device
US08/598,207 US5937098A (en) 1995-02-06 1996-02-06 Adaptive quantization of orthogonal transform coefficients for setting a target amount of compression

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP04133495A JP3746804B2 (en) 1995-02-06 1995-02-06 Image compression device

Publications (2)

Publication Number Publication Date
JPH08214311A JPH08214311A (en) 1996-08-20
JP3746804B2 true JP3746804B2 (en) 2006-02-15

Family

ID=12605630

Family Applications (1)

Application Number Title Priority Date Filing Date
JP04133495A Expired - Fee Related JP3746804B2 (en) 1995-02-06 1995-02-06 Image compression device

Country Status (1)

Country Link
JP (1) JP3746804B2 (en)

Also Published As

Publication number Publication date
JPH08214311A (en) 1996-08-20

Similar Documents

Publication Publication Date Title
JP4365957B2 (en) Image processing method and apparatus and storage medium
CN100568969C (en) Reversible Wavelet Transform and Embedded Code Stream Processing Method
US7483575B2 (en) Picture encoding apparatus and method, program and recording medium
EP0671852B1 (en) Device and method for encoding image data
US6909811B1 (en) Image processing apparatus and method and storage medium storing steps realizing such method
JP3743384B2 (en) Image encoding apparatus and method, and image decoding apparatus and method
JP3356663B2 (en) Image encoding device, image encoding method, and recording medium recording image encoding program
US7142722B2 (en) Image coding device and coding method of same
US7133567B2 (en) Image coding apparatus and image coding method
JP2005515727A (en) Coder-matched layer separation and interpolation for compound document compression
EP1009168A2 (en) Image processing apparatus and method, and recording medium
US6337929B1 (en) Image processing apparatus and method and storing medium
CN1124045C (en) Runlength coding method for use in video signal encoding system
Wei An introduction to image compression
US5937098A (en) Adaptive quantization of orthogonal transform coefficients for setting a target amount of compression
JPH0832037B2 (en) Image data compression device
JP4514169B2 (en) Digital signal conversion apparatus and method
JP3532963B2 (en) Image compression device
US7551788B2 (en) Digital image coding device and method for noise removal using wavelet transforms
US5724096A (en) Video signal encoding method and apparatus employing inter-block redundancies
DE602004011213T2 (en) INTRAFRAME COMPRESSION AND DECOMPRIMATION OF VIDEO SIGNALS WITH A FIXED BITRATE
JP3746804B2 (en) Image compression device
JP3559314B2 (en) Image compression device
JP3421463B2 (en) Quantization table generation device for image compression device
JP2002290743A (en) Image information encoding method, encoding device, digital copying machine, digital facsimile device, and digital filing device

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20041118

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20050117

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20050426

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20050624

A911 Transfer of reconsideration by examiner before appeal (zenchi)

Free format text: JAPANESE INTERMEDIATE CODE: A911

Effective date: 20050701

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20050913

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20051017

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20051108

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20051125

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20081202

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20091202

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20101202

Year of fee payment: 5

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20101202

Year of fee payment: 5

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111202

Year of fee payment: 6

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111202

Year of fee payment: 6

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313111

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111202

Year of fee payment: 6

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313111

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111202

Year of fee payment: 6

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121202

Year of fee payment: 7

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20131202

Year of fee payment: 8

S533 Written request for registration of change of name

Free format text: JAPANESE INTERMEDIATE CODE: R313533

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

LAPS Cancellation because of no payment of annual fees