JP3652754B2 - Subtractive color image processing device - Google Patents

Subtractive color image processing device Download PDF

Info

Publication number
JP3652754B2
JP3652754B2 JP29679495A JP29679495A JP3652754B2 JP 3652754 B2 JP3652754 B2 JP 3652754B2 JP 29679495 A JP29679495 A JP 29679495A JP 29679495 A JP29679495 A JP 29679495A JP 3652754 B2 JP3652754 B2 JP 3652754B2
Authority
JP
Japan
Prior art keywords
color
replacement
image processing
processing apparatus
pixel value
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
JP29679495A
Other languages
Japanese (ja)
Other versions
JPH09138676A (en
Inventor
広記 兒玉
博之 鈴木
享 江口
淳史 三浦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
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 Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP29679495A priority Critical patent/JP3652754B2/en
Publication of JPH09138676A publication Critical patent/JPH09138676A/en
Application granted granted Critical
Publication of JP3652754B2 publication Critical patent/JP3652754B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Image Processing (AREA)
  • Facsimile Image Signal Circuits (AREA)
  • Controls And Circuits For Display Device (AREA)

Description

【0001】
【発明の属する技術分野】
本発明は、画像データの減色処理を実行する減色画像処理装置に関し、特に、高速に減色処理を実行できるようにする減色画像処理装置に関する。
【0002】
減色画像処理装置は、表示色の限られているカラーディスプレイへの画像データの表示を実現するために用意されるものであって、多数の色を用いて表現される画像データの画素値を、用意される代表色の内の最も近いものに置換することで減色処理を実行する。
【0003】
この減色画像処理装置の実用性を高めていくためには、高速に減色処理を実行できるようにする構成を構築していく必要がある。
【0004】
【従来の技術】
原画像の各画素値に最も近い色を代表色の中から選択する方法として、最近隣探索法がある。この最近隣探索法は、原画像の各画素の色を全ての代表色と比較し、その差の最も小さい代表色、すなわち、色空間内でのユークリッド距離が最小となる代表色を置換色として選択する方法である。
【0005】
ここで、図21に示すようなRGB色空間を想定するならば、点x(Rx,x,x )と点y( Ry,y,y ) とのユークリッド距離D(x,y) としては、
D(x,y) =[(Rx −Ry )2+(Gx −Gy )2+(Bx −By )2]1/2
や、
D(x,y) =(Rx −Ry )2+(Gx −Gy )2+(Bx −By )2
や、
D(x,y) =|Rx −Ry |+|Gx −Gy |+|Bx −By
といったものが用いられている。
【0006】
図22に、最近隣探索法の処理手順を図示する。
すなわち、最近隣探索法では、この処理手順に示すように、n番目の代表色p(n) を選択すると、その代表色p(n) と原画像の画素値sとのユークリッド距離D(s,p(n))を算出し、その新たに算出したユークリッド距離が、変数dmin に格納されるそれまでに算出した最も小さいユークリッド距離よりも小さいのか否かを判断して、小さいことを判断するときには、その新たに算出したユークリッド距離を変数dmin に格納するとともに、そのときのn値を変数nmin に格納してから変数nの値を1つインクリメントし、小さくないことを判断するときには、変数dmin /nmin を更新せずに直ちに変数nの値を1つインクリメントすることを繰り返していくことで、原画像の画素値に最も近い色を代表色の中から選択していくことになる。
【0007】
このような最近隣探索法を使って、原画像の各画素値に最も近い色を代表色の中から選択する処理を行う減色画像処理装置では、従来、原画像の全画素値について、最近隣探索法を使って最も近い色を代表色の中から選択して置換していくという構成を採っていた。
【0008】
すなわち、図23に示すように、原画像の中から処理対象となる画素値を取得すると、最近隣探索法を使って代表色の中から置換色を選択し、その処理対象の画素値をその置換色に置き換えてから、原画像の全画素値の処理を終了したのか否かを判断して、未終了を判断するときには、次の処理対象となる画素値を取得することを繰り返していくことで、原画像の各画素値を代表色に置換していくという構成を採っていたのである。
【0009】
【発明が解決しようとする課題】
しかしながら、このような従来構成の減色画像処理装置に従っていると、原画像の減色処理に膨大な時間がかかるという問題点があった。すなわち、最近隣探索法では、全ての代表色と原画像の各画素値との距離を計算すことから、計算量が膨大なものとなって、原画像の減色処理に膨大な時間がかかるという問題点があったのである。
【0010】
本発明はかかる事情に鑑みてなされたものであって、高速に減色処理を実行できるようにする新たな減色画像処理装置の提供を目的とする。
【0011】
【課題を解決するための手段】
図1に本発明の原理構成を図示する。
図中、1は本発明を具備する減色画像処理装置であって、多数の色を用いて表現される画像データの画素値を、用意される代表色の内の最も近いものに置換することで減色処理を実行するものである。
【0012】
この減色画像処理装置1は、原画像ファイル10と、置換画像ファイル11と、入力手段12と、置換手段13と、キャッシュメモリ手段14と、判断手段15と、変換手段16と、起動手段17とを備える。
【0013】
この原画像ファイル10は、減色対象となる原画像を格納する。置換画像ファイル11は、減色された置換画像を格納する。
入力手段12は、原画像ファイル10から画素値を1つずつ読み出して置換要求を発行する。ここで、入力手段12は、読み出した画素値の下位ビットに対して、強制的にゼロ値をセットしてから置換要求を発行したり、強制的に下位ビットのとり得る値の中間値をセットしてから置換要求を発行することがある。
置換手段13は、置換要求のある画素値と用意される複数の代表色との間の距離を算出し、それに基づいて、その画素値を用意される代表色の内の最も近いものに置換することで、置換要求のある画素値の置換色を求めて置換する。
【0014】
キャッシュメモリ手段14は、置換手段13の求めた画素値と置換色との対応関係を一時的に保存する。ここで、キャッシュメモリ手段14は、置換色の画素値そのものを使って対応関係を保存するのではなくて、置換色を指すインデックス値を使って対応関係を保存することがある。判断手段15は、置換要求のある画素値がキャッシュメモリ手段14に登録されているのか否かを判断する。変換手段16は、置換要求のある画素値をキャッシュメモリ手段14に登録されているその画素値の指す置換色に置換する。起動手段17は、置換要求のある画素値を指定して置換手段13を起動する。
【0015】
このように構成される本発明の減色画像処理装置1では、入力手段12は、例えば、原画像ファイル10に格納される原画像を複数の矩形ブロックで区画して、その矩形ブロックを走査単位として画素値を1つずつ読み出して置換要求を発行する。この置換要求を受け取ると、判断手段15は、キャッシュメモリ手段14を参照することで、置換要求のある画素値がキャッシュメモリ手段14に登録されているのか否かを判断するとともに、登録されているときには、その画素値の指す置換色を特定する。
【0016】
この判断手段15の処理を受けて、変換手段16は、判断手段15が登録を判断するときには、置換要求のある画素値を判断手段15の特定した置換色に変換して置換画像ファイル11に格納する。一方、起動手段17は、判断手段15が未登録を判断するときには、置換要求のある画素値を指定して置換手段13を起動する。
【0017】
そして、置換手段13は、起動手段17から起動されると、最近隣探索法等を用いて、置換要求のある画素値の置換色を求めることで置換処理を実行して置換画像ファイル11に格納するとともに、その求めた画素値と置換色との対応関係をキャッシュメモリ手段14に登録する。
【0018】
このように、本発明では、最近隣探索法等を用いて減色処理を実行する構成を採るときにあって、キャッシュメモリを利用することで、その減色処理計算の回数を減らす構成を採るので、多色画像の減色を高速に実行できるようになる。
【0019】
【発明の実施の形態】
以下、実施の形態に従って本発明を詳細に説明する。
図2に、本発明を具備する減色画像処理装置1の一実施例を図示する。
【0020】
この図に示すように、本発明を具備する減色画像処理装置1は、減色対象となる原画像を格納する原画像ファイル20と、原画像ファイル20から画像値を読み出す画像入力プログラム21と、画像入力プログラム21の読み出した画素値に対して減色処理を施すことでその画素値の置換色を求める減色処理プログラム22と、減色処理プログラム22の処理用に用意されて、置換色となる代表色を管理するカラーパレット23と、減色処理プログラム22の処理用に用意されて、減色処理プログラム22の求めた画素値と置換色との対応関係を管理するキャッシュ機構24と、減色処理プログラム22の求めた置換画像を格納する置換画像ファイル25と、置換画像ファイル25から画像値を読み出して外部に出力する画像出力プログラム26とを備える。
【0021】
図3に、カラーパレット23の管理データの一実施例、図4に、キャッシュ機構24の管理データの一実施例を図示する。
カラーパレット23は、図3に示すように、例えば、256個用意される代表色のインデックス値と、それらの代表色の画素値となるRGB値との対応関係を管理することになる。
【0022】
一方、キャッシュ機構24は、例えばM個のエントリを有して、図4(a)に示すように、カラーパレット23の管理するインデックス値を使いつつ、減色処理プログラム22の求めた画素値と置換色との対応関係を管理したり、図4(b)に示すように、そのインデックス値を用いずに置換色の画素値を直接使いつつ、減色処理プログラム22の求めた画素値と置換色との対応関係を管理する。ここで、この2つの管理構成の内、インデックス値を用いる前者の管理構成を採ると、メモリを大幅に削減できるという利点がある。
【0023】
このキャッシュ機構24は、減色処理プログラム22の求めた画素値と置換色との対応関係を一時的に保持するものであるが、後述するように、この対応関係を保持するにあたって、参照された対応関係を先頭にしつつ、登録順序の新しい対応関係が先頭側となる管理構成を採っている。この管理構成は、参照された対応関係を先頭に並び換えつつ、減色処理プログラム22により新たな対応関係が求まると、最後のエントリに管理される最も古く登録された対応関係を削除し、それ以外のエントリに管理される対応関係を1つずつ古いものを管理するエントリに移動させながら、その新たに求められた対応関係を先頭のエントリに登録することで実現されることになるが、これでは、データを移動させなければならず時間がかかってしまう。
【0024】
そこで、本発明では、リンク構造を採用する構成を採って、データの物理的な移動を行わずにリンクを張り換えることで、データの並び換えを行う構成を採っている。すなわち、キャッシュ機構24は、図5に示すように、各エントリ対応に、1つ前の対応関係がどのエントリに登録されているのかを管理する管理域prev(m) と、1つ後の対応関係がどのエントリに登録されているのかを管理する管理域next(m) とで構成されるリンク構造を持って、それらのリンクを張り換えていくことで、データの移動を行わずに、参照された対応関係を先頭に並び換えつつ、登録順序の新しい対応関係が先頭側となる形式に従って対応関係を管理する構成を採っている。
【0025】
図6に、本発明の減色画像処理装置1が画像入力プログラム21/減色処理プログラム22を起動することで実行する処理フローの一実施例を図示する。
本発明の減色画像処理装置1は、この図6の処理フローに示すように、先ず最初に、ステップ1で、画素の参照位置を原画像の先頭画素に設定すると、続くステップ2で、原画像ファイル20から現在の画素値(設定されている参照画素の画素値)を取得し、続くステップ3で、その取得した現在の画素値をキャッシュ機構24から検索する。
【0026】
続くステップ4で、現在の画素値がキャッシュ機構24に登録されているのか否かを判断して、登録されていないことを判断するときには、ステップ5に進んで、最近隣探索法を使って、カラーパレット23に登録される代表色の中から置換色を選択し、続くステップ6で、その求めた画素値と置換色との対応関係をキャッシュ機構24に登録する。
【0027】
一方、ステップ4で登録されていることを判断するときには、ステップ7に進んで、その登録されている対応関係から現在の画素値に対応付けられる置換色を得て、続くステップ8で、その対応関係をキャッシュ機構24の先頭のエントリへ移動する。
【0028】
ステップ5/ステップ7で置換色を特定すると、ステップ9に進んで、現在の画素値を置換色に置き換えてから置換画像ファイル25に格納し、続くステップ10で、原画像ファイル20に格納される全画素について処理を終了したのか否かを判断して、画素が残っていないことを判断するときには、処理を終了し、画素が残っていることを判断するときには、ステップ11に進んで、画素の参照位置を次の画素に設定してからステップ2に戻っていく。
【0029】
このようにして、本発明の減色画像処理装置1は、キャッシュ機構24を利用することで、減色処理計算の回数を減らす構成を採るのである。
画像入力プログラム21は、この図6の処理フローのステップ1/ステップ2/ステップ10/ステップ11の処理を実行するものである。
【0030】
すなわち、画像入力プログラム21は、図7の処理フローに示すように、先ず最初に、ステップ1で、入力位置を画素の先頭に設定し、続くステップ2で、減色処理プログラム22からの画像入力要求を待って、入力要求があることを検出すると、ステップ3に進んで、原画像ファイル20の全画素について処理を終了したのか否かを判断して、全画素の終了を判断するときには、ステップ4に進んで、減色処理プログラム22に対して入力終了を通知する。
【0031】
一方、ステップ3で全画素の未終了を判断するときには、ステップ5に進んで、設定される入力位置から3バイト分の画素値を読み出して減色処理プログラム22に渡し、続くステップ6で、入力位置を3バイト分後ろに設定してからステップ2に戻っていく。ここで、ステップ5で、入力位置から3バイト分の画素値を読み出して減色処理プログラム22に渡すのは、図8に示すように、画素値がRGBの各3バイトで表されているからである。
【0032】
このように、画像入力プログラム21は、原画像ファイル20から画素値を読み出して、減色処理プログラム22に渡していくことになるが、キャッシュヒット率の向上を図るために、通常のラスタスキャン走査による画素値の読み出し方法を採らずに、原画像を複数の矩形ブロックで区画して、その矩形ブロックを走査単位として画素値を読み出していく方法を採ることが好ましい。
【0033】
すなわち、通常の画像では、2次元的な広がりを持つ比較的狭い範囲に同一の色を持つ画素が集中するので、画像入力プログラム21は、図9(a)に示すような通常のラスタスキャン走査による画素値の読み出し方法を採らずに、図9(b)に示すような原画像を複数の矩形ブロックで区画して、その矩形ブロックを走査単位として画素値を読み出していく方法を採ることで、キャッシュヒット率の向上を実現する構成を採ることが好ましい。
【0034】
図10に、この図9(b)に示す画素値読出方法を実現するために画像入力プログラム21が実行する処理フローの一実施例を図示する。
ここで、この処理フローでは、原画像は、図11に示すように、左上の画素を原点(0,0)として、水平方向にX個の画素を持ち、垂直方向にY個の画素を持つことを想定するとともに、図12に示すように、水平方向にBX個の画素、垂直方向にBY個の画素を持つ矩形ブロックで区画されていることを想定する。また、xは読出対象画素の水平方向の画素位置、yは読出対象画素の垂直方向の画素位置、bxは図12中に示す矩形ブロックの水平方向のブロック番号、byは図12中に示す矩形ブロックの垂直方向のブロック番号を表し、これらの初期値は全てゼロであるとする。なお、画素値が図8に示すような1次元のメモリ展開形態を採る場合には、画素座標(x,y)の画素値の展開されるアドレスAi は、「Ai =(X・y+x)・3」で求められることになる。
【0035】
画像入力プログラム21は、図10の処理フローに従って原画像から画素値を読み出す場合には、先ず最初に、ステップ1で、読出対象画素の水平画素位置を示す変数xの値を1つインクリメントし、続くステップ2で、xをBXで割り算した余り(x%BX)が“0”になったのか否かを判断する。この余りが“0”になるということは、水平方向の次の矩形ブロックの画素に入ったということを意味するので、このステップ2では、変数xの指す画素が右隣の矩形ブロックに入ることになるのか否かを判断するのである。
【0036】
このステップ2で、右隣の矩形ブロックまで到達していないことを判断するときには、ステップ3に進んで、変数xの値がXに到達したのか否かを判断する。すなわち、水平方向の最終画素位置まで到達したのか否かを判断するのである。この判断処理により、水平方向の最終画素位置まで到達していないことを判断するときには、ステップ1で更新した変数xの値を有効なものとして扱って、変数xと変数yの指定する画素を読出対象として、その画素の画素値を読み出していく処理に入る。
【0037】
一方、ステップ2で右隣の矩形ブロックに入ることを判断するときと、ステップ3で水平方向の最終画素位置に到達したことを判断するときには、ステップ4進んで、読出対象画素の垂直画素位置を示す変数yの値を1つインクリメントし、続くステップ5で、yをBYで割り算した余り(y%BY)が“0”になったのか否かを判断する。この余りが“0”になるということは、垂直方向の次の矩形ブロックの画素に入ったということを意味するので、このステップ5では、変数yの指す画素が下隣の矩形ブロックに入ることになるのか否かを判断するのである。
【0038】
このステップ5で、下隣の矩形ブロックまで到達していないことを判断するときには、ステップ6に進んで、変数yの値がYに到達したのか否かを判断する。すなわち、垂直方向の最終画素位置まで到達したのか否かを判断するのである。このステップ6の判断処理により、垂直方向の最終画素位置まで到達していないことを判断するときには、ステップ7に進んで、変数bxと変数BXとの乗算値を変数xに代入することで、変数xの値が自矩形ブロックの水平方向の先頭画素位置を指すように設定してから、変数xと変数yの指定する画素を読出対象として、その画素の画素値を読み出していく処理に入る。
【0039】
一方、ステップ5で下隣の矩形ブロックに入ることを判断するときと、ステップ6で垂直方向の最終画素位置に到達したことを判断するときには、ステップ8に進んで、変数bxの値を1つインクリメントし、続くステップ9で、「bx×BX>X」の条件式が成立するのか否かを判断する。この条件式が成立するということは、水平方向の最終矩形ブロックを超えることになったということを意味するので、このステップ9では、そのような状態になったのか否かを判断するのである。
【0040】
このステップ9で、「bx×BX>X」の条件式の成立を判断するときには、ステップ10に進んで、読出対象画素の属する矩形ブロックの垂直ブロック番号を示す変数byの値を1つインクリメントし、続くステップ11で、読出対象画素の属する矩形ブロックの水平ブロック番号を示す変数bxの値を“0”に設定し、続いて、ステップ12で、変数byと変数BYとの乗算値を変数yに設定してから、ステップ7に進んで、変数xと変数yの指定する画素を読出対象として、その画素の画素値を読み出していく処理に入る。
【0041】
一方、このステップ9で、「bx×BX>X」の条件式の不成立を判断するときには、ステップ10及びステップ11の処理を省略して、直ちにステップ12に進んで、変数byと変数BYとの乗算値を変数yに設定してから、ステップ7に進んで、変数xと変数yの指定する画素を読出対象として、その画素の画素値を読み出していく処理に入る。
【0042】
このようにして、画像入力プログラム21は、この図10の処理フローを実行することで、図9(b)に示す走査形式に従って、原画像ファイル20から画素値を読み出していくことになる。これにより、キャッシュヒット率の向上を実現できるようになる。
【0043】
次に、減色処理プログラム22の実行する処理について説明する。
減色処理プログラム22は、上述した図6の処理フローのステップ3ないしステップ9の処理を実行することになる。
【0044】
図13に、減色処理プログラム22の実行する処理フローの一実施例を図示する。
すなわち、減色処理プログラム22は、起動されると、図13の処理フローに示すように、先ず最初に、ステップ1で、画像入力プログラム21に対して画像の入力要求を発行し、続くステップ2で、この入力要求に対する応答して、画像入力プログラム21から入力終了が通知されるのか否かを判断して、入力終了通知を受け取るときには、ステップ2に進んで、置換画像ファイル25に対して、処理終了を通知する。
【0045】
一方、ステップ2で、画像入力プログラム21から受け取るものが入力終了通知でないことを判断するとき、すなわち、画像入力プログラム21から受け取るものが画素値であることを判断するときには、ステップ3に進んで、その画素値を受け取り、続くステップ5で、その画素値を使ってキャッシュ機構24を検索する。
【0046】
続いて、ステップ6で、ステップ5での検索処理によりキャッシュヒットしたのか否かを判断して、キャッシュヒットしないことを判断するときには、ステップ7に進んで、最近隣探索法を使って、カラーパレット23に登録される代表色の中から、ステップ3で受け取った画素値の置換色とそのインデックス値を選択し、続くステップ8で、その画素値とインデックス値との対応関係をキャッシュ機構24の先頭のエントリに登録する。
【0047】
一方、ステップ6でキャッシュヒットしたことを判断するときには、ステップ9に進んで、キャッシュヒット先のインデックス値の指す置換色を特定し、続くステップ10で、そのキャッシュヒットした対応関係をキャッシュ機構24の先頭のエントリへ移動する。
【0048】
ステップ7/ステップ9で置換色を特定すると、ステップ11に進んで、置換画像ファイル25に対して出力要求を発行し、続くステップ12で、ステップ3で受け取った画素値をその置換色に置き換えて、置換画像ファイル25に格納(置換色そのものを格納することもあるし、インデックス値を格納することもある)してからステップ1に戻っていく。
【0049】
このようにして、減色処理プログラム22は、キャッシュ機構24を利用することで、減色処理計算の回数を減らす構成を採るのである。
次に、キャッシュ機構24の構成について詳細に説明する。
【0050】
キャッシュ機構24は、図5に示したように、各エントリ対応に、1つ前の対応関係がどのエントリに登録されているのかを管理する管理域prev(m) と、1つ後の対応関係がどのエントリに登録されているのかを管理する管理域next(m) とで構成されるリンク構造を持って、それらのリンクを張り換えていくことで、データの移動を行わずに、参照された対応関係を先頭に並び換えつつ、登録順序の新しい対応関係が先頭側となる形式に従って対応関係を管理する構成を採っている。
【0051】
すなわち、キャッシュ機構24に対応関係が登録されていないときには、図14(a)に示すように、先頭のエントリを指すTopが、最後のエントリを指すLast をポイントしている。この状態にあるときに、対応関係の登録要求があると、図14(b)に示すように、先頭のエントリである0番のエントリに登録要求のある対応関係を登録するとともに、0番のエントリの持つprev(m) がTopを指し、next(m) がLast を指すように設定するとともに、Topが0番のエントリを指し、Last が0番のエントリを指すように設定する。
【0052】
続いて、対応関係の登録要求があると、空いているエントリの先頭のものに登録要求の対応関係を登録するとともに、その格納先エントリの持つprev(m) がTopを指し、next(m) がそれまでTopを指していたエントリを指すように設定するとともに、それまでTopを指していたエントリの持つprev(m) が格納先エントリを指すように設定し、更に、Topが格納先エントリを指すように設定する。
【0053】
このようにして、図15(a)(b)に示すように、エントリが一杯になるまで、登録要求のある対応関係がキャッシュ機構24に登録されていく。
続いて、対応関係の登録要求があると、図16(a)に示すように、Last の指すエントリに登録要求のある対応関係を登録し、その格納先エントリの持つprev(m) がTopを指し、next(m) がそれまでTopを指していたエントリを指すように設定するとともに、それまでTopを指していたエントリの持つprev(m) が格納先エントリを指すように設定し、更に、その格納先エントリの持つprev(m) の指していたエントリの持つnext(m) がLast を指すように設定し、更に、Topが格納先エントリを指し、Last がその格納先エントリの持つprev(m) の指していたエントリを指すように設定する。
【0054】
このような状態にあるときに、(M−1)番のエントリに格納される対応関係が参照されると、図16(b)に示すように、(M−1)番のエントリの持つprev(m) がTopを指し、next(m) がそれまでTopを指していたエントリを指すように設定するとともに、それまでTopを指していたエントリの持つprev(m) が(M−1)番のエントリを指し、next(m) が(M−1)番のエントリの持つnext(m) の指していたエントリを指すように設定し、更に、Topが(M−1)番のエントリを指すように設定する。
【0055】
このようにして、キャッシュ機構24は、リンク構造を持って、そのリンクを張り換えていくことで、データの移動を行わずに、参照された対応関係を先頭に並び換えつつ、登録順序の新しい対応関係が先頭側となる形式に従って対応関係を管理する構成を採っている。
【0056】
この構成に従い、減色処理プログラム22は、図13に示した処理フローのステップ6でキャッシュ検索処理に入ると、図17の処理フローに示すように、リンクを辿りながら、検索対象となる画素値の指すインデックス値を検索していくのである。ここで、図中、sは検索対象の画素値、c(m)はm番のエントリに格納されている画素値、n(m)はm番のエントリに格納されているインデックス値を表している。
【0057】
減色処理プログラム22の処理に従って、置換画像ファイル25に置換色のインデックス値(カラーパレット23が256 個の代表色を管理することから、このインデックス値は1バイトで表される)に置き換えられた画像が格納されると、画像出力プログラム26は、図18に示す処理フローに従って、置換画像ファイル25から画像値を読み出して外部に出力する処理を実行する。
【0058】
すなわち、画像出力プログラム26は、図18の処理フローに示すように、先ず最初に、ステップ1で、出力位置を画素の先頭に設定し、続くステップ2で、置換画像ファイル25から終了通知が発行されたのか否かを判断して、終了通知が発行されたときには処理を終了し、終了通知が発行されないときには、続いて、ステップ3で、出力先から置換画像の出力要求が発行されたのか否かを判断して、出力要求の発行を検出すると、ステップ4に進んで、置換画像ファイル25から受け取るインデックス値の指す代表色を出力位置に出力し、続くステップ5で、出力位置を更新してからステップ2に戻っていくことを繰り返していくことで、置換画像ファイル25から画像値を読み出して外部に出力していくのである。
【0059】
上述したように、画像入力プログラム21は、原画像ファイル20から画素値を読み出して減色処理プログラム22に渡していくときに、図9(b)に示す走査形式に従って画素値を読み出していくことで、キャッシュヒット率の向上を実現する構成を採ったが、これと組み合わせて、あるいは単独に、原画像ファイル20から読み出した画素値の下位ビットを強制的にゼロ値に設定することで、キャッシュヒット率の向上を実現する構成を採ることもできる。
【0060】
RGB各8ビットの合計24ビットで表される画素値は約1600万色にもなるが、肉眼ではこのような多数の色を識別できない。そこで、例えば、RGBの各下位4ビットを無視することで4096色に縮退させても実用上は何も問題は起こらない。そこで、画像入力プログラム21は、例えば、原画像ファイル20から読み出した画素値の下位4ビットを強制的にゼロ値に設定することで、原画像の色を4096色に縮退させ、これにより、キャッシュヒット率を向上を実現することが可能である。
【0061】
このとき、下位4ビットをオールゼロとすると、本来“1111”から“0000”の間の値をとり得るものが、“0000”に統一されてしまうことで画像が暗くなってしまうことになる。そこで、下位4ビットを“0000”に強制的に設定するのではなくて、図19に示すように、“1111”から“0000”の中間値である“1000”に強制的に設定する方法を採ることが好ましい。
【0062】
このような下位ビットを縮退させる方法を採るときには、減色画像処理装置1は、図20の処理フローのステップ20に示すように、図6の処理フローのステップ2とステップ3の間に、原画像ファイル20から取得した現在の画素値の下位ビットを無視することでビット数を削減する処理を実行することになる。
【0063】
図示実施例に従って本発明を詳細に説明したが、本発明はこれに限られるものではない。例えば、実施例ではRGB表色系で表される画素値を用いたが、本発明はこれに限られるものではない。また、実施例では最近隣探索法に従って減色処理を実行する構成を採ったが、本発明はこれに限られるものではない。
【0064】
【発明の効果】
以上説明したように、本発明では、最近隣探索法等を用いて減色処理を実行する構成を採るときにあって、キャッシュメモリを利用することで、その減色処理計算の回数を減らす構成を採るので、多色画像の減色を高速に実行できるようになる。
【図面の簡単な説明】
【図1】本発明の原理構成図である。
【図2】本発明の一実施例である。
【図3】カラーパレットの管理データの一実施例である。
【図4】キャッシュ機構の管理データの一実施例である。
【図5】キャッシュ機構の管理データの一実施例である。
【図6】本発明の実行する処理フローの一実施例である。
【図7】画像入力プログラムの処理フローの一実施例である。
【図8】画素値の格納形態の説明図である。
【図9】画像入力プログラムの画素値読出方法の説明図である。
【図10】画像入力プログラムの処理フローの一実施例である。
【図11】画素値の座標系の説明図である。
【図12】矩形ブロックの説明図である。
【図13】減色処理プログラムの処理フローの一実施例である。
【図14】キャッシュ機構の動作説明図である。
【図15】キャッシュ機構の動作説明図である。
【図16】キャッシュ機構の動作説明図である。
【図17】減色処理プログラムの処理フローの一実施例である。
【図18】画像出力プログラムの処理フローの一実施例である。
【図19】画像入力プログラムの実行する処理の説明図である。
【図20】本発明の実行する処理フローの他の実施例である。
【図21】色空間の説明図である。
【図22】最近隣探索法の説明図である。
【図23】従来技術の説明図である。
【符号の説明】
1 減色画像処理装置
10 原画像ファイル
11 置換画像ファイル
12 入力手段
13 置換手段
14 キャッシュメモリ手段
15 判断手段
16 変換手段
17 起動手段
[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a color-reduction image processing apparatus that performs color-reduction processing on image data, and more particularly to a color-reduction image processing apparatus that enables color reduction processing to be executed at high speed.
[0002]
The color-reduction image processing apparatus is prepared for realizing display of image data on a color display with a limited display color, and the pixel value of image data expressed using a large number of colors, The color reduction process is executed by replacing the closest representative color among the prepared representative colors.
[0003]
In order to improve the practicality of this color-reduced image processing apparatus, it is necessary to construct a configuration that enables the color-reduction process to be executed at high speed.
[0004]
[Prior art]
As a method for selecting a color closest to each pixel value of the original image from representative colors, there is a nearest neighbor search method. In this nearest neighbor search method, the color of each pixel of the original image is compared with all representative colors, and the representative color with the smallest difference, that is, the representative color with the smallest Euclidean distance in the color space is used as the replacement color. How to choose.
[0005]
Here, if an RGB color space as shown in FIG. 21 is assumed, the point x (Rx,Gx,Bx) And point y (Ry,Gy,By) Euclidean distance D (x, y) with
D (x, y) = [(Rx-Ry)2+ (Gx-Gy)2+ (Bx-By)2]1/2
Or
D (x, y) = (Rx-Ry)2+ (Gx-Gy)2+ (Bx-By)2
Or
D (x, y) = | Rx-Ry| + | Gx-Gy| + | Bx-By
Are used.
[0006]
FIG. 22 illustrates the processing procedure of the nearest neighbor search method.
That is, in the nearest neighbor search method, as shown in this processing procedure, when the nth representative color p (n) is selected, the Euclidean distance D (s) between the representative color p (n) and the pixel value s of the original image. , p (n)), and the newly calculated Euclidean distance is the variable dminWhen it is determined whether or not the distance is smaller than the smallest Euclidean distance calculated so far, the newly calculated Euclidean distance is set to the variable d.minAnd the n value at that time is stored in the variable nminWhen the value of the variable n is incremented by one and then determined not to be small, the variable dmin/ NminBy immediately repeating incrementing the value of the variable n by 1 without updating the color, the color closest to the pixel value of the original image is selected from the representative colors.
[0007]
In a subtractive color image processing apparatus that performs processing for selecting a color closest to each pixel value of an original image from representative colors using such a nearest neighbor search method, conventionally, for all pixel values of the original image, The search method was used to select and replace the closest color from the representative colors.
[0008]
That is, as shown in FIG. 23, when the pixel value to be processed is acquired from the original image, a replacement color is selected from the representative colors using the nearest neighbor search method, and the pixel value to be processed is After replacing with the replacement color, it is determined whether or not the processing of all the pixel values of the original image has been completed, and when it is determined that the processing has not been completed, it is repeated that the pixel value to be processed next is acquired. Thus, a configuration is adopted in which each pixel value of the original image is replaced with a representative color.
[0009]
[Problems to be solved by the invention]
However, according to such a conventional color-reduced image processing apparatus, there is a problem that it takes a long time to perform color-reduction processing of the original image. That is, in the nearest neighbor search method, since the distance between all the representative colors and each pixel value of the original image is calculated, the calculation amount becomes enormous, and it takes an enormous time for the color reduction processing of the original image. There was a problem.
[0010]
The present invention has been made in view of such circumstances, and an object of the present invention is to provide a new color-reduced image processing apparatus that can perform color-reduction processing at high speed.
[0011]
[Means for Solving the Problems]
FIG. 1 illustrates the principle configuration of the present invention.
In the figure, reference numeral 1 denotes a subtractive color image processing apparatus having the present invention, wherein pixel values of image data expressed using a large number of colors are replaced with the closest one of prepared representative colors. A color reduction process is executed.
[0012]
The reduced-color image processing apparatus 1 includes an original image file 10, a replacement image file 11, an input unit 12, a replacement unit 13, a cache memory unit 14, a determination unit 15, a conversion unit 16, and an activation unit 17. Is provided.
[0013]
  The original image file 10 stores an original image to be reduced. The replacement image file 11 stores the reduced color replacement image.
  The input unit 12 receives the pixel value from the original image file 10.One by oneRead and issue a replacement request. Here, the input means 12 forcibly sets a zero value to the lower bits of the read pixel value and then issues a replacement request, or forcibly sets an intermediate value of values that the lower bits can take. Then, a replacement request may be issued.
  Replacement means 13Calculates the distance between the pixel value for which there is a replacement request and a plurality of representative colors to be prepared, and based on the distance, replaces the pixel value with the closest one of the representative colors to be prepared, PlaceThe replacement color of the pixel value for which replacement is requested is obtained and replaced.
[0014]
  The cache memory means 14 determines the correspondence between the pixel value obtained by the replacement means 13 and the replacement color.Temporarilysave. Here, the cache memory unit 14 may store the correspondence using an index value indicating the replacement color, instead of storing the correspondence using the pixel value itself of the replacement color. The determination unit 15 determines whether or not a pixel value for which a replacement request has been made is registered in the cache memory unit 14. The conversion unit 16 registers the pixel value for which a replacement request is made in the cache memory unit 14.HaveTo the replacement color indicated by the pixel value. The activation unit 17 activates the replacement unit 13 by designating a pixel value for which a replacement request is made.
[0015]
  In the subtractive color image processing apparatus 1 of the present invention configured as described above, the input unit 12 divides the original image stored in the original image file 10 into a plurality of rectangular blocks, and uses the rectangular blocks as scanning units. Pixel valueOne by oneRead and issue a replacement request. Upon receiving this replacement request, the determination unit 15 refers to the cache memory unit 14 to determine whether or not a pixel value for which a replacement request has been made is registered in the cache memory unit 14 and is registered. Sometimes, the replacement color indicated by the pixel value is specified.
[0016]
In response to the processing of the determination unit 15, the conversion unit 16 converts the pixel value for which replacement is requested into the replacement color specified by the determination unit 15 and stores it in the replacement image file 11 when the determination unit 15 determines registration. To do. On the other hand, the activation unit 17 activates the replacement unit 13 by designating a pixel value for which a replacement request is made when the determination unit 15 determines that it is not registered.
[0017]
Then, the replacement unit 13, when activated by the activation unit 17, executes a replacement process by obtaining a replacement color of a pixel value having a replacement request using a nearest neighbor search method or the like, and stores it in the replacement image file 11. At the same time, the correspondence relationship between the obtained pixel value and the replacement color is registered in the cache memory means 14.
[0018]
Thus, in the present invention, when adopting a configuration for performing the color reduction processing using the nearest neighbor search method or the like, since the cache memory is used, the configuration for reducing the number of color reduction processing calculations is adopted. Multicolor image reduction can be performed at high speed.
[0019]
DETAILED DESCRIPTION OF THE INVENTION
Hereinafter, the present invention will be described in detail according to embodiments.
FIG. 2 shows an embodiment of a subtractive color image processing apparatus 1 having the present invention.
[0020]
As shown in this figure, a reduced-color image processing apparatus 1 having the present invention includes an original image file 20 that stores an original image to be reduced, an image input program 21 that reads image values from the original image file 20, and an image A color reduction processing program 22 for obtaining a replacement color of the pixel value by performing a color reduction process on the pixel value read by the input program 21 and a representative color to be a replacement color prepared for the processing of the color reduction processing program 22 A color palette 23 to be managed, a cache mechanism 24 that is prepared for the processing of the color reduction processing program 22 and manages the correspondence between the pixel value obtained by the color reduction processing program 22 and the replacement color, and the color reduction processing program 22 A replacement image file 25 for storing a replacement image, and an image output program for reading image values from the replacement image file 25 and outputting them to the outside And a 6.
[0021]
FIG. 3 illustrates an example of management data of the color palette 23, and FIG. 4 illustrates an example of management data of the cache mechanism 24.
As shown in FIG. 3, the color palette 23 manages, for example, the correspondence between 256 prepared representative color index values and RGB values serving as pixel values of these representative colors.
[0022]
On the other hand, the cache mechanism 24 has, for example, M entries, and replaces the pixel value obtained by the color reduction processing program 22 while using the index value managed by the color palette 23 as shown in FIG. As shown in FIG. 4B, the pixel values and replacement colors obtained by the color reduction processing program 22 are managed while directly using the replacement color pixel values without using the index values, as shown in FIG. Manage the correspondence of. Here, of the two management configurations, the former management configuration using the index value is advantageous in that the memory can be greatly reduced.
[0023]
The cache mechanism 24 temporarily holds the correspondence relationship between the pixel value obtained by the color reduction processing program 22 and the replacement color. As will be described later, when the correspondence relationship is held, the correspondence referred to is referred to. A management configuration is adopted in which the new correspondence in the registration order is at the head while the relationship is at the head. This management configuration deletes the oldest registered correspondence managed in the last entry when a new correspondence is obtained by the color reduction processing program 22 while rearranging the referenced correspondence at the top. It is realized by registering the newly found correspondence relationship in the top entry while moving the correspondence relationship managed by the entry to the entry managing the old one by one. It takes time to move data.
[0024]
Therefore, the present invention employs a configuration that employs a link structure and rearranges the data by replacing the links without physically moving the data. That is, the cache mechanism 24, as shown in FIG. 5, corresponds to each entry, the management area prev (m) for managing the entry in which the previous correspondence is registered, and the next correspondence It has a link structure consisting of a management area next (m) that manages which entry the relationship is registered in, and can be referenced without moving data by re-linking those links. The correspondence relationship is managed in accordance with a format in which the correspondence relationship in the new registration order becomes the top side while rearranging the correspondence relationship thus formed.
[0025]
FIG. 6 shows an embodiment of a processing flow executed by the image-reduction image processing apparatus 1 of the present invention by starting the image input program 21 / color-reduction processing program 22.
As shown in the processing flow of FIG. 6, the color-reduced image processing apparatus 1 of the present invention first sets the reference position of the pixel to the first pixel of the original image in step 1. The current pixel value (the pixel value of the set reference pixel) is acquired from the file 20, and the acquired current pixel value is retrieved from the cache mechanism 24 in the subsequent step 3.
[0026]
In the subsequent step 4, it is determined whether or not the current pixel value is registered in the cache mechanism 24, and when it is determined that the current pixel value is not registered, the process proceeds to step 5 and the nearest neighbor search method is used. A replacement color is selected from the representative colors registered in the color palette 23, and in the subsequent step 6, the correspondence relationship between the obtained pixel value and the replacement color is registered in the cache mechanism 24.
[0027]
On the other hand, when determining that it is registered in step 4, go to step 7 to obtain a replacement color associated with the current pixel value from the registered correspondence, and in step 8 that follows, The relationship is moved to the top entry of the cache mechanism 24.
[0028]
When the replacement color is specified in Step 5 / Step 7, the process proceeds to Step 9, where the current pixel value is replaced with the replacement color, and then stored in the replacement image file 25. Then, in Step 10, it is stored in the original image file 20. When it is determined whether or not the processing has been completed for all the pixels, and it is determined that there are no remaining pixels, the processing is ended. After setting the reference position to the next pixel, the process returns to step 2.
[0029]
Thus, the color-reduction image processing apparatus 1 of the present invention employs a configuration that reduces the number of color-reduction processing calculations by using the cache mechanism 24.
The image input program 21 executes the processing of Step 1 / Step 2 / Step 10 / Step 11 in the processing flow of FIG.
[0030]
That is, as shown in the processing flow of FIG. 7, the image input program 21 first sets the input position at the top of the pixel in Step 1 and then in Step 2 receives an image input request from the color reduction processing program 22. When it is detected that there is an input request, the process proceeds to step 3 to determine whether or not the processing has been completed for all the pixels of the original image file 20, and when determining the end of all the pixels, step 4 is performed. Then, the end of input is notified to the color reduction processing program 22.
[0031]
On the other hand, when it is determined in step 3 that all the pixels have not been completed, the process proceeds to step 5 where a pixel value for 3 bytes is read from the set input position and is passed to the color reduction processing program 22. Is set 3 bytes later, and the process returns to step 2. Here, in step 5, the pixel value for 3 bytes is read from the input position and passed to the color reduction processing program 22 because the pixel value is represented by 3 bytes of RGB as shown in FIG. is there.
[0032]
As described above, the image input program 21 reads out the pixel values from the original image file 20 and passes them to the color reduction processing program 22. In order to improve the cache hit rate, the image input program 21 performs normal raster scan scanning. Instead of adopting a pixel value reading method, it is preferable to divide the original image into a plurality of rectangular blocks and read the pixel values using the rectangular blocks as scanning units.
[0033]
That is, in a normal image, pixels having the same color are concentrated in a relatively narrow range having a two-dimensional spread. Therefore, the image input program 21 performs normal raster scan scanning as shown in FIG. 9B, the original image as shown in FIG. 9B is divided into a plurality of rectangular blocks, and the pixel values are read out using the rectangular blocks as scanning units. It is preferable to adopt a configuration that realizes an improvement in the cache hit rate.
[0034]
FIG. 10 shows an example of a processing flow executed by the image input program 21 in order to realize the pixel value reading method shown in FIG. 9B.
Here, in this processing flow, as shown in FIG. 11, the original image has X pixels in the horizontal direction and Y pixels in the vertical direction with the upper left pixel as the origin (0, 0). In addition, as shown in FIG. 12, it is assumed that the image is partitioned by rectangular blocks having BX pixels in the horizontal direction and BY pixels in the vertical direction. Also, x is the pixel position in the horizontal direction of the readout target pixel, y is the pixel position in the vertical direction of the readout target pixel, bx is the horizontal block number of the rectangular block shown in FIG. 12, and by is the rectangle shown in FIG. It represents the block number in the vertical direction of the block, and these initial values are all zero. If the pixel value adopts a one-dimensional memory development form as shown in FIG. 8, the address A where the pixel value of the pixel coordinate (x, y) is developed.iIs "Ai= (X · y + x) · 3 ”.
[0035]
When the image input program 21 reads a pixel value from the original image according to the processing flow of FIG. 10, first, in step 1, the value of the variable x indicating the horizontal pixel position of the pixel to be read is incremented by one, In the subsequent step 2, it is determined whether or not the remainder (x% BX) obtained by dividing x by BX has become "0". When this remainder becomes “0”, it means that the pixel of the next rectangular block in the horizontal direction has been entered, so in this step 2, the pixel indicated by the variable x enters the rectangular block on the right. It is judged whether it becomes.
[0036]
When it is determined in step 2 that the rectangular block adjacent to the right has not been reached, the process proceeds to step 3 to determine whether or not the value of the variable x has reached X. That is, it is determined whether or not the final pixel position in the horizontal direction has been reached. When it is determined that the final pixel position in the horizontal direction has not been reached by this determination process, the value of the variable x updated in step 1 is treated as valid, and the pixels specified by the variable x and the variable y are read. As a target, the process of reading the pixel value of the pixel is started.
[0037]
On the other hand, when it is determined at step 2 that the right-hand side rectangular block is entered and when it is determined at step 3 that the final pixel position in the horizontal direction has been reached, the process proceeds to step 4 to set the vertical pixel position of the pixel to be read out. The value of the indicated variable y is incremented by 1, and in the subsequent step 5, it is determined whether or not the remainder (y% BY) obtained by dividing y by BY has become “0”. If this remainder becomes “0”, it means that the pixel of the next rectangular block in the vertical direction has been entered, so in this step 5, the pixel indicated by the variable y enters the lower rectangular block. It is judged whether it becomes.
[0038]
If it is determined in step 5 that the lower rectangular block has not been reached, the process proceeds to step 6 to determine whether the value of the variable y has reached Y. That is, it is determined whether or not the final pixel position in the vertical direction has been reached. When it is determined by the determination process in step 6 that the final pixel position in the vertical direction has not been reached, the process proceeds to step 7 where the multiplication value of the variable bx and the variable BX is substituted into the variable x. After setting the value of x so that it points to the position of the first pixel in the horizontal direction of the rectangular block, the process begins to read out the pixel value of that pixel with the pixel specified by the variable x and variable y as the read target.
[0039]
On the other hand, when it is determined at step 5 that the next lower rectangular block is entered and when it is determined at step 6 that the final pixel position in the vertical direction has been reached, the routine proceeds to step 8 where the value of the variable bx is incremented by one. In step 9, it is determined whether or not the conditional expression “bx × BX> X” is satisfied. If this conditional expression is satisfied, it means that the final rectangular block in the horizontal direction has been exceeded. In Step 9, it is determined whether or not such a state has been reached.
[0040]
If it is determined in step 9 that the conditional expression “bx × BX> X” is satisfied, the process proceeds to step 10 to increment the variable by indicating the vertical block number of the rectangular block to which the pixel to be read belongs by one. In the following step 11, the value of the variable bx indicating the horizontal block number of the rectangular block to which the pixel to be read belongs is set to “0”. Subsequently, in step 12, the product of the variable by and the variable BY is set to the variable y. Then, the process proceeds to step 7 and the process of reading out the pixel value of the pixel with the pixel designated by the variable x and the variable y as the reading target is started.
[0041]
On the other hand, when it is determined in this step 9 that the conditional expression “bx × BX> X” is not satisfied, the processing of step 10 and step 11 is omitted, and the process immediately proceeds to step 12, where the variables by and BY After the multiplication value is set to the variable y, the process proceeds to step 7 and the process of reading the pixel value of the pixel with the pixel specified by the variable x and the variable y as a reading target is started.
[0042]
In this way, the image input program 21 reads out pixel values from the original image file 20 in accordance with the scanning format shown in FIG. 9B by executing the processing flow of FIG. As a result, the cache hit rate can be improved.
[0043]
Next, processing executed by the color reduction processing program 22 will be described.
The subtractive color processing program 22 executes the processing from step 3 to step 9 in the processing flow of FIG.
[0044]
FIG. 13 illustrates an example of a processing flow executed by the color reduction processing program 22.
That is, when the color reduction processing program 22 is started, as shown in the processing flow of FIG. 13, first, in step 1, an image input request is issued to the image input program 21, and then in step 2. In response to the input request, it is determined whether or not the input end notification is notified from the image input program 21. When the input end notification is received, the process proceeds to step 2 to process the replacement image file 25. Notify the end.
[0045]
On the other hand, when it is determined in step 2 that what is received from the image input program 21 is not an input end notification, that is, when it is determined that what is received from the image input program 21 is a pixel value, the process proceeds to step 3. The pixel value is received, and in step 5 that follows, the cache mechanism 24 is searched using the pixel value.
[0046]
Subsequently, at step 6, it is determined whether or not there is a cache hit by the search processing at step 5, and when it is determined that there is no cache hit, the process proceeds to step 7 and the nearest neighbor search method is used to set the color palette. 23, the replacement color of the pixel value received in step 3 and its index value are selected from the representative colors registered in step 23, and in the subsequent step 8, the correspondence between the pixel value and the index value is determined as the top of the cache mechanism 24 Register in the entry.
[0047]
On the other hand, when it is determined in step 6 that a cache hit has occurred, the process proceeds to step 9 in which the replacement color indicated by the index value of the cache hit destination is specified. Move to the first entry.
[0048]
When the replacement color is specified in step 7 / step 9, the process proceeds to step 11 where an output request is issued to the replacement image file 25, and in step 12 the pixel value received in step 3 is replaced with the replacement color. Then, the data is stored in the replacement image file 25 (the replacement color itself may be stored or the index value may be stored), and then the process returns to Step 1.
[0049]
In this way, the color reduction processing program 22 uses the cache mechanism 24 to reduce the number of color reduction processing calculations.
Next, the configuration of the cache mechanism 24 will be described in detail.
[0050]
As shown in FIG. 5, the cache mechanism 24 manages each entry corresponding to the management area prev (m) for managing the entry corresponding to the previous correspondence and the next correspondence. It has a link structure consisting of a management area next (m) that manages which entry is registered, and by re-linking those links, it can be referenced without moving the data. The correspondence relationship is managed in accordance with a format in which the correspondence relationship in the new registration order becomes the top side while rearranging the correspondence relationship at the top.
[0051]
That is, when the correspondence relationship is not registered in the cache mechanism 24, as shown in FIG. 14A, Top indicating the first entry points to Last indicating the last entry. In this state, if there is a correspondence registration request, as shown in FIG. 14 (b), the correspondence with the registration request is registered in the entry No. 0 as the first entry, and An entry is set so that prev (m) indicates Top, next (m) indicates Last, and Top indicates a 0th entry, and Last indicates a 0th entry.
[0052]
Subsequently, when there is a correspondence registration request, the registration request correspondence is registered at the head of the free entry, and prev (m) of the storage destination entry indicates Top, and next (m) Is set to point to the entry that previously pointed to Top, and prev (m) of the entry that pointed to Top until then is set to point to the storage destination entry. Set to point.
[0053]
In this manner, as shown in FIGS. 15A and 15B, the correspondence with a registration request is registered in the cache mechanism 24 until the entry is full.
Subsequently, when there is a correspondence registration request, as shown in FIG. 16A, the correspondence with the registration request is registered in the entry indicated by Last, and prev (m) of the storage destination entry stores Top. And next (m) is set to point to the entry that previously pointed to Top, and prev (m) of the entry that previously pointed to Top is set to point to the storage destination entry. Next (m) of the entry pointed to by prev (m) of the storage destination entry is set to point to Last, and further, Top indicates the storage destination entry, and Last indicates prev () of the storage destination entry. Set to point to the entry pointed to by m).
[0054]
In this state, when the correspondence stored in the (M-1) th entry is referred to, as shown in FIG. 16 (b), the prev that the (M-1) th entry has (m) points to Top, next (m) is set to point to the entry that previously pointed to Top, and prev (m) of the entry that previously pointed to Top is number (M-1) Next (m) is set to point to the entry pointed to by next (m) of the (M-1) th entry, and Top points to the (M-1) th entry. Set as follows.
[0055]
In this way, the cache mechanism 24 has a link structure, and the links are rearranged, so that the registered correspondence is rearranged while rearranging the referenced correspondence relationship without moving the data. A configuration is adopted in which the correspondence relationship is managed in accordance with the format in which the correspondence relationship is the leading side.
[0056]
In accordance with this configuration, when the color reduction processing program 22 enters the cache search process in step 6 of the process flow shown in FIG. 13, as shown in the process flow of FIG. The index value to point to is searched. Here, in the figure, s represents a pixel value to be searched, c (m) represents a pixel value stored in the mth entry, and n (m) represents an index value stored in the mth entry. Yes.
[0057]
According to the processing of the color reduction processing program 22, the replacement image file 25 is replaced with the replacement color index value (the index value is represented by 1 byte because the color palette 23 manages 256 representative colors). Is stored, the image output program 26 executes a process of reading the image value from the replacement image file 25 and outputting it to the outside according to the processing flow shown in FIG.
[0058]
That is, as shown in the processing flow of FIG. 18, the image output program 26 first sets the output position at the top of the pixel in step 1 and issues an end notification from the replacement image file 25 in the subsequent step 2. If the end notification is issued, the process ends. If the end notification is not issued, subsequently, in step 3, whether or not a replacement image output request is issued from the output destination. If the output request issuance is detected, the process proceeds to step 4 to output the representative color indicated by the index value received from the replacement image file 25 to the output position. In the subsequent step 5, the output position is updated. By repeating the process from step 2 to step 2, the image value is read from the replacement image file 25 and output to the outside.
[0059]
As described above, when the image input program 21 reads out pixel values from the original image file 20 and passes them to the color reduction processing program 22, it reads out the pixel values according to the scanning format shown in FIG. The cache hit rate is improved, but in combination with or independently, the lower bit of the pixel value read from the original image file 20 is forcibly set to a zero value to thereby improve the cache hit rate. It is also possible to adopt a configuration that realizes an improvement in rate.
[0060]
Although the pixel value represented by 24 bits in total of 8 bits for each of RGB is about 16 million colors, such a large number of colors cannot be identified with the naked eye. Therefore, for example, even if each of the lower 4 bits of RGB is ignored and reduced to 4096 colors, there is no practical problem. Therefore, the image input program 21, for example, forcibly sets the lower 4 bits of the pixel value read from the original image file 20 to zero value, thereby reducing the color of the original image to 4096 colors, thereby It is possible to improve the hit rate.
[0061]
At this time, if the lower 4 bits are all zeros, the original value that can take a value between “1111” and “0000” is unified with “0000”, and the image becomes dark. Therefore, instead of forcibly setting the lower 4 bits to “0000”, as shown in FIG. 19, there is a method for forcibly setting “1000” which is an intermediate value from “1111” to “0000”. It is preferable to take.
[0062]
When such a method of reducing the lower bits is adopted, the subtractive color image processing apparatus 1 performs the original image processing between Step 2 and Step 3 of the processing flow of FIG. 6, as shown in Step 20 of the processing flow of FIG. By ignoring the low-order bits of the current pixel value acquired from the file 20, processing for reducing the number of bits is executed.
[0063]
Although the present invention has been described in detail according to the illustrated embodiments, the present invention is not limited thereto. For example, although pixel values represented in the RGB color system are used in the embodiments, the present invention is not limited to this. In the embodiment, the color reduction process is executed according to the nearest neighbor search method. However, the present invention is not limited to this.
[0064]
【The invention's effect】
As described above, the present invention employs a configuration for reducing the number of color reduction processing calculations by using a cache memory when adopting a configuration for executing the color reduction processing using the nearest neighbor search method or the like. As a result, the color reduction of the multicolor image can be executed at high speed.
[Brief description of the drawings]
FIG. 1 is a principle configuration diagram of the present invention.
FIG. 2 is an example of the present invention.
FIG. 3 is an example of color pallet management data.
FIG. 4 is an example of management data of a cache mechanism.
FIG. 5 is an example of management data of a cache mechanism.
FIG. 6 is an example of a processing flow executed by the present invention.
FIG. 7 is an example of a processing flow of an image input program.
FIG. 8 is an explanatory diagram of a storage form of pixel values.
FIG. 9 is an explanatory diagram of a pixel value reading method of an image input program.
FIG. 10 is an example of a processing flow of an image input program.
FIG. 11 is an explanatory diagram of a coordinate system of pixel values.
FIG. 12 is an explanatory diagram of a rectangular block.
FIG. 13 is an example of a processing flow of a color reduction processing program.
FIG. 14 is an operation explanatory diagram of a cache mechanism.
FIG. 15 is an operation explanatory diagram of a cache mechanism.
FIG. 16 is an operation explanatory diagram of a cache mechanism.
FIG. 17 is an example of a processing flow of a color reduction processing program.
FIG. 18 is an example of a processing flow of an image output program.
FIG. 19 is an explanatory diagram of processing executed by the image input program.
FIG. 20 is another embodiment of the processing flow executed by the present invention.
FIG. 21 is an explanatory diagram of a color space.
FIG. 22 is an explanatory diagram of a nearest neighbor search method.
FIG. 23 is an explanatory diagram of a prior art.
[Explanation of symbols]
1. Color reduction image processing device
10 Original image file
11 Replacement image file
12 Input means
13 Replacement means
14 Cache memory means
15 Judgment means
16 Conversion means
17 Starting means

Claims (7)

像データの減色処理を実行する減色画像処理装置において、
減色処理の対象となる画像データから画素値を1つずつ読み出して入力する入力手段と、
上記入力手段の入力した画素値を置換対象として、該画素値と用意される複数の代表色との間の距離を算出し、それに基づいて、該画素値を該代表色の内の最も近いものに置換する置換手段と、
上記置換手段の求めた画素値と置換色との対応関係を一時的に保存するキャッシュメモリ手段と、
上記入力手段の入力した画素値が上記キャッシュメモリ手段に登録されているのか否かを判断する判断手段と、
上記判断手段が登録を判断する場合に、上記入力手段の入力した画素値を上記キャッシュメモリ手段に登録されている該画素値の指す置換色に置換する変換手段と、
上記判断手段が未登録を判断する場合に、上記入力手段の入力した画素値を指定して上記置換手段を起動する起動手段とを備えることを、
特徴とする減色画像処理装置。
In the subtractive color image processing apparatus for performing color reduction processing of images data,
Input means for reading out and inputting pixel values one by one from image data to be subjected to color reduction processing;
Using the pixel value input by the input means as a replacement object, the distance between the pixel value and a plurality of representative colors prepared is calculated, and based on this, the pixel value is the closest of the representative colors Replacement means for replacing with,
Cache memory means for temporarily storing the correspondence between the pixel value obtained by the replacement means and the replacement color;
A determining means for image pixel value input of the input means to determine whether or not registered in the cache memory means,
If the determination means you determines registration, and converting means for replacing the image pixel value input of the input means to the replacement color indicated by the pixel value registered in said cache memory means,
If the determination means you determine unregistered, by specifying the image pixel value input of the input means further comprising a starting means for starting the replacement means,
A feature of a reduced color image processing apparatus.
請求項1記載の減色画像処理装置において、
上記キャッシュメモリ手段は、リンク構造に従って、参照された対応関係を先頭にしつつ、登録順序の新しい対応関係が先頭側となるようにと対応関係を保存することを、
特徴とする減色画像処理装置。
The color-reduced image processing apparatus according to claim 1.
It said cache memory means, according to the link structure, with the referenced correspondence to the head, to save the corresponding relationship between such a new correspondence between the registration order is top side,
A feature of a reduced color image processing apparatus.
請求項1又は2記載の減色画像処理装置において、
上記キャッシュメモリ手段は、置換色の画素値そのものを使って対応関係を保存することを、
特徴とする減色画像処理装置。
In the subtractive color image processing apparatus according to claim 1 or 2,
The cache memory means stores the correspondence relationship using the pixel value itself of the replacement color.
A feature of a reduced color image processing apparatus.
請求項1又は2記載の減色画像処理装置において、
上記キャッシュメモリ手段は、置換色を指すインデックス値を使って対応関係を保存することを、
特徴とする減色画像処理装置。
In the subtractive color image processing apparatus according to claim 1 or 2,
The cache memory means stores the correspondence relationship using an index value indicating a replacement color.
A feature of a reduced color image processing apparatus.
請求項記載の減色画像処理装置において、
上記入力手段は、減色処理の対象となる画像データを複数の矩形ブロックで区画して、その矩形ブロックを走査単位として画素値を読み出していくことを、
特徴とする減色画像処理装置。
The color-reduced image processing apparatus according to claim 1 .
Said input means, and divides the images data to be color reduction process in a plurality of rectangular blocks, that it will read the pixel values that rectangular block as a scanning unit,
A feature of a reduced color image processing apparatus.
請求項又は記載の減色画像処理装置において、
上記入力手段は、読み出した画素値の下位ビットに対して、強制的にゼロ値をセットすることを、
特徴とする減色画像処理装置。
In the color-reduced image processing apparatus according to claim 1 or 5 ,
Said input means, to the lower bits of the read pixel values, the set Tosu Rukoto forcibly zero value,
A feature of a reduced color image processing apparatus.
請求項又は記載の減色画像処理装置において、
上記入力手段は、読み出した画素値の下位ビットに対して、強制的に該下位ビットのとり得る値の中間値をセットすることを、
特徴とする減色画像処理装置。
In the color-reduced image processing apparatus according to claim 1 or 5 ,
Said input means, to the lower bits of the read pixel values, the set Tosu Rukoto intermediate values forcibly possible values of the lower significant bits,
A feature of a reduced color image processing apparatus.
JP29679495A 1995-11-15 1995-11-15 Subtractive color image processing device Expired - Fee Related JP3652754B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP29679495A JP3652754B2 (en) 1995-11-15 1995-11-15 Subtractive color image processing device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP29679495A JP3652754B2 (en) 1995-11-15 1995-11-15 Subtractive color image processing device

Publications (2)

Publication Number Publication Date
JPH09138676A JPH09138676A (en) 1997-05-27
JP3652754B2 true JP3652754B2 (en) 2005-05-25

Family

ID=17838227

Family Applications (1)

Application Number Title Priority Date Filing Date
JP29679495A Expired - Fee Related JP3652754B2 (en) 1995-11-15 1995-11-15 Subtractive color image processing device

Country Status (1)

Country Link
JP (1) JP3652754B2 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4641959B2 (en) * 2006-03-29 2011-03-02 京セラミタ株式会社 Image processing device
JP5511468B2 (en) * 2009-04-13 2014-06-04 キヤノン株式会社 Image processing apparatus, control method therefor, and program
JP2015143946A (en) * 2014-01-31 2015-08-06 富士通株式会社 Moving object detection and tracking apparatus, moving object detection and tracking system, moving object detection and tracking method and program

Also Published As

Publication number Publication date
JPH09138676A (en) 1997-05-27

Similar Documents

Publication Publication Date Title
KR910000545B1 (en) Color image display system
US5332995A (en) Graphic pattern processing apparatus
JP2523222B2 (en) Image reduction / enlargement method and apparatus
JP2011070671A (en) Method and apparatus for controlling reading of array of data from memory
JP6403430B2 (en) Image processing apparatus and image processing method
EP0177640B1 (en) Image reduction method
JP5522890B2 (en) Image processing apparatus and method
EP1143696A2 (en) Image processing apparatus, image processing circuit, and image processing method
CN106780415B (en) Histogram statistical circuit and multimedia processing system
JP3652754B2 (en) Subtractive color image processing device
CN114219716A (en) Multi-layer image display method and display engine
JP4481343B2 (en) Method and apparatus for enabling generation of FM grid points at high speed
KR970004538B1 (en) Graphic data processing system
JPH01291387A (en) Image processor
JP4156194B2 (en) Method for converting first resolution raster digital data to second resolution digital data
US20100253699A1 (en) Methods and Systems for Improved Processing of Digital Image Data
JP5731816B2 (en) Image processing apparatus and image processing method
JPH06326876A (en) Processing method for picture information of prediction coding system
JP3512462B2 (en) Black isolated point removal device
JP3227222B2 (en) Image processing device
JP2798025B2 (en) Video coding method and apparatus
JPH09326920A (en) Digital image processing method in the unit of sub pixel
JP2008281536A (en) Image processing apparatus, image processing program, and imaging device
WO2019003610A1 (en) Processing device
JP2018196156A (en) Data processing device, method, and program

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20040608

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20040809

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: 20050222

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20050224

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: 20080304

Year of fee payment: 3

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

Free format text: PAYMENT UNTIL: 20090304

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20100304

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20100304

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20110304

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20110304

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20120304

Year of fee payment: 7

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

Free format text: PAYMENT UNTIL: 20130304

Year of fee payment: 8

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

Free format text: PAYMENT UNTIL: 20130304

Year of fee payment: 8

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

Free format text: PAYMENT UNTIL: 20140304

Year of fee payment: 9

LAPS Cancellation because of no payment of annual fees