JP2012249061A - Run length coding device, run length decoding device, run length coding method, and run length decoding method - Google Patents

Run length coding device, run length decoding device, run length coding method, and run length decoding method Download PDF

Info

Publication number
JP2012249061A
JP2012249061A JP2011118968A JP2011118968A JP2012249061A JP 2012249061 A JP2012249061 A JP 2012249061A JP 2011118968 A JP2011118968 A JP 2011118968A JP 2011118968 A JP2011118968 A JP 2011118968A JP 2012249061 A JP2012249061 A JP 2012249061A
Authority
JP
Japan
Prior art keywords
run
length
color code
bits
code
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.)
Withdrawn
Application number
JP2011118968A
Other languages
Japanese (ja)
Inventor
Hiroshi Uchino
浩志 内野
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.)
Konica Minolta Advanced Layers Inc
Original Assignee
Konica Minolta Advanced Layers Inc
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 Konica Minolta Advanced Layers Inc filed Critical Konica Minolta Advanced Layers Inc
Priority to JP2011118968A priority Critical patent/JP2012249061A/en
Publication of JP2012249061A publication Critical patent/JP2012249061A/en
Withdrawn legal-status Critical Current

Links

Images

Landscapes

  • Compression Of Band Width Or Redundancy In Fax (AREA)

Abstract

PROBLEM TO BE SOLVED: To generate run length code from raw image data efficiently.SOLUTION: A color code assignment unit 13 encodes raw image data with color code and run lengths to generate run length code, calculates a histogram of run lengths per run for each color code composing the run length code, and, on the basis of a calculated histogram, extracts a part of runs which have had some color code assigned thereto, thereby assigning unused color code to it. After code assignment by the color code assignment unit 13 is finished, an encoding unit 14 calculates the number of bits as a length part bit count for each color code, with which the coding result of the entire run will be at minimum, in which way it encodes each run.

Description

本発明は、ランレングス符号化に関する技術である。   The present invention is a technique related to run-length encoding.

ランレングス符号化は、画像の内容にもよるが、適した画像であれば、圧縮率が高い、ロスレス圧縮である、及びハードウェア化した場合の回路規模が小さいといった特徴があり、FAX等で広く使用されている。ランレングス符号化の概要に関しては例えば特許文献1、2に記述されている。   Run-length coding depends on the content of the image, but if it is a suitable image, it has features such as a high compression ratio, lossless compression, and a small circuit scale when implemented in hardware. Widely used. An outline of run-length encoding is described in Patent Documents 1 and 2, for example.

カメラにおいても、画像に重畳して出力するOSD(オンスクリーンディスプレイ)表示パターンをカメラ内に保持するといった用途でランレングス符号化を適用することができる。これは、予め決まったOSDパターンを表示するのであれば、OSD表示パターンを予めランレングス符号化してランレングスデータとして保持しておき、そのランレングスデータを表示タイミングに合わせてリアルタイムで復号化する方が、フレームバッファ用のRAMが不要で、低コストになるためである。つまり、ランレングス符号化は、圧縮ロスが小さく、復号化回路の回路構成が簡単、かつ、リアルタイム処理が可能といった特徴を持つため、このような用途に適している。   Also in the camera, run-length encoding can be applied for the purpose of holding an OSD (on-screen display) display pattern to be superimposed and output on an image. If a predetermined OSD pattern is to be displayed, the OSD display pattern is run-length encoded in advance and stored as run-length data, and the run-length data is decoded in real time in accordance with the display timing. However, this is because the RAM for the frame buffer is unnecessary and the cost is low. That is, run-length encoding is suitable for such applications because it has features such as a small compression loss, a simple circuit configuration of a decoding circuit, and real-time processing.

OSD表示パターンをランレングス符号化する場合、符号化するパターンは予め分かっているため、画像全体の特徴から符号化のパラメータを最適化することが可能である。   When the OSD display pattern is run-length encoded, since the pattern to be encoded is known in advance, the encoding parameters can be optimized from the characteristics of the entire image.

カラー表示されるOSD表示パターンは、自然画像とは異なり使用する色数は限定される場合が多い。したがって、OSD表示パターンをランレングス符号化する場合、色コードを用いて各色が表され、使用する色数に応じて、色コードのビット数が設定される。そして、各色コードと、各色コードをディスプレイで表示するための色情報とが対応付けられた色コードテーブルを用いて、各色コードが色情報に変換され、ランレングスデータがOSD表示パターンに復号化される。   The OSD display pattern displayed in color is often limited in the number of colors used, unlike a natural image. Therefore, when the OSD display pattern is run-length encoded, each color is represented using a color code, and the number of bits of the color code is set according to the number of colors used. Each color code is converted into color information using a color code table in which each color code is associated with color information for displaying each color code on a display, and run-length data is decoded into an OSD display pattern. The

図29(A)は、8×8のOSD表示パターンをランレングス符号化した一例である。図29(A)において、各グリッドは画素を表し、各グリッド内の数字は各画素の色コードを示している。図29(B)は図29(A)に示すOSD表示パターンを色コードとランレングスとでコード化して得られたランレングスコードである。   FIG. 29A shows an example of run-length encoding of an 8 × 8 OSD display pattern. In FIG. 29A, each grid represents a pixel, and the numbers in each grid indicate the color code of each pixel. FIG. 29B shows a run-length code obtained by encoding the OSD display pattern shown in FIG. 29A with a color code and a run-length.

このランレングスコードは、A、B等のアルファベットがランの色コード(A:色コード0、B:色コード1、...)を示し、それに続く数字がそのランのランレングスを10進数で示している。例えば、最初の“B18”は色コードが1、ランレングスが18のランを示している。また、“B18”の次の“A5”は色コードが0、ランレングスが5のランを示している。   In this run length code, alphabets such as A and B indicate the color code of the run (A: color code 0, B: color code 1,...), And the subsequent numbers indicate the run length of the run in decimal. Show. For example, the first “B18” indicates a run with a color code of 1 and a run length of 18. Also, “A5” next to “B18” indicates a run with a color code of 0 and a run length of 5.

ランレングス符号化では、水平ラインごとにランを区切って、次の水平ラインは新しいランとする場合もあるが、図29の例では水平ラインが変わる場合もランは区切らず、連続したランとして符号化している。このようにしても、復号化の際に水平画素数を指定することで正しい復号化が可能である。   In run-length encoding, a run may be divided for each horizontal line, and the next horizontal line may be a new run. However, in the example of FIG. 29, a run is not divided even when the horizontal line is changed, and is encoded as a continuous run. It has become. Even in this way, correct decoding is possible by designating the number of horizontal pixels at the time of decoding.

ランレングスコードをビットパターンで表したランレングスデータは、色コード部及び長さ部のそれぞれに所定のビット数が割り当てられたビットパターンで表される。色コード部のビット数は使用する色数で決まり、長さ部のビット数はランレングスデータの符号長を最小にすることができる値が採用される。使用する色数が8色の場合、色コード部のビット数は3bitとなる。また、長さ部のビット数をm、各ランのランレングスを0〜2m−1としたときの、長さ部のビット数と色コード部のビット数との関係は図30のようになる。 The run-length data in which the run-length code is represented by a bit pattern is represented by a bit pattern in which a predetermined number of bits are assigned to each of the color code part and the length part. The number of bits in the color code portion is determined by the number of colors used, and a value that can minimize the code length of the run-length data is adopted as the number of bits in the length portion. When the number of colors used is 8, the number of bits in the color code part is 3 bits. The relationship between the number of bits in the length part and the number of bits in the color code part when the number of bits in the length part is m and the run length of each run is 0 to 2 m−1 is as shown in FIG. Become.

図30は、図29のランレングスコードについて、色コード部のビット数を3として、長さ部のビット数を変えたときの色コード毎のランレングスデータの符号長である。   FIG. 30 shows the code length of run-length data for each color code when the number of bits in the color code part is 3 and the number of bits in the length part is changed for the run-length code in FIG.

図30において1行目には、1、88、168が格納されている。これは、m=1として図29のランレングスコードをビットパターンで表した場合、色コードが0のランレングスデータは符号長が88ビットとなり、色コードが1のランレングスデータは符号長が168ビットになることを示している。   In FIG. 30, 1, 88, 168 are stored in the first row. This is because when m = 1 and the run-length code in FIG. 29 is represented by a bit pattern, the run-length data with a color code of 0 has a code length of 88 bits, and the run-length data with a color code of 1 has a code length of 168. It shows that it becomes a bit.

また、図30において2行目には、2、40、75が格納されている。これは、m=1として、図29のランレングスコードをランレングスデータで表した場合、色コードが0のランレングスデータは符号長が40ビットとなり、色コードが1のランレングスデータは符号長が75ビットになることを示している。   In FIG. 30, 2, 40, 75 are stored in the second row. This is because when m = 1 and the run-length code in FIG. 29 is represented by run-length data, the run-length data with a color code of 0 has a code length of 40 bits, and the run-length data with a color code of 1 has a code length. Indicates 75 bits.

図30の表から分かるように、色コード0については、長さ部のビット数を3にすると、図29のランレングスコードを24ビットのランレングスデータで表すことができ、色コード1については、長さ部のビット数を5にすると、64ビットのランレングスデータで表すことができ、それぞれランレングスデータの符号長を最小にすることができる。   As can be seen from the table of FIG. 30, for the color code 0, if the number of bits in the length portion is 3, the run length code of FIG. 29 can be represented by 24-bit run length data. If the number of bits in the length part is 5, it can be expressed by 64-bit run-length data, and the code length of the run-length data can be minimized.

図31は、色コード0の長さ部のビット数を3、色コード1の長さ部のビット数を5にした場合の図29のランレングスコードのランレングスデータである。   FIG. 31 shows run-length data of the run-length code of FIG. 29 when the number of bits of the length portion of the color code 0 is 3 and the number of bits of the length portion of the color code 1 is 5.

図31に示すように、Bで表される色コード1は長さ部のビット数が5であるため、B18は00110010の8ビットで表されている。また、Aで表される色コード0は長さ部のビット数が3であるため、A5は000101の6ビットで表されている。   As shown in FIG. 31, since the color code 1 represented by B has 5 bits in the length portion, B18 is represented by 8 bits of 00110010. Further, since the color code 0 represented by A has 3 bits in the length portion, A5 is represented by 6 bits of 00101.

このようにして、図29の“B18〜B17”のランレングスコードをランレングスデータで表すと、図31に示す64ビットのランレングスデータが得られる。   In this way, when the run-length codes “B18 to B17” in FIG. 29 are represented by run-length data, 64-bit run-length data shown in FIG. 31 is obtained.

特開2010−131681号公報JP 2010-131681 A 特開2009−060317号公報JP 2009-060317 A

色コード部のビット数が例えば3の場合、8色の画像を取り扱うことができる。したがって、実際の画像で使用されている色が8色未満の場合、未使用の色コードが発生するが、従来のランレングス符号化においては、この未使用の色コードをどのように取り扱うかに関して全く考慮されていなかった。   When the number of bits in the color code part is 3, for example, an image of 8 colors can be handled. Therefore, when there are less than 8 colors used in the actual image, an unused color code is generated. In the conventional run-length encoding, how to handle this unused color code. It was not considered at all.

また、OSD表示パターンのランレングスデータは、ランレングスの分布には偏りがある場合が多い。図32(A)は、図29のランレングスコードにおいて、色コード1のランのヒストグラムである。図32(B)は、図29のランレングスコードの色コード1において、色コード部のビット数を3ビットとし、長さ部のビット数を1〜5としたときの符号長である。   In addition, the run length data of the OSD display pattern often has a bias in the run length distribution. FIG. 32A is a run histogram of color code 1 in the run-length code of FIG. FIG. 32B shows the code length when the number of bits of the color code part is 3 bits and the number of bits of the length part is 1 to 5 in the color code 1 of the run-length code of FIG.

図32(B)の表から分かるように長さ部のビット数を5にすると符号長を最小にすることができる。しかしながら、ランレングスが2〜3のランは、長さ部のビット数が2であれば十分である。したがって、色コード1について長さ部のビット数を一律に5に設定すると、ランレングスが2〜3のランに対して長さ部のビット数が3ビット余分になり、符号化効率が悪い。これはランレングスの分布に複数の偏りがあることが原因であるが、この複数の偏りに関して、従来のランレングス符号化では全く考慮されていなかった。   As can be seen from the table in FIG. 32B, the code length can be minimized by setting the number of bits in the length part to 5. However, a run with a run length of 2 to 3 is sufficient if the number of bits in the length portion is 2. Therefore, if the number of bits in the length portion is uniformly set to 5 for the color code 1, the number of bits in the length portion is extra 3 bits for runs with run lengths of 2 to 3, resulting in poor encoding efficiency. This is because the run-length distribution has a plurality of biases, but the plurality of biases were not considered at all in the conventional run-length encoding.

本発明の目的は、原画像データをより効率良くランレングス符号化することができる技術を提供することである。   An object of the present invention is to provide a technique capable of more efficiently run-length encoding original image data.

(1)本発明によるランレングス符号化装置は、所定ビット数で色コードを格納する色コード部と、前記色コード毎にビット数が定められた長さ部とで各ランを表すランレングスデータに原画像データを符号化するランレングス符号化装置であって、前記原画像データを色コードとランレングスとでコード化し、ランレングスコードを生成し、前記ランレングスコードを構成する各色コードにつき、各ランのランレングスのヒストグラムを算出し、算出したヒストグラムに基づいて、ある色コードが割り当てられたランの一部を抽出し、未使用の色コードに割り当てる色コード割当部と、前記色コード割当部による割り当てが終了した後、各色コードにつき、全ランの符号化結果が最小となるビット数を前記長さ部のビット数として求め、各ランを符号化する符号化部とを備える。   (1) A run-length encoding apparatus according to the present invention is a run-length data representing each run by a color code part that stores a color code with a predetermined number of bits and a length part in which the number of bits is determined for each color code. A run-length encoding device that encodes original image data, encoding the original image data with a color code and a run length, generating a run-length code, and for each color code constituting the run-length code, A run length histogram of each run is calculated, a part of a run to which a certain color code is assigned is extracted based on the calculated histogram, and a color code assigning unit assigned to an unused color code, and the color code assignment After the allocation by the part is completed, for each color code, the number of bits that minimizes the encoding result of all runs is obtained as the number of bits of the length part. And a coding unit for coding the down.

この構成によれば、色コードごとのランレングスのヒストグラムに基づき、いずれかの色コードのランが未使用の色コードに振り分けられる。そのため、原画像データを効率良く符号化することができる。   According to this configuration, the run of any one of the color codes is assigned to an unused color code based on the run length histogram for each color code. Therefore, the original image data can be efficiently encoded.

(2)前記符号化部は、各色コードにつき、ランレングスの最小値をベース値として算出するベース値算出部と、各ランにつき、ランレングスから対応する色コードのベース値を差し引き、各ランの差分ランレングスを算出する差分ランレングス算出部と、各色コードにつき、全ランの差分ランレングスを表すことができる最小のビット数を前記長さ部のビット数として求め、各ランを符号化する差分ランレングス符号化部とを備えることが好ましい。   (2) The encoding unit subtracts the base value of the corresponding color code from the run length for each run by subtracting the base value calculation unit that calculates the minimum value of the run length as the base value for each color code. A difference run length calculation unit for calculating a difference run length, and a difference in which each run is encoded by obtaining the minimum number of bits that can represent the difference run length of all runs as the number of bits of the length part for each color code It is preferable to include a run-length encoding unit.

この構成によれば、各色コードにつき、ランレングスの最小値がベース値として算出される。そして、各ランのランレングスから対応する色コードのベース値が差し引かれて差分ランレングスが算出される。そのため、差分ランレングスはベース値からのオフセットを表し、ランレングスよりも小さくなる。よって、差分ランレングスで各ランを表すことで、各ランの符号長をより短くし、ランレングスデータのビット長を更に短くすることができる。   According to this configuration, the minimum run length is calculated as the base value for each color code. Then, a difference run length is calculated by subtracting the base value of the corresponding color code from the run length of each run. Therefore, the differential run length represents an offset from the base value, and is smaller than the run length. Therefore, by representing each run with a differential run length, the code length of each run can be further shortened, and the bit length of the run length data can be further shortened.

(3)前記符号化部は、各色コードにつき、前記ベース値を、前記長さ部のビット数と対応付けてベース値テーブルを生成するベース値テーブル生成部を更に備えることが好ましい。   (3) It is preferable that the encoding unit further includes a base value table generation unit that generates a base value table by associating the base value with the number of bits of the length part for each color code.

この構成によれば、各色コードにつき、ベース値と長さ部のビット数とが対応付けられたベース値テーブルが生成されるため、このベース値テーブルを参照することで、差分ランレングスからランレングスを算出することができる。   According to this configuration, for each color code, a base value table in which the base value and the number of bits of the length part are associated with each other is generated. By referring to this base value table, the difference run length is changed to the run length. Can be calculated.

(4)前記色コード割当部は、前記ヒストグラムからランレングスに複数の偏りがある色コードを特定し、特定した色コードに対し、同じ偏りに属するランを抽出し、前記未使用の色コードを割り当てることが好ましい。   (4) The color code assigning unit identifies a color code having a plurality of deviations in run length from the histogram, extracts a run belonging to the same deviation for the identified color code, and selects the unused color code. It is preferable to assign.

この構成によれば、各色コードに複数の偏りがある場合、これらの偏りが分散されるように、各色コードにランが割り当てられる。そのため、符号化効率を改善することができる。   According to this configuration, when there are a plurality of deviations in each color code, a run is assigned to each color code so that these deviations are distributed. Therefore, encoding efficiency can be improved.

(5)前記色コード割当部は、各色コードにつき、前記長さ部のビット数の分割位置を変えながら符号長の削減量を算出し、前記削減量を最大化する分割位置を持つ色コードを、前記複数の偏りがある色コードとして特定し、特定した色コードにおいて、前記削減量を最大化する分割位置より大きなビット数で表されるランレングスを持つランを抽出し、前記未使用の色コードを割り当てることが好ましい。   (5) The color code allocating unit calculates a code length reduction amount while changing a division position of the number of bits of the length portion for each color code, and selects a color code having a division position that maximizes the reduction amount. The color codes having a plurality of biases are extracted, and in the specified color code, a run having a run length represented by a bit number larger than a division position that maximizes the reduction amount is extracted, and the unused color is extracted. It is preferable to assign a code.

この構成によれば、各色コードにおいて長さ部のビット数を分割するための分割位置をより正確に求めることができる。   According to this configuration, the division position for dividing the number of bits of the length portion in each color code can be obtained more accurately.

(6)本発明によるランレングス復号化装置は、所定ビット数で色コードを格納する色コード部と、前記色コード毎にビット数が定められた長さ部とを用いて各ランを表すランレングスデータを原画像データに復号化するランレングス復号化装置であって、前記長さ部は、各ランのランレングスから各ランのベース値を差し引いた差分ランレングスを格納し、前記ベース値は、各色コードにおけるランレングスの最小値を示し、各色コードにつき、前記ベース値と前記長さ部のビット数とが対応付けられたベース値テーブルを保持するベース値テーブル保持部と、各色コードをビットマップ形式で表すための色情報を保持する色情報保持部と、前記ランレングスデータから色コードを特定し、特定した色コードに対応する前記長さ部のビット数を前記ベース値テーブルから特定し、特定したビット数分の前記色コードに続く前記ランレングスデータを差分ランレングスとして抽出する差分ランレングス抽出部と、前記差分ランレングス抽出部により抽出された差分ランレングスに対応するベース値を加算し、ランレングスを算出する加算部と、前記加算部により算出されたランレングス及び前記色情報に基づいて前記ランレングスデータを前記原画像データに復号化する復号化部とを備える。   (6) A run-length decoding apparatus according to the present invention uses a color code part that stores a color code with a predetermined number of bits and a length part in which the number of bits is determined for each color code to represent each run. A run-length decoding device that decodes length data into original image data, wherein the length section stores a differential run length obtained by subtracting the base value of each run from the run length of each run, and the base value is , A minimum value of run length in each color code, a base value table holding unit for holding a base value table in which the base value and the number of bits of the length part are associated with each color code, and each color code in bits A color information holding unit that holds color information to be expressed in a map format, a color code specified from the run-length data, and a bit of the length part corresponding to the specified color code Is determined from the base value table, and the run length data following the color code for the specified number of bits is extracted as a difference run length, and the difference run extracted by the difference run length extraction unit An adder that adds a base value corresponding to a length and calculates a run length; and a decoding that decodes the run length data into the original image data based on the run length calculated by the adder and the color information A part.

この構成によれば、差分ランレングスを用いて各ランが表された符号化ランレングスを復号化することができる。   According to this configuration, it is possible to decode the encoded run length in which each run is represented using the differential run length.

本発明によれば、原画像データを効率良くランレングスデータに符号化することができる。   According to the present invention, original image data can be efficiently encoded into run-length data.

本発明の実施の形態によるランレングス符号化装置のブロック図である。It is a block diagram of the run-length encoding apparatus by embodiment of this invention. (A)は図29(A)に対して色コードが1、かつ、ランレングスが2〜3のランに対し、色コード2が割り当てられた原画像データである。(B)は(A)の原画像データのランレングスコードである。(A) is original image data in which color code 2 is assigned to a run having a color code of 1 and a run length of 2 to 3 with respect to FIG. (B) is a run-length code of the original image data of (A). 図2(B)のランレングスコードを、長さ部のビット数を変えて符号化したときの色コード別の符号長である。This is the code length for each color code when the run-length code in FIG. 2B is encoded by changing the number of bits in the length part. ベース値テーブルが生成される処理を示した図である。It is the figure which showed the process by which a base value table is produced | generated. 本発明の実施の形態によるランレングス復号化装置のブロック図である。It is a block diagram of the run length decoding apparatus by embodiment of this invention. 図5に示すランレングス符号化装置が適用されていない比較例の車載用カメラの機能ブロック図である。It is a functional block diagram of the vehicle-mounted camera of the comparative example to which the run length encoding apparatus shown in FIG. 5 is not applied. 図5に示すランレングス復号化装置が適用された車載用カメラの機能ブロック図である。FIG. 6 is a functional block diagram of a vehicle-mounted camera to which the run-length decoding device shown in FIG. 5 is applied. 図5に示すランレングス復号化装置が適用された車載用カメラのハードウェア構成を示すブロック図である。It is a block diagram which shows the hardware constitutions of the vehicle-mounted camera to which the run length decoding apparatus shown in FIG. 5 was applied. 図8に示す車載用カメラにおいて、6種類のOSD表示パターンを撮像画像データに重畳して出力する場合のOSD表示制御部83の機能ブロック図である。FIG. 9 is a functional block diagram of an OSD display control unit 83 in a case where six types of OSD display patterns are superimposed and output on captured image data in the in-vehicle camera shown in FIG. 8. ランレングス符号化装置が車載用カメラにランレングスデータを書き込む際の処理を示したブロック図である。It is the block diagram which showed the process at the time of a run length encoding apparatus writing run length data in a vehicle-mounted camera. (A)は、図1に示すランレングス符号化装置が行うランレングス符号化処理を示したフローチャートである。(A) is the flowchart which showed the run length encoding process which the run length encoding apparatus shown in FIG. 1 performs. 図11(A)の色コード分割処理のサブルーチンを示すフローチャートである。12 is a flowchart showing a subroutine of color code division processing in FIG. 図11に示すベース値算出処理のサブルーチンを示すフローチャートである。It is a flowchart which shows the subroutine of the base value calculation process shown in FIG. 図11のランレングス符号化処理のサブルーチンを示すフローチャートである。It is a flowchart which shows the subroutine of the run length encoding process of FIG. 図13、図14、図16で示すラン抽出処理のサブルーチンを示すフローチャートである。17 is a flowchart showing a subroutine of the run extraction process shown in FIGS. 13, 14, and 16. 図11(B)に示す長さ部ビット数算出処理のサブルーチンを示すフローチャートである。12 is a flowchart showing a subroutine of length part bit number calculation processing shown in FIG. 実施例2でランレングス符号化の対象となるOSD表示パターンを示した図である。It is the figure which showed the OSD display pattern used as the object of run length encoding in Example 2. FIG. 初期のヒストグラムである。It is an initial histogram. 初期の色コードテーブルである。It is an initial color code table. 初期の符号長テーブルである。It is an initial code length table. 符号長削減量テーブルである。It is a code length reduction amount table. 初期のヒストグラムを更新することで得られたヒストグラムである。This is a histogram obtained by updating the initial histogram. 図19に示す初期の色コードテーブルを更新することで得られた色コードテーブルである。20 is a color code table obtained by updating the initial color code table shown in FIG. 色コード分割処理によって最終的に得られたヒストグラムである。It is the histogram finally obtained by the color code division process. 色コード分割処理によって最終的に得られた色コードテーブルである。It is a color code table finally obtained by the color code dividing process. 色コード分割処理によって最終的に得られた符号長テーブルである。It is a code length table finally obtained by color code division processing. 色コード分割処理が行われた図17に示すOSD表示パターンに対し、差分ランレングスを求めて符号化した場合の効果を示す表である。It is a table | surface which shows the effect at the time of calculating | requiring and encoding a difference run length with respect to the OSD display pattern shown in FIG. 17 in which the color code division | segmentation process was performed. 実施例2の結果をまとめた表である。10 is a table summarizing the results of Example 2. (A)は8×8のOSD表示パターンをランレングス符号化した一例である。(B)は図29(A)に示すOSD表示パターンを色コードとランレングスとでコード化することで得られたランレングスコードである。(A) is an example of run-length encoding of an 8 × 8 OSD display pattern. (B) is a run length code obtained by encoding the OSD display pattern shown in FIG. 29 (A) with a color code and a run length. 図29のランレングスコードについて、色コード部のビット数を3として、長さ部のビット数を変えたときの色コード毎のランレングスデータの符号長である。The run length data shown in FIG. 29 is the code length of run length data for each color code when the number of bits in the color code part is 3 and the number of bits in the length part is changed. 色コード0の長さ部のビット数を3、色コード1の長さ部のビット数を5にして、図29のランレングスコードのビットパターンである。29 is a bit pattern of the run length code of FIG. 29 with the number of bits of the length portion of the color code 0 being 3 and the number of bits of the length portion of the color code 1 being 5. (A)は、図29のランレングスコードにおいて、色コード1のランのヒストグラムである。(B)は、図29のランレングスコードの色コード1において、色コード部のビット数を3ビットとし、長さ部のビット数を1〜5としたときの符号長である。FIG. 29A is a histogram of the run of color code 1 in the run length code of FIG. (B) is the code length when the number of bits of the color code portion is 3 bits and the number of bits of the length portion is 1 to 5 in the color code 1 of the run length code of FIG.

図1は、本発明の実施の形態によるランレングス符号化装置のブロック図である。ランレングス符号化装置は、画像取得部11、テーブル保持部12、色コード割当部13、符号化部14、及びランレングスデータ保持部16を備えている。   FIG. 1 is a block diagram of a run-length encoding apparatus according to an embodiment of the present invention. The run-length encoding apparatus includes an image acquisition unit 11, a table holding unit 12, a color code allocation unit 13, an encoding unit 14, and a run-length data holding unit 16.

画像取得部11は、符号化対象となる原画像データを取得する。ここで、原画像データは、例えば、複数の画素がマトリックス状に配列されたデータ構造を持つ。また、各画素は、R,G,B、及び透明度の4成分からなる画素値を持つ。   The image acquisition unit 11 acquires original image data to be encoded. Here, the original image data has, for example, a data structure in which a plurality of pixels are arranged in a matrix. Each pixel has a pixel value composed of four components of R, G, B, and transparency.

色コード割当部13は、画像取得部11により取得された原画像データの各画素に対して色毎に色コードを付す。そして、色コードを付した原画像データを色コードとランレングスとでコード化し、ランレングスコードを生成する。ここで、ランレングスコードは、複数のランから構成されている。各ランは、色コードとランレングスとで構成されている。色コードはランの色を示す。ランレングスはランの長さを示す。   The color code assigning unit 13 assigns a color code for each color to each pixel of the original image data acquired by the image acquiring unit 11. Then, the original image data with the color code is encoded with the color code and the run length to generate a run length code. Here, the run-length code is composed of a plurality of runs. Each run is composed of a color code and a run length. The color code indicates the color of the run. Run length indicates the length of the run.

例えば、図29(A)の例では、左上の画素からラスタ走査していくと、色コード1の画素が18個連続している。そのため、これら18個の画素が1つのランとなる。そして、色コード1に対応する符号Bがこのランの色コードとして設定される。なお、図29(B)の例では、色コード0,1は、それぞれA,Bの符号で表されている。   For example, in the example of FIG. 29A, when raster scanning is performed from the upper left pixel, 18 pixels of color code 1 are continuous. Therefore, these 18 pixels form one run. The code B corresponding to the color code 1 is set as the color code of this run. In the example of FIG. 29B, the color codes 0 and 1 are represented by the symbols A and B, respectively.

また、この1つのランには18個の画素が含まれるため、この1つのランのランレングスとして10進数の18が設定される。色コード割当部13は、図29(A)に示す色コードを付与した原画像データに対してこの処理を繰り返し、図29(B)に示すランレングスコードを生成する。   Further, since this one run includes 18 pixels, the decimal number 18 is set as the run length of this one run. The color code assigning unit 13 repeats this process for the original image data to which the color code shown in FIG. 29A is assigned, and generates a run-length code shown in FIG.

また、色コード割当部13は、生成したランレングスコードを構成する各色コードにつき、各ランのランレングスのヒストグラムを算出し、算出したヒストグラムに基づいて、ある色コードが割り当てられたランの一部を抽出し、未使用の色コードに割り当てる。   The color code assigning unit 13 calculates a run-length histogram of each run for each color code constituting the generated run-length code, and a part of the run to which a certain color code is assigned based on the calculated histogram. Are extracted and assigned to unused color codes.

図29(A)の例では、原画像データには色コード0、色コード1が含まれているため、それぞれの色コード0,1のヒストグラムが算出される。この例において、色コード1に対しては、例えば図32(A)で示すようなヒストグラムが算出される。つまり、色コード割当部13は、ランレングスのビット長を複数の階級に分け、各ランのランレングスがどの階級に属するかを特定し、特定した階級に投票することでヒストグラムを算出し、テーブル保持部12に保持する。   In the example of FIG. 29A, since the original image data includes color code 0 and color code 1, histograms of the respective color codes 0 and 1 are calculated. In this example, for the color code 1, for example, a histogram as shown in FIG. That is, the color code assigning unit 13 divides the run length bit length into a plurality of classes, identifies which class the run length of each run belongs to, and calculates a histogram by voting to the identified class, It is held by the holding unit 12.

本実施の形態では、最終的に色コードを3ビットのビット列で2進数表示する。そのため、色コードは、最大8つの色コードを表すことができるが、図29(A)の原画像データでは色コードが2つしか使用されていないため、6つの色コードが未使用となっている。   In the present embodiment, the color code is finally displayed as a binary number in a 3-bit bit string. Therefore, although the color code can represent a maximum of eight color codes, since only two color codes are used in the original image data of FIG. 29A, six color codes are unused. Yes.

そこで、色コード割当部13は、未使用の色コードがある場合、色コードごとのランレングスのヒストグラムに基づき、いずれかの色コードのランを未使用の色コードに振り分けることにより、符号化効率を改善している。   Therefore, when there is an unused color code, the color code allocating unit 13 assigns the run of one of the color codes to the unused color code based on the run length histogram for each color code, thereby encoding efficiency. Has improved.

図32(A)の例では、ランレングスが2〜3と16〜31に偏って分布している。そこで、色コード割当部13は、ランレングスが2〜3のランの色コードに対し、未使用の色コード2を割り当てる。つまり、色コード割当部13は、ランレングスに複数の偏りがある色コードに対し、同じ偏りに属するランを抽出し、未使用の色コードを割り当てる。   In the example of FIG. 32 (A), the run lengths are distributed in a biased way to 2-3 and 16-31. Therefore, the color code assigning unit 13 assigns an unused color code 2 to the color code of the run having a run length of 2 to 3. That is, the color code assigning unit 13 extracts runs belonging to the same bias and assigns unused color codes to color codes having a plurality of biases in the run length.

図2(A)は、図29(A)の例において、色コードが1、かつ、ランレングスが2〜3のランに色コード2を割り当てたときの原画像データである。図2(A)に示すように、図29(A)で色コード1が付与されていた画素が色コード2に変更されている。図2(B)は、図2(A)の原画像データのランレングスコードである。この例では、色コード2に対してCの符号が割り当てられ、ランレングスコードが表されている。   FIG. 2A shows original image data when color code 2 is assigned to a run having a color code of 1 and a run length of 2 to 3 in the example of FIG. As shown in FIG. 2A, the pixel to which color code 1 is assigned in FIG. FIG. 2B is a run-length code of the original image data in FIG. In this example, a C code is assigned to the color code 2 to represent a run length code.

また、色コード割当部13は、各色コードと長さ部のビット数とが対応付けられた色コードテーブル(図19参照)を生成し、テーブル保持部12に保持する。   In addition, the color code assigning unit 13 generates a color code table (see FIG. 19) in which each color code is associated with the number of bits of the length part, and stores the color code table in the table holding unit 12.

そして、色コード割当部13は、色コードの割り当てを変更すると、その割り当ての変更が反映されるように色コードテーブル及びヒストグラムをそれぞれ更新する。具体的には、色コード割当部13は、あるランにつき色コードの割り当てを変更した場合、そのランの当初の色コードと変更後の色コードとが対応付けられるように色コードテーブルを更新する。   Then, when the color code assignment is changed, the color code assignment unit 13 updates the color code table and the histogram so that the change in the assignment is reflected. Specifically, when the color code assignment for a certain run is changed, the color code assigning unit 13 updates the color code table so that the original color code of the run and the changed color code are associated with each other. .

このように、色コードテーブルを更新することで、復号化を行う際、色コードの割り当てが変更されたランについて、そのランが当初持っていた色を再現することができる。   In this way, by updating the color code table, when decoding is performed, the color originally assigned to the run can be reproduced for the run whose color code assignment is changed.

符号化部14は、色コード割当部13による割り当てが終了した後、各色コードにつき、全ランの符号化結果が最小となるビット数を長さ部のビット数として求め、各ランを符号化し、ランレングスコードをビットパターンで表したランレングスデータを求める。ここで、ランレングスデータは、各ランを色コード部と長さ部とで表すデータ構造を持っている。色コード部のビット数は3である。   After the assignment by the color code assigning unit 13 is completed, the encoding unit 14 obtains, as the number of bits of the length part, the number of bits that minimizes the encoding result of all runs for each color code, encodes each run, Run-length data representing the run-length code as a bit pattern is obtained. Here, the run length data has a data structure in which each run is represented by a color code portion and a length portion. The number of bits of the color code part is 3.

図3は、図2(B)のランレングスコードを、長さ部のビット数を変えて符号化したときの色コード別の符号長である。色コード0は長さ部のビット数を3、色コード1は長さ部のビット数を5、色コード2は長さ部のビット数を2に設定すると、ランレングスデータの符号長が55ビットとなり、符号長を最小にすることができる。一方、色コード1の一部のランを色コード2に割り当てる前は、図30に示すようにランレングスデータの符号長は64ビットであった。したがって、色コード1のランのうち、ランレングスが2〜3のランを色コード2に割り当てることで、符号号化効率を改善することができる。   FIG. 3 shows the code length for each color code when the run-length code in FIG. 2B is encoded by changing the number of bits in the length portion. If color code 0 is set to 3 in the length part, color code 1 is set to 5 in the length part, and color code 2 is set to 2 in the length part, the run length data code length is 55. The code length can be minimized. On the other hand, before assigning a part of the run of color code 1 to color code 2, the code length of the run-length data was 64 bits as shown in FIG. Therefore, the coding efficiency can be improved by allocating the run having the run length of 2 to 3 to the color code 2 among the runs of the color code 1.

具体的には、符号化部14は、ベース値算出部141、差分ランレングス算出部142、差分ランレングス符号化部143、及びベース値テーブル生成部144を備えている。   Specifically, the encoding unit 14 includes a base value calculation unit 141, a differential run length calculation unit 142, a differential run length encoding unit 143, and a base value table generation unit 144.

ベース値算出部141は、画像取得部11により取得された原画像データから、色コード割当部13と同様にしてランレングスコードを生成し、各色コードにつき、ランレングスの最小値をベース値として算出する。差分ランレングス算出部142は、画像取得部11により取得された原画像データから色コード割当部13と同様にしてランレングスコードを生成し、各ランにつき、ランレングスから対応する色コードのベース値を差し引き各ランの差分ランレングスを算出する。   The base value calculation unit 141 generates a run length code from the original image data acquired by the image acquisition unit 11 in the same manner as the color code allocation unit 13, and calculates the minimum run length value for each color code as a base value. To do. The difference run length calculation unit 142 generates a run length code from the original image data acquired by the image acquisition unit 11 in the same manner as the color code allocation unit 13, and for each run, the base value of the corresponding color code from the run length. Is subtracted to calculate the differential run length of each run.

差分ランレングス符号化部143は、画像取得部11により取得された原画像データから色コード割当部13と同様にしてランレングスコードを生成し、各色コードにつき、全ランの差分ランレングスを表すことができる最小のビット数を長さ部のビット数として求め、各ランを符号化する。   The difference run length encoding unit 143 generates a run length code from the original image data acquired by the image acquisition unit 11 in the same manner as the color code allocation unit 13, and represents the difference run length of all runs for each color code. The minimum number of bits that can be obtained is obtained as the number of bits in the length part, and each run is encoded.

ベース値テーブル生成部144は、ベース値算出部141により各色コードについて算出されたベース値を、差分ランレングス符号化部143により各色コードについて算出された長さ部のビット数と対応付けてベース値テーブルを生成し、テーブル保持部12に保持する。   The base value table generation unit 144 associates the base value calculated for each color code by the base value calculation unit 141 with the number of bits of the length part calculated for each color code by the differential run length encoding unit 143. A table is generated and held in the table holding unit 12.

図4は、ベース値テーブルが生成される処理を示した図である。図4(A)は図2(A)の色コードが付された原画像データであり、(B)は(A)の原画像データを差分ランレングスを用いて表したときのランレングスコードであり、(C)はベース値テーブルである。   FIG. 4 is a diagram illustrating processing for generating a base value table. 4A is the original image data to which the color code of FIG. 2A is attached, and FIG. 4B is a run-length code when the original image data of (A) is expressed using a differential run-length. Yes, (C) is a base value table.

図4(C)の例では、色コード0,1,2のベース値はそれぞれ5,17,2と算出されている。よって、図2(B)で“B18”と表されていたランの差分ランレングスは18−17=1となる。したがって、このB18のランは図4(B)ではB1と表されている。他のランについても同様に差分ランレングスが求められる。そして、各色コードにつき、全差分ランレングスを表すことができるビット数が求められる。すると、図4(C)に示すように、色コード0,1,2の長さ部のビット数はそれぞれ1と算出される。以上により、図4(C)に示すように、各色コードにつき、長さ部のビット数とベース値とが対応付けられたベース値テーブルが生成される。   In the example of FIG. 4C, the base values of the color codes 0, 1, and 2 are calculated as 5, 17, and 2, respectively. Therefore, the run difference run length of “B18” in FIG. 2B is 18−17 = 1. Therefore, this run of B18 is represented as B1 in FIG. Differential run lengths are similarly obtained for other runs. For each color code, the number of bits that can represent the total differential run length is obtained. Then, as shown in FIG. 4C, the number of bits of the length portion of the color codes 0, 1, and 2 is calculated as 1, respectively. As described above, as shown in FIG. 4C, a base value table in which the number of bits of the length part and the base value are associated with each color code is generated.

図4(B)に示すランレングスコードをランレングスデータで表すと、符号長は36ビットであった。したがって、図2(B)で色コードを振り分けることで55ビットに削減された符号長が、更に36ビットまで削減され、符号化効率が改善されている。   When the run-length code shown in FIG. 4B is represented by run-length data, the code length is 36 bits. Therefore, the code length reduced to 55 bits by distributing the color code in FIG. 2B is further reduced to 36 bits, and the encoding efficiency is improved.

図1に戻り、ランレングスデータ保持部16は、差分ランレングス符号化部143により生成されたランレングスデータを保持する。   Returning to FIG. 1, the run-length data holding unit 16 holds the run-length data generated by the differential run-length encoding unit 143.

このように、ベース値からのランレングスのオフセットを表す差分ランレングスを用いて各ランを表すことで、各ランの符号長をより短くし、ランレングスデータの符号長を更に短くすることができる。   In this way, by representing each run using the differential run length representing the run length offset from the base value, the code length of each run can be further shortened, and the code length of the run length data can be further shortened. .

図5は、本発明の実施の形態によるランレングス復号化装置のブロック図である。ランレングス復号化装置は、図1に示すランレングス符号化装置で生成されたランレングスデータを復号する。   FIG. 5 is a block diagram of a run-length decoding apparatus according to the embodiment of the present invention. The run-length decoding apparatus decodes run-length data generated by the run-length encoding apparatus shown in FIG.

具体的には、ランレングス復号装置は、ベース値テーブル保持部51、色情報保持部52、差分ランレングス抽出部53、加算部54、及び復号化部55を備えている。   Specifically, the run length decoding apparatus includes a base value table holding unit 51, a color information holding unit 52, a difference run length extracting unit 53, an adding unit 54, and a decoding unit 55.

ベース値テーブル保持部51は、各色コードにつき、ベース値と長さ部のビット数とが対応付けられたベース値テーブルを保持する。つまり、ベース値テーブル保持部51は、図1に示すランレングス符号化装置により生成されたベース値テーブルを保持する。   The base value table holding unit 51 holds a base value table in which the base value and the number of bits of the length part are associated with each color code. That is, the base value table holding unit 51 holds the base value table generated by the run-length encoding device shown in FIG.

図5に示すようにベース値テーブル保持部51は、図4(C)に示すベース値テーブルと同じものを記憶している。   As shown in FIG. 5, the base value table holding unit 51 stores the same base value table as that shown in FIG.

色情報保持部52は、ランレングスデータをビットマップデータに展開する際に必要となる色情報を保持する。図5に示すように色情報保持部52は、各色コードに対し、R,G,Bの画素値と透明度αを示す画素値との4つの画素値が対応付けられた色情報テーブルを保持している。   The color information holding unit 52 holds color information necessary for developing run-length data into bitmap data. As shown in FIG. 5, the color information holding unit 52 holds a color information table in which four pixel values of R, G, B pixel values and pixel values indicating transparency α are associated with each color code. ing.

差分ランレングス抽出部53は、ランレングス符号化装置により生成されたランレングスデータから色コードを特定し、特定した色コードに対応する長さ部のビット数をベース値テーブルから特定し、特定したビット数分の色コードに続くランレングスデータを差分ランレングスとして抽出する。   The difference run-length extraction unit 53 identifies the color code from the run-length data generated by the run-length encoding apparatus, identifies the number of bits of the length part corresponding to the identified color code from the base value table, and identifies Run-length data following the color code for the number of bits is extracted as a differential run-length.

具体的には、差分ランレングス抽出部53は、まず、ランレングスデータの最初の3ビットに格納された符号列を抽出する。本実施の形態では、ランレングスデータは、各ランが色コード部と長さ部との順で表され、色コード部のビット数は3ビットである。したがって、ランレングスデータの最初の3ビットは色コードを表すことになる。図5の例では、最初の3ビットに001の符号列が格納されている。よって、差分ランレングス抽出部53は、最初のランの色コード1と判定する。   Specifically, the differential run length extraction unit 53 first extracts the code string stored in the first 3 bits of the run length data. In the present embodiment, each run is represented in the order of a color code part and a length part in the run length data, and the number of bits of the color code part is 3 bits. Therefore, the first 3 bits of the run length data represent the color code. In the example of FIG. 5, a code string of 001 is stored in the first 3 bits. Therefore, the differential run length extraction unit 53 determines that the color code is 1 for the first run.

次に、差分ランレングス抽出部53は、色コード1に対応する長さ部のビット数をベース値テーブルから特定する。この場合、色コード1に対応する長さ部のビット数は1である。よって、差分ランレングス抽出部53は、最初のランの長さ部のビット数は1と判定する。   Next, the differential run length extraction unit 53 specifies the number of bits of the length portion corresponding to the color code 1 from the base value table. In this case, the number of bits of the length portion corresponding to the color code 1 is 1. Therefore, the differential run length extraction unit 53 determines that the number of bits in the length portion of the first run is 1.

次に、差分ランレングス抽出部53は、最初のランの色コードに続く、1ビットのランレングスデータを差分ランレングスとして抽出する。この場合、差分ランレングスは1である。つまり、最初のランは色コードが001の符号列で表され、長さ部が1の符号列で表されている。よって、差分ランレングス抽出部53は、ランレングスデータの5,6,7番目の3ビットを2番目のランの色コード部と判定する。差分ランレングス抽出部53は、以上の処理を繰り返し、ランレングスデータに含まれる色コードと差分ランレングスとを順次に特定する。   Next, the differential run length extracting unit 53 extracts 1-bit run length data following the color code of the first run as a differential run length. In this case, the differential run length is 1. That is, the first run is represented by a code string having a color code of 001 and a length part having a code string of 1. Therefore, the differential run length extracting unit 53 determines the fifth, sixth, and seventh third bits of the run length data as the color code portion of the second run. The difference run length extraction unit 53 repeats the above processing, and sequentially specifies the color code and the difference run length included in the run length data.

加算部54は、差分ランレングス抽出部53により抽出された差分ランレングスに対応するベース値を加算し、ランレングスを算出する。図5の例では、最初のランの差分ランレングスは1である。また、最初のランの色コードは1である。よって、加算部54は、色コード1に対応する長さ部のベース値である17をベース値テーブルから読み出す。そして、加算部54は、読み出したベース値である17に差分ランレングスである1を加算し、ランレングスを算出する。この場合、ランレングスは18となり、図2(B)に示す“B18”が再現される。   The adding unit 54 adds the base values corresponding to the differential run length extracted by the differential run length extracting unit 53, and calculates the run length. In the example of FIG. 5, the differential run length of the first run is 1. The color code of the first run is 1. Therefore, the adding unit 54 reads 17 which is the base value of the length portion corresponding to the color code 1 from the base value table. Then, the adding unit 54 adds the difference run length 1 to the read base value 17 to calculate the run length. In this case, the run length is 18, and “B18” shown in FIG. 2B is reproduced.

復号化部55は、加算部54により算出されたランレングス及び色情報テーブルに基づいてランレングスデータをビットマップデータに展開する。先の例では、最初のランの色コードは1であり、レングスは18であった。   The decoding unit 55 expands the run length data into bitmap data based on the run length and color information table calculated by the addition unit 54. In the previous example, the color code for the first run was 1 and the length was 18.

したがって、復号化部55は、色コード1に対応するR,G,B,αの画素値を色情報テーブルから読み出し、連続する18個の画素に対して、色コード1に対応するR,G,B,αの画素値を設定し、各画素を順次に出力することで、ランレングスデータをビットマップデータに展開する。これにより原画像データが得られる。   Therefore, the decoding unit 55 reads out the R, G, B, and α pixel values corresponding to the color code 1 from the color information table, and R and G corresponding to the color code 1 for 18 consecutive pixels. , B, α pixel values are set, and each pixel is output sequentially, whereby the run-length data is developed into bitmap data. Thereby, original image data is obtained.

例えば、復号化部55は、撮像系で撮像された撮像画像データが展開されたフレームバッファに画素値を書き込むことでビットマップデータに展開する。その結果、OSD表示パターン専用のフレームバッファが不要となる。そして、復号化部55は、各ランに対して上記の処理を繰り返し、OSD表示パターンを撮像画像データに重畳表示する。   For example, the decoding unit 55 develops bitmap data by writing pixel values into a frame buffer in which captured image data captured by the imaging system is expanded. As a result, a dedicated frame buffer for the OSD display pattern becomes unnecessary. And the decoding part 55 repeats said process with respect to each run, and superimposes and displays an OSD display pattern on captured image data.

(実施例1)
次に、図5に示すランレングス復号化装置を車載用カメラに適用した実施例1について説明する。車載用カメラでは、バックビューモニタ用途での車幅線表示など、撮像画像にグラフィックを重畳して出力する機能が求められる。このグラフィックがOSD表示パターンである。
Example 1
Next, a first embodiment in which the run-length decoding apparatus shown in FIG. 5 is applied to a vehicle-mounted camera will be described. A vehicle-mounted camera is required to have a function of superimposing a graphic on a captured image and outputting it, such as a vehicle width line display for backview monitor applications. This graphic is an OSD display pattern.

OSD表示パターンを表示する方法として、ECUなどではOSD表示パターン専用のフレームバッファを設け、グラフィックコントローラでフレームバッファにOSDパターンを描画する構成が採用される。   As a method for displaying the OSD display pattern, a configuration in which a frame buffer dedicated to the OSD display pattern is provided in the ECU or the like and the OSD pattern is drawn in the frame buffer by a graphic controller is adopted.

図6は、図5に示すランレングス符号化装置が適用されていない比較例の車載用カメラの機能ブロック図である。図6に示す車載用カメラは、撮像系61、画像処理回路62、グラフィックコントローラ63、フレームバッファ64、及び出力制御部65を備えている。   FIG. 6 is a functional block diagram of a vehicle-mounted camera of a comparative example to which the run-length encoding device shown in FIG. 5 is not applied. The in-vehicle camera shown in FIG. 6 includes an imaging system 61, an image processing circuit 62, a graphic controller 63, a frame buffer 64, and an output control unit 65.

撮像系61は、所定のフレームレートで被写体を撮像するカメラにより構成され、撮像画像データを取得する。画像処理回路62は、撮像系61により取得された撮像画像データに対し、ガンマ補正等の所定の画像処理を行う。グラフィックコントローラ63は、描画回路631及び重畳回路632を備えている。   The imaging system 61 is configured by a camera that images a subject at a predetermined frame rate, and acquires captured image data. The image processing circuit 62 performs predetermined image processing such as gamma correction on the captured image data acquired by the imaging system 61. The graphic controller 63 includes a drawing circuit 631 and a superimposing circuit 632.

描画回路631は、CPUから描画命令を受け、OSD表示パターンをフレームバッファ64に生成する。重畳回路632は、フレームバッファ64に展開されたOSD表示パターンと、画像処理回路62から出力された撮像画像データとを重畳し、出力制御部65に出力する。具体的には、重畳回路632は、画像処理回路62から入力される撮像画像データに同期してフレームバッファ64からOSD表示パターンを読み出し、画素演算により重畳結果を生成する。出力制御部65は、重畳結果画像をNTSC信号やデジタル信号として外部に出力する。   The drawing circuit 631 receives a drawing command from the CPU and generates an OSD display pattern in the frame buffer 64. The superimposing circuit 632 superimposes the OSD display pattern developed in the frame buffer 64 and the captured image data output from the image processing circuit 62, and outputs them to the output control unit 65. Specifically, the superimposing circuit 632 reads an OSD display pattern from the frame buffer 64 in synchronization with the captured image data input from the image processing circuit 62, and generates a superimposition result by pixel calculation. The output control unit 65 outputs the superimposed result image to the outside as an NTSC signal or a digital signal.

このように、比較例の車載用カメラの構成ではフレームバッファ64として、大容量のRAMが必要となる。また、描画回路631を備えるグラフィックコントローラ63が必要になり、コストが嵩む。   Thus, the configuration of the in-vehicle camera of the comparative example requires a large-capacity RAM as the frame buffer 64. In addition, the graphic controller 63 including the drawing circuit 631 is required, which increases the cost.

車載用途で必要となるOSD表示パターンは、車幅線等の予め決められたグラフィック画像が採用される。そのため、必要なOSD表示パターンを符号化し、データとして保持しておき、表示時にリアルタイムで復号化して表示する構成を採用すると、フレームバッファ64や描画回路631が不要となり、コストダウンが可能である。   The OSD display pattern required for in-vehicle use employs a predetermined graphic image such as a vehicle width line. Therefore, if a configuration is adopted in which a necessary OSD display pattern is encoded and stored as data, and decoded and displayed in real time at the time of display, the frame buffer 64 and the drawing circuit 631 are not necessary, and the cost can be reduced.

図7は、図5に示すランレングス復号化装置が適用された車載用カメラの機能ブロック図である。図7に示す車載用カメラは、撮像系71、画像処理回路72、重畳回路73、符号データRAM74、復号化回路75、及び出力制御部76を備えている。   FIG. 7 is a functional block diagram of a vehicle-mounted camera to which the run-length decoding device shown in FIG. 5 is applied. The in-vehicle camera shown in FIG. 7 includes an imaging system 71, an image processing circuit 72, a superimposing circuit 73, a code data RAM 74, a decoding circuit 75, and an output control unit 76.

撮像系71、画像処理回路72、及び出力制御部76は、図6のものと同じである。符号データRAM74は、図1に示すランレングス符号化装置により予め生成されたランレングスデータを保持する。復号化回路75は、図5に示すランレングス復号化装置により構成されている。重畳回路73は、画像処理回路72から出力される撮像画像データと、復号化回路75から出力されるOSD表示パターンとを重畳し、重畳結果を出力する。   The imaging system 71, the image processing circuit 72, and the output control unit 76 are the same as those in FIG. The code data RAM 74 holds run length data generated in advance by the run length encoding apparatus shown in FIG. The decoding circuit 75 is composed of a run-length decoding device shown in FIG. The superimposing circuit 73 superimposes the captured image data output from the image processing circuit 72 and the OSD display pattern output from the decoding circuit 75, and outputs a superimposition result.

この構成によれば、OSD表示パターンの復号化が、車載用カメラ内部において、表示時にリアルタイムで行われる。そのため、比較例の車載用カメラのように描画回路631及びOSD表示パターン専用のフレームバッファ64が不要となり、装置構成を簡略化し、コストダウンを図ることができる。   According to this configuration, the decoding of the OSD display pattern is performed in real time at the time of display inside the vehicle-mounted camera. This eliminates the need for the drawing circuit 631 and the frame buffer 64 dedicated to the OSD display pattern as in the in-vehicle camera of the comparative example, thereby simplifying the device configuration and reducing the cost.

また、符号データRAM74が保持するランレングス符号化されたOSD表示パターンは、車載用カメラの外部で生成されるため、符号化アルゴリズムが複雑化してもコストに対する影響は少ない。また、ランレングスデータの復号化は比較的簡素な処理で実現できるため、表示時においてリアルタイムの復号化が可能となり、車載用カメラにとって好適である。   In addition, since the run-length encoded OSD display pattern held in the code data RAM 74 is generated outside the vehicle-mounted camera, even if the encoding algorithm is complicated, there is little influence on the cost. Moreover, since decoding of run-length data can be realized by a relatively simple process, real-time decoding is possible at the time of display, which is suitable for a vehicle-mounted camera.

図8は、図5に示すランレングス復号化装置が適用された車載用カメラのハードウェア構成を示すブロック図である。   FIG. 8 is a block diagram showing a hardware configuration of a vehicle-mounted camera to which the run-length decoding device shown in FIG. 5 is applied.

図8に示す車載用カメラは、撮像系81、画像処理回路82、OSD表示制御部83、出力制御部84、CPU85、RAM86、ROM87、及びI/O88を備えている。撮像系81〜I/O88はそれぞれ、バスライン89を介して相互に接続されている。   The in-vehicle camera shown in FIG. 8 includes an imaging system 81, an image processing circuit 82, an OSD display control unit 83, an output control unit 84, a CPU 85, a RAM 86, a ROM 87, and an I / O 88. The imaging systems 81 to I / O 88 are connected to each other via a bus line 89.

撮像系81及び画像処理回路82は、それぞれ図7の撮像系71及び画像処理回路72を構成する。OSD表示制御部83は、図7に示す復号化回路75、符号データRAM74、及び重畳回路73を構成する。出力制御部84は図7に示す出力制御部76を構成する。CPU85は、車載用カメラの全体制御を司る。RAM86は、CPU85のワーキングメモリとして使用される。ROM87は予め作成されたランレングスデータを保持している。I/O88は、例えばECUとの間で各種の制御信号を入出力する。出力制御部84は、OSD表示パターンと撮像画像データとを重畳した画像データをデジタルの画像信号として外部に出力する、或いは、NTSC信号に変換して外部に出力する。   The imaging system 81 and the image processing circuit 82 constitute the imaging system 71 and the image processing circuit 72 of FIG. 7, respectively. The OSD display control unit 83 constitutes the decoding circuit 75, the code data RAM 74, and the superimposing circuit 73 shown in FIG. The output control unit 84 constitutes the output control unit 76 shown in FIG. The CPU 85 governs overall control of the in-vehicle camera. The RAM 86 is used as a working memory for the CPU 85. The ROM 87 holds run length data created in advance. The I / O 88 inputs and outputs various control signals with the ECU, for example. The output control unit 84 outputs image data obtained by superimposing the OSD display pattern and the captured image data to the outside as a digital image signal, or converts the image data to an NTSC signal and outputs it to the outside.

図9は、図8に示す車載用カメラにおいて、6種類のOSD表示パターンを撮像画像データに重畳して出力する場合のOSD表示制御部83の機能ブロック図である。   FIG. 9 is a functional block diagram of the OSD display control unit 83 when the six types of OSD display patterns are superimposed on the captured image data and output in the in-vehicle camera shown in FIG.

図9に示すOSD表示制御部は、6種類のOSD表示パターンを表示時にリアルタイムに復号化して出力するものである。このOSD表示制御部は、図7に示す符号データRAM74、復号化回路75、及び重畳回路73からなる復号化ユニットが6段設けられている。   The OSD display control unit shown in FIG. 9 decodes and outputs six types of OSD display patterns in real time during display. The OSD display control unit is provided with six stages of decoding units including a code data RAM 74, a decoding circuit 75, and a superimposing circuit 73 shown in FIG.

1段目の重畳回路73には、図7に示す撮像系71が画像処理回路72を介して接続され、撮像系71により撮像された撮像画像データが入力される。   An imaging system 71 shown in FIG. 7 is connected to the first stage superimposing circuit 73 via an image processing circuit 72, and captured image data captured by the imaging system 71 is input.

1段目〜6段目の符号データRAM74は、それぞれ、それぞれ、6種類のOSD表示パターンである第1〜第6のOSD表示パターンをランレングス符号化することで予め得られたランレングスデータを保持している。そして、1段目〜6段目の符号データRAM74は、CPU85からの復号化開始の制御信号を受け付けると、保持するランレングスデータを復号化回路75に出力し、復号化回路75に復号化処理を実行させる。   The code data RAM 74 in the first to sixth stages respectively stores run-length data obtained in advance by run-length encoding the first to sixth OSD display patterns, which are six types of OSD display patterns. keeping. When receiving the decoding start control signal from the CPU 85, the first to sixth stage code data RAM 74 outputs the run-length data to be held to the decoding circuit 75, and the decoding circuit 75 performs the decoding process. Is executed.

復号化回路75は、ランレングスデータを復号化して重畳回路73に出力する。1段目の重畳回路73は1段目の復号化回路75から出力された第1のOSD表示パターンと撮像画像データを重畳して2段目の重畳回路73に出力する。2段目〜5段目の重畳回路73は、それぞれ、上段の重畳回路73から出力された画像データに第2〜第5のOSD表示パターンを重畳し、下段の重畳回路73に出力する。   The decoding circuit 75 decodes the run length data and outputs it to the superimposing circuit 73. The first stage superimposing circuit 73 superimposes the first OSD display pattern output from the first stage decoding circuit 75 and the captured image data, and outputs the result to the second stage superimposing circuit 73. The second to fifth superimposing circuits 73 superimpose the second to fifth OSD display patterns on the image data output from the upper superimposing circuit 73 and output the image data to the lower superimposing circuit 73.

6段目の重畳回路73は、5段目の重畳回路73から出力された画像データに第6のOSD表示パターンを重畳し、出力制御部76に出力する。これにより撮像画像データに第1〜第6のOSD表示パターンが重畳された画像データが出力制御部76に出力される。   The sixth stage superimposing circuit 73 superimposes the sixth OSD display pattern on the image data output from the fifth stage superimposing circuit 73 and outputs the image data to the output control unit 76. As a result, the image data in which the first to sixth OSD display patterns are superimposed on the captured image data is output to the output control unit 76.

図10は、ランレングス符号化装置が車載用カメラにランレングスデータを書き込む際の処理を示したブロック図である。   FIG. 10 is a block diagram showing processing when the run-length encoding apparatus writes run-length data to the vehicle-mounted camera.

コンピュータ101は、図1に示すランレングス符号化装置の機能を実現する。まず、コンピュータ101はグラフィック作成ツールを起動し、デザイナーからの操作指示にしたがって、OSD表示パターンを生成する(工程1)。   The computer 101 implements the function of the run length encoding device shown in FIG. First, the computer 101 activates a graphic creation tool and generates an OSD display pattern in accordance with an operation instruction from a designer (step 1).

次に、コンピュータ101は、生成したOSD表示パターンをランレングス符号化し、ランレングスデータを生成する(工程2)。次に、コンピュータ101は、生成したランレングスデータを車載用カメラ102のROMに書き込む(工程3)。これにより、車載用カメラ102はランレングスデータを得る。このとき、コンピュータ101は、ランレングスデータを復号化するために必要となる色コードテーブル及びベース値テーブルもROM87に書き込む。   Next, the computer 101 performs run-length encoding on the generated OSD display pattern to generate run-length data (step 2). Next, the computer 101 writes the generated run length data in the ROM of the in-vehicle camera 102 (step 3). Thereby, the vehicle-mounted camera 102 obtains run length data. At this time, the computer 101 also writes a color code table and a base value table necessary for decoding the run-length data in the ROM 87.

なお、コンピュータ101は、例えば車載用カメラ102が備えるI/O88とケーブルを介して接続され、ランレングスデータ等を車載用カメラ102に出力する。   The computer 101 is connected to, for example, an I / O 88 included in the vehicle-mounted camera 102 via a cable, and outputs run-length data or the like to the vehicle-mounted camera 102.

次に、OSD表示制御部83がROM87からランレングス符号化データを読み出し(工程4)、復号化してOSD表示パターンを生成し、出力制御部84を介して外部に出力する。   Next, the OSD display control unit 83 reads run-length encoded data from the ROM 87 (step 4), decodes it to generate an OSD display pattern, and outputs it to the outside via the output control unit 84.

(実施例2)
次に、実施例1の車載用カメラで使用されるOSD表示パターンを図1に示すランレングス符号化装置を用いてランレングス符号化する実施例2について説明する。
(Example 2)
Next, a second embodiment in which the OSD display pattern used in the vehicle-mounted camera of the first embodiment is run-length encoded using the run-length encoding device shown in FIG.

図10に示す車載用カメラ102の仕様は下記の通りである。   The specifications of the in-vehicle camera 102 shown in FIG. 10 are as follows.

OSD表示パターンの重畳数:6個
同時表示可能色数:8色/面
色コードのビット数:3bit
符号データRAM74:色コードが3bitなので、3bit/wordのRAMを使用する。回路を簡単にするため各ランの長さ部は3bitの倍数とする。
Number of superimposed OSD display patterns: 6 Number of simultaneously displayable colors: 8 colors / surface Number of color code bits: 3 bits
Code data RAM 74: Since the color code is 3 bits, a RAM of 3 bits / word is used. In order to simplify the circuit, the length of each run is a multiple of 3 bits.

符号データRAM74のサイズ:2049bit/面(3bit/word×683word)
表示色:RGB24bit→各面の各色コードに対応した色情報テーブルを設け、3bitの色コードをRGB24bitの画素データに変換する。
Code data RAM 74 size: 2049 bits / plane (3 bits / word × 683 words)
Display color: RGB 24-bit → Color information table corresponding to each color code on each surface is provided, and a 3-bit color code is converted into RGB 24-bit pixel data.

透過表示制御:0(透過率0)〜1(透過率100%)を1/16ステップの17段階で指定する。   Transmission display control: 0 (transmittance 0) to 1 (transmittance 100%) is designated in 17 steps of 1/16 steps.

出力される画像データ:360×480pixel,24bit/pixel
このように、符号データRAM74のサイズが2KBに限定されているため、各OSD表示パターンは2KB以下のサイズに符号化しなければならず、符号化効率のよい符号化アルゴリズムが必要となる。
Output image data: 360 × 480 pixels, 24 bits / pixel
Thus, since the size of the code data RAM 74 is limited to 2 KB, each OSD display pattern must be encoded to a size of 2 KB or less, and an encoding algorithm with high encoding efficiency is required.

<ランレングス符号化>
図11(A)は、図1に示すランレングス符号化装置が行うランレングス符号化処理を示したフローチャートである。図17は、実施例2でランレングス符号化の対象となるOSD表示パターンを示した図である。
<Run-length encoding>
FIG. 11A is a flowchart showing a run-length encoding process performed by the run-length encoding apparatus shown in FIG. FIG. 17 is a diagram illustrating an OSD display pattern that is a target of run-length encoding in the second embodiment.

このOSD表示パターンは、360×480の画素から構成され、3つの色コードを持っている。画面中央に示す傾斜した波線からなるグラフィックには色コード5が付与されている。OSD表示パターンの外周を覆う外枠のグラフィックには色コード6が付与されている。OSD表示パターンの傾斜した波線からなるグラフィックの背景のグラフィックには色コード0が付与されている。   This OSD display pattern is composed of 360 × 480 pixels and has three color codes. A color code 5 is given to the graphic composed of the inclined wavy lines shown in the center of the screen. A color code 6 is assigned to the graphic of the outer frame covering the outer periphery of the OSD display pattern. A color code 0 is assigned to the graphic of the background of the graphic composed of the inclined wavy lines of the OSD display pattern.

まず、色コード割当部13は、色コード分割処理を行う(S1)。次に、符号化部14は、ベース値算出処理を行う(S2)。次に、符号化部14は、ランレングス符号化を行い、ランレングスデータを生成する(S3)。   First, the color code assigning unit 13 performs color code division processing (S1). Next, the encoding unit 14 performs base value calculation processing (S2). Next, the encoding unit 14 performs run-length encoding to generate run-length data (S3).

<色コード分割処理>
図12は、図11(A)の色コード分割処理のサブルーチンを示すフローチャートである。まず、色コード割当部13は、初期化を行う。このとき、色コード割当部13は、初期の色コードテーブルを生成する(S11)。
<Color code division processing>
FIG. 12 is a flowchart showing a subroutine of color code division processing in FIG. First, the color code assigning unit 13 performs initialization. At this time, the color code assigning unit 13 generates an initial color code table (S11).

図19は、初期の色コードテーブルである。色コードテーブルは、色コードのフィールドと長さ部ビット数のフィールドとを備えている。色コードテーブルのフィールドには0(A)〜7(H)の8色の色コードが格納されている。長さ部ビット数のフィールドには、各色コードにおいて、長さ部のビット数毎に割り当てられた色コードが示されている。   FIG. 19 is an initial color code table. The color code table includes a color code field and a length bit number field. The color code table field stores eight color codes of 0 (A) to 7 (H). In the length part bit number field, a color code assigned to each length part bit number is shown in each color code.

図19の例では、長さ部ビット数は、0ビット、3ビット、6ビットというように3ビット毎区切られている。これは、符号データRAMを3bit/wordとしたためである。   In the example of FIG. 19, the number of bits in the length part is divided every 3 bits, such as 0 bits, 3 bits, and 6 bits. This is because the code data RAM is set to 3 bits / word.

図19は初期の色コードテーブルであるため、色コード0〜7のそれぞれに対して、長さ部ビット数にかかわらず、色コード0〜7が割り当てられている。   Since FIG. 19 is an initial color code table, the color codes 0 to 7 are assigned to the color codes 0 to 7 regardless of the number of bits in the length part.

また、S11において、色コード割当部13は、図20に示す符号長テーブルを生成する。図20は、初期の符号長テーブルである。符号長テーブルは、色コードテーブルと同様のデータ構造を持っている。そして、この符号長テーブルは、各色コードにつき、長さ部のビット数を変えたときのランレングスデータの符号長を示している。   In S11, the color code assigning unit 13 generates a code length table shown in FIG. FIG. 20 is an initial code length table. The code length table has the same data structure as the color code table. This code length table shows the code length of run-length data when the number of bits in the length portion is changed for each color code.

例えば、1行1列目のセルにはdda90が格納されている。これは、色コード0につき、長さ部のビット数を0ビットにしたとき、色コード0のグラフィックのランレングスデータの符号長がdda90ビットであったからである。   For example, dda90 is stored in the cell in the first row and the first column. This is because the code length of the run length data of the color code 0 graphic is dda90 bits when the number of bits of the length portion is set to 0 bit for the color code 0.

図20に示すように、色コード0については、長さ部のビット数を9ビットにしたとき、符号長が1ef0となり最小となる。そのため、色コード割当部13は、色コード0の長さ部のビット数を9に設定する。   As shown in FIG. 20, for the color code 0, when the number of bits in the length part is 9 bits, the code length is 1ef0, which is the minimum. Therefore, the color code assigning unit 13 sets the number of bits of the length part of the color code 0 to 9.

同様に色コード5,6については、それぞれ、長さ部のビット数を6ビットに設定したとき、符号長が最小となる。よって、色コード割当部13は、色コード5,6の長さ部のビット数をそれぞれ6に設定する。   Similarly, for the color codes 5 and 6, when the number of bits in the length portion is set to 6 bits, the code length is minimized. Therefore, the color code assigning unit 13 sets the number of bits of the length part of the color codes 5 and 6 to 6, respectively.

なお、色コード0,5,6のそれぞれにつき、長さ部のビット数を9,6,6に設定したときのランレングスデータのトータルの符号長は、1ef0+06e4+14c7=449b=17,563bitとなる。   For each of the color codes 0, 5, and 6, the total code length of the run-length data when the number of bits in the length part is set to 9, 6, and 6 is 1ef0 + 06e4 + 14c7 = 449b = 17,563 bits.

図12に戻り、色コード割当部13は、ヒストグラムを作成する(S12)。図18は、初期のヒストグラムである。ヒストグラムは、色コードテーブルと同様のデータ構造を持っている。なお、ヒストグラムの各セルに格納された数値は16進数である。   Returning to FIG. 12, the color code assigning unit 13 creates a histogram (S12). FIG. 18 is an initial histogram. The histogram has a data structure similar to that of the color code table. The numerical value stored in each cell of the histogram is a hexadecimal number.

図17のOSD表示パターンでは、色コード0のグラフィックにおいて、長さ部のビット数が0ビットより大きく3ビット以下で表すことのできるランの個数が6個であったため、1行2列目のセルには6が格納されている。また、色コード0のグラフィックにおいて、長さ部のビット数が3ビットより大きく6ビット以下で表すことができるランの個数が48個であったため、1行4列目のセルには48が格納されている。   In the OSD display pattern of FIG. 17, in the color code 0 graphic, the number of runs that can be represented by the number of bits of the length portion greater than 0 bits and 3 bits or less is 6, so that the first row and second column 6 is stored in the cell. Also, in the graphic of color code 0, the number of bits that can be represented by the number of bits of the length portion greater than 3 bits and 6 bits or less was 48, so 48 is stored in the cell in the first row and the fourth column. Has been.

また、図17に示すOSD表示パターンは、色コード0のグラフィックの他に、色コード5のグラフィックと色コード6のグラフィックとが存在するため、色コード5、6の該当するセルに数値が格納されている。色コード0,5,6以外の色コードのセルには、数値は格納されていない。   In addition, since the OSD display pattern shown in FIG. 17 includes a color code 5 graphic and a color code 6 graphic in addition to the color code 0 graphic, numerical values are stored in the corresponding cells of the color code 5 and 6. Has been. Numeric values are not stored in cells of color codes other than color codes 0, 5, and 6.

図12に戻り、色コード割当部13は、未使用の色コードが存在するか否かを判定する(S13)。未使用の色コードが存在する場合(S13でYES)、色コード割当部13は、色コード分割位置を算出する(S14)。図18に示す初期のヒストグラムには、色コード0,5,6以外の色コードのセルには数値が格納されていないため、色コード割当部13は、未使用の色コードが存在すると判定する。   Returning to FIG. 12, the color code assigning unit 13 determines whether there is an unused color code (S13). When there is an unused color code (YES in S13), the color code assignment unit 13 calculates a color code division position (S14). In the initial histogram shown in FIG. 18, since no numerical value is stored in cells of color codes other than color codes 0, 5, and 6, the color code allocation unit 13 determines that an unused color code exists. .

一方、未使用の色コードが存在しない場合(S13でNO)、処理をリターンさせる。この場合、ヒストグラムにおいて、初期状態で色コードが割り当てられていなかった色コードのいずれかのセルにおいて、数値が格納されていれば、未使用の色コードはないと判定される。   On the other hand, if there is no unused color code (NO in S13), the process is returned. In this case, if a numerical value is stored in any cell of the color code to which no color code is assigned in the initial state in the histogram, it is determined that there is no unused color code.

<S14>色コード分割位置算出処理
以下、S14の色コード分割位置算出処理について詳細に説明する。まず、色コード割当部13は、各色コードにつき、長さ部のビット数の分割位置を変えながら、現在の長さ部のビット数に対してどれだけ符号長を削減させることができるかを示す符号長削減量テーブルを算出する。そして、符号長削減量テーブルに基づいて、削減量を最大化することができる色コードの分割位置を算出する。図21は、符号長削減量テーブルである。なお、符号長削減量テーブルは、色コードテーブルと同様のデータ構造を持っている。
<S14> Color Code Division Position Calculation Processing Hereinafter, the color code division position calculation processing in S14 will be described in detail. First, the color code allocating unit 13 shows how much the code length can be reduced with respect to the number of bits of the current length part while changing the division position of the number of bits of the length part for each color code. A code length reduction amount table is calculated. Then, based on the code length reduction amount table, a color code division position capable of maximizing the reduction amount is calculated. FIG. 21 is a code length reduction amount table. The code length reduction amount table has the same data structure as the color code table.

色コード割当部13は、現在、色コード0,5,6につき、長さ部のビット数を9,6,6に設定している。そのため、図21に示す符号長削減量テーブルは、この場合と比較したときの符号長の削減量を示している。   The color code assigning unit 13 currently sets the number of bits of the length part to 9, 6, 6 for the color codes 0, 5, 6. Therefore, the code length reduction amount table shown in FIG. 21 indicates the code length reduction amount when compared with this case.

色コード0において、分割位置を3ビットとすると、削減量は36ビットとなる。ここで、分割位置が3ビットとは、色コード0において、長さ部のビット数が3ビット以下のランは長さ部のビット数を3ビットとしてランレングス符号化を行い、長さ部のビット数が3ビットより大きいランは、分割前の長さ部のビット数(色コード0の場合は9ビット)でランレングス符号化を行った場合を示している。   In color code 0, if the division position is 3 bits, the reduction amount is 36 bits. Here, the division position is 3 bits. In the color code 0, a run whose length part has 3 bits or less is run-length encoded with the length part having 3 bits, and the length part has 3 bits. A run with the number of bits larger than 3 bits indicates a case where run-length encoding is performed with the number of bits in the length part before division (9 bits in the case of color code 0).

同様に、色コード0において、分割位置を6ビットにすると、削減量は234ビットとなる。このことから、色コード0については、分割位置を6ビットすると、削減量を最大にすることができる。色コード5,6についても色コード0と同様に長さ部のビット数を変えながら削減量を求める。その結果、色コード5については、分割位置を3ビット、色コード6については分割位置を6ビット又は9ビットにすると削減量を最大にすることができる。   Similarly, in color code 0, if the division position is 6 bits, the reduction amount is 234 bits. Therefore, for the color code 0, the reduction amount can be maximized if the division position is 6 bits. For the color codes 5 and 6, the reduction amount is obtained while changing the number of bits in the length portion as in the case of the color code 0. As a result, the reduction amount can be maximized by setting the division position for the color code 5 to 3 bits and the division position for the color code 6 to 6 bits or 9 bits.

そして、色コード割当部13は、図21に示す符号長削減量テーブルにおいて、全色コードのうち、削減量が最大の色コードを分割対象の色コードとして決定する。この場合、色コード6の6又は9ビットの削減量が1122ビットであるため、色コード6が分割対象の色コードとして決定される。   Then, the color code assigning unit 13 determines the color code having the largest reduction amount as the color code to be divided among all the color codes in the code length reduction amount table shown in FIG. In this case, since the 6 or 9-bit reduction amount of the color code 6 is 1122 bits, the color code 6 is determined as the color code to be divided.

そして、色コード割当部13は、色コード6において、削減量が最大である6ビット、又は9ビットを分割位置として決定する。なお、色コード6では、分割位置を6ビット、9ビットとしても削減量は同じである。このような場合、色コード割当部13は、小さい方の6ビットを分割位置とするが、これに限定されず、大きい方の9ビットを分割位置にしてもよい。   Then, the color code assigning unit 13 determines 6 bits or 9 bits with the maximum reduction amount as the division position in the color code 6. In the color code 6, the reduction amount is the same even if the division position is 6 bits and 9 bits. In such a case, the color code allocating unit 13 uses the smaller 6 bits as the dividing position, but is not limited thereto, and the larger 9 bits may be used as the dividing position.

<S15>ヒストグラム分割処理
図12に戻り、S15において、色コード割当部13は、色コード6の分割位置を6ビットとしたため、色コード6において、ランレングスが6ビットより大きなランを抽出し、未使用の色コードに割り当てる。この場合、色コード割当部13は、例えば、未使用の色コードのうち、番号が最も若い色コードに抽出したランを割り当てればよい。この場合、未使用の色コードのうち、番号が最も若い色コードは色コード1であるため、色コード6において、ランレングスが6ビットより大きなランは色コード1が割り当てられる。
<S15> Histogram Division Processing Returning to FIG. 12, in S15, the color code allocation unit 13 sets the division position of the color code 6 to 6 bits, and therefore extracts a run having a run length larger than 6 bits in the color code 6. Assign to an unused color code. In this case, for example, the color code assigning unit 13 may assign the extracted run to the color code with the smallest number among the unused color codes. In this case, since the color code with the smallest number among the unused color codes is the color code 1, in the color code 6, a run having a run length larger than 6 bits is assigned the color code 1.

次に、色コード割当部13は、抽出したランに対して新たに色コードを割り当てたことを反映させるため、図18に示す初期のヒストグラムを更新する。図22は、初期のヒストグラムを更新することで得られたヒストグラムである。   Next, the color code assigning unit 13 updates the initial histogram shown in FIG. 18 to reflect that a new color code has been assigned to the extracted run. FIG. 22 is a histogram obtained by updating the initial histogram.

図22に示すように、色コード6において長さ部のビット数が9〜21ビットの各セルに格納された数値が色コード1の長さ部のビット数が9〜21ビットの各セルに移動され、かつ、色コード6において長さ部のビット数が9〜12ビットの各セルに格納された数値が0に更新されている。   As shown in FIG. 22, the numerical value stored in each cell having a length portion of 9-21 bits in the color code 6 is assigned to each cell having a length portion of 9-21 bits in the color code 1. The numeric value stored in each cell in which the number of bits in the length portion is 9 to 12 bits in the color code 6 is updated to 0.

<S16>色コードテーブル更新処理
図12に戻り、S16において、色コード割当部13は、図19に示す初期の色コードテーブルを更新する。図23は、図19に示す初期の色コードテーブルを更新することで得られた色コードテーブルである。
<S16> Color Code Table Update Processing Returning to FIG. 12, in S16, the color code assignment unit 13 updates the initial color code table shown in FIG. FIG. 23 is a color code table obtained by updating the initial color code table shown in FIG.

図23に示すように、色コード6において、長さ部のビット数が9〜12ビットの各セルに格納された数値が6から1に更新されている。これにより、色コード6においてランレングスが6ビットよりも大きいランに対して、色コード1を付与しても、これらのランは、元々は色コード6であったことが分かる。   As shown in FIG. 23, in the color code 6, the numerical value stored in each cell having the length portion of 9 to 12 bits is updated from 6 to 1. As a result, even if color code 1 is assigned to a run having a run length larger than 6 bits in color code 6, it can be seen that these runs were originally color code 6.

次に、色コード割当部13は、図20に示す初期の符号長テーブルを生成したときと同様にして、各色コードについての符号長テーブルを生成し、各色コードについて、符号長を最小にする長さ部のビット数を求め、各色コードの長さ部の現在のビット数として設定する。   Next, the color code allocation unit 13 generates a code length table for each color code in the same manner as when the initial code length table shown in FIG. 20 is generated, and the length that minimizes the code length for each color code. The number of bits in the length part is obtained and set as the current number of bits in the length part of each color code.

以後、色コード割当部13は、未使用の色コードが残っている間、S13〜S16の処理を繰り返す。すると、最終的に、図24に示すヒストグラム、図25に示す色コードテーブルが得られた。図24は、色コード分割処理によって最終的に得られたヒストグラムである。図25は、色コード分割処理によって最終的に得られた色コードテーブルである。   Thereafter, the color code assigning unit 13 repeats the processes of S13 to S16 while an unused color code remains. Finally, the histogram shown in FIG. 24 and the color code table shown in FIG. 25 were obtained. FIG. 24 is a histogram finally obtained by the color code dividing process. FIG. 25 is a color code table finally obtained by the color code dividing process.

図24に示すヒストグラムにおいて、色コード1〜色コード7はそれぞれ、いずれかのセルに数値が格納されており、ランが割り当てられていることが分かる。なお、色コード0において、いずれのセルも0になっているのは、S13〜S16の最後のループにおいて、色コード0の3ビットのセルの値が未使用の色コード7に移動されたからである。   In the histogram shown in FIG. 24, it can be seen that each of the color code 1 to the color code 7 stores a numerical value in one of the cells, and is assigned a run. In addition, in the color code 0, all the cells are 0 because the value of the 3-bit cell of the color code 0 was moved to the unused color code 7 in the last loop of S13 to S16. is there.

図24に示すヒストグラムでは、色コード1〜7につき、ランレングスが似たような長さを持つランが割り当てられていることが分かる。したがって、各色コードの長さ部は、無駄なくランレングスを格納することができる。   In the histogram shown in FIG. 24, it can be seen that runs having similar run lengths are assigned to the color codes 1 to 7. Therefore, the length portion of each color code can store the run length without waste.

また、図25に示すように、例えば、色コード0は、3ビットのセルに色コード7が格納されている。そのため、ランレングスデータにおいて、色コードが7で長さ部のビット数が3ビットのランは、元々の色コードが0であったことが分かる。   As shown in FIG. 25, for example, the color code 0 is stored in a 3-bit cell. Therefore, in the run-length data, it can be seen that the original color code is 0 in a run in which the color code is 7 and the number of bits of the length part is 3 bits.

図26は、色コード分割処理によって最終的に得られた符号長テーブルである。色コード0〜7につき、それぞれ、網掛けで示すセルに対応するビット数で長さ部のビット数を設定すると符号長を最小化することができる。   FIG. 26 is a code length table finally obtained by the color code dividing process. For each of the color codes 0 to 7, the code length can be minimized by setting the number of bits of the length portion by the number of bits corresponding to the shaded cells.

図17に示すOSD表示パターンの符号長は、色コード分割処理後により、001e+1b48+0426+0288+01d4+1047+0024=3453=13,395bitとなる。   The code length of the OSD display pattern shown in FIG. 17 is 001e + 1b48 + 0426 + 0288 + 01d4 + 1047 + 0024 = 3453 = 13,395 bits after color code division processing.

<ベース値処理>
次に、ベース値処理について説明する。図11(B)はベース値処理のフローチャートである。まず、ベース値算出部141は、ベース値算出処理を行う(S21)。次に、ベース値算出部141は、長さ部ビット数算出処理を行う(S22)。
<Base value processing>
Next, the base value process will be described. FIG. 11B is a flowchart of the base value process. First, the base value calculation unit 141 performs a base value calculation process (S21). Next, the base value calculation unit 141 performs a length part bit number calculation process (S22).

<ベース値算出処理>
図13は、図11に示すベース値算出処理のサブルーチンを示すフローチャートである。まず、ベース値算出部141は、各種パラメータを初期化する(S31)。
<Base value calculation processing>
FIG. 13 is a flowchart showing a subroutine of the base value calculation process shown in FIG. First, the base value calculation unit 141 initializes various parameters (S31).

次に、ベース値算出部141は、処理対象となるOSD表示パターンの最後のランの抽出が終了したか否かを判定し、終了した場合(S32でYES)、処理をリターンする。一方、最後のランの抽出が終了していない場合(S32でNO)、ベース値算出部141はラン抽出処理を行う(S33)。   Next, the base value calculation unit 141 determines whether or not the extraction of the last run of the OSD display pattern to be processed has ended, and if it has ended (YES in S32), returns the processing. On the other hand, when the extraction of the last run has not ended (NO in S32), the base value calculation unit 141 performs a run extraction process (S33).

<ラン抽出処理>
図15は、図13、図14、図16で示すラン抽出処理のサブルーチンを示すフローチャートである。まず、ランレングス変数に0が代入されて初期化され、色コード変数に注目画素の画素値が代入されて色コード変数が初期化される(S51)。ここで、注目画素は、OSD表示パターンにおいてラスタ走査順に決定される。
<Run extraction process>
FIG. 15 is a flowchart showing a subroutine of the run extraction process shown in FIGS. 13, 14, and 16. First, 0 is assigned to the run length variable and initialized, and the pixel value of the target pixel is assigned to the color code variable to initialize the color code variable (S51). Here, the target pixel is determined in the raster scan order in the OSD display pattern.

次に、ランレングス変数が1加算され、ランレングス変数が更新される(S52)。次に、注目画素の画素位置が更新される(S53)。次に、注目画素の画素値が色コード変数と同じ値であれば(S54でYES)、処理がS52に戻される。一方、注目画素の画素値が色コード変数と異なる値であれば、1つのランが抽出できたと判定され、処理がリターンされる。つまり、OSD表示パターンに対して、注目画素が順次ずらされ、注目画素の画素値が前の注目画素の画素値と異なる値になったとき、1つのランが抽出できたと判定する。そして、注目画素をずらす都度、1加算されたランレングス変数の値が抽出したランのランレングスとなる。   Next, 1 is added to the run length variable, and the run length variable is updated (S52). Next, the pixel position of the target pixel is updated (S53). Next, if the pixel value of the target pixel is the same value as the color code variable (YES in S54), the process returns to S52. On the other hand, if the pixel value of the target pixel is different from the color code variable, it is determined that one run has been extracted, and the process is returned. That is, when the target pixel is sequentially shifted with respect to the OSD display pattern and the pixel value of the target pixel becomes different from the pixel value of the previous target pixel, it is determined that one run has been extracted. Each time the pixel of interest is shifted, the value of the run length variable added by 1 becomes the run length of the extracted run.

図13に戻り、S34において、ベース値算出部141は、図25に示す色コードテーブルを参照し、S33で抽出したランの色コード分割処理後の色コードを算出する。例えば、色コードが0、ランレングスが3ビットより大きく6ビット以下で表すことができるランが抽出された場合、このランの色コードは4と算出される。   Returning to FIG. 13, in S34, the base value calculation unit 141 refers to the color code table shown in FIG. 25, and calculates the color code after the color code division processing of the run extracted in S33. For example, when a run that can be represented by a color code of 0 and a run length of greater than 3 bits and less than 6 bits is extracted, the color code of this run is calculated as 4.

次に、ベース値算出部141は、S33で抽出したランのランレングスが対応する色コードの現在のベース値未満である場合(S35でYES)、現在のベース値を抽出したランのランレングスで更新し(S36)、処理をS32に戻す。   Next, when the run length of the run extracted in S33 is less than the current base value of the corresponding color code (YES in S35), the base value calculation unit 141 uses the run length of the run from which the current base value is extracted. Update (S36), and return the process to S32.

一方、S33で抽出したランのランレングスが対応する色コードの現在のベース値以上である場合(S35でNO)、現在のベース値を更新せず、処理をS32に戻す。   On the other hand, if the run length of the run extracted in S33 is greater than or equal to the current base value of the corresponding color code (NO in S35), the current base value is not updated, and the process returns to S32.

例えば、S34で色コード7と算出されたランのランレングスが色コード7の現在のベース値未満である場合、S35でYESと判定され、色コード7の現在のベース値がこのランレングスで更新される。このような処理が各色コードに対して行われ、各色コードにつき、ランレングスの最小値がベース値として算出される。   For example, if the run length of the run calculated as color code 7 in S34 is less than the current base value of color code 7, it is determined YES in S35, and the current base value of color code 7 is updated with this run length. Is done. Such processing is performed on each color code, and the minimum run length is calculated as the base value for each color code.

<長さ部ビット数算出処理>
次に、図11(B)のS22の長さ部ビット数算出処理について説明する。図16は、図11(B)に示す長さ部ビット数算出処理のサブルーチンを示すフローチャートである。まず、差分ランレングス算出部142は、各種パラメータを初期化する(S61)。次に、差分ランレングス算出部142は、処理対象となるOSD表示パターンの最後のランの抽出が終了したか否かを判定し、終了した場合(S62でYES)、処理をS68に進める。一方、最後のランの抽出が終了していない場合(S62でNO)、差分ランレングス算出部142はラン抽出処理を行う(S63)。このラン抽出処理は、図15で示した処理と同じである。
<Length part bit number calculation processing>
Next, the length part bit number calculation processing in S22 of FIG. 11B will be described. FIG. 16 is a flowchart showing a subroutine of length part bit number calculation processing shown in FIG. First, the differential run length calculation unit 142 initializes various parameters (S61). Next, the differential run length calculation unit 142 determines whether or not the extraction of the last run of the OSD display pattern to be processed has ended, and if it has ended (YES in S62), the process proceeds to S68. On the other hand, if the last run has not been extracted (NO in S62), the differential run length calculation unit 142 performs a run extraction process (S63). This run extraction process is the same as the process shown in FIG.

次に、差分ランレングス算出部142は、S63で抽出したランの色コードを算出する(S64)。この処理は図13のS34と同じである。   Next, the difference run length calculation unit 142 calculates the color code of the run extracted in S63 (S64). This process is the same as S34 in FIG.

次に、差分ランレングス算出部142は、S63で抽出したランレングスから対応する色コードのベース値を差し引き、差分ランレングスを算出する(S65)。例えば、S63で抽出されたランにおいて、S64で算出された色コードが色コード7であった場合、色コード7のベース値を用いて差分ランレングスが算出される。   Next, the difference run length calculation unit 142 calculates a difference run length by subtracting the base value of the corresponding color code from the run length extracted in S63 (S65). For example, in the run extracted in S63, when the color code calculated in S64 is the color code 7, the difference run length is calculated using the base value of the color code 7.

次に、差分ランレングス符号化部143は、S65で求められた差分ランレングスが対応する色コードの最大差分ランレングスより大きい場合(S66でYES)、対応する色コードの最大差分ランレングスをS65で算出された差分ランレングスで更新し(S67)、処理をS62に戻す。   Next, if the difference run length obtained in S65 is larger than the maximum difference run length of the corresponding color code (YES in S66), the difference run length encoding unit 143 sets the maximum difference run length of the corresponding color code to S65. (S67) and the process returns to S62.

一方、S65で求められた差分ランレングスが対応する色コードの最大差分ランレングス以下の場合(S66でNO)、最大差分ランレングスが更新されずに処理がS62に戻される。   On the other hand, if the difference run length obtained in S65 is less than or equal to the maximum difference run length of the corresponding color code (NO in S66), the process returns to S62 without updating the maximum difference run length.

S68において、差分ランレングス符号化部143は、各色コードにつき、最大差分ランレングスを表すことができる最小のビット数を長さ部のビット数として算出し、処理をリターンする。   In S68, the difference run length encoding unit 143 calculates, for each color code, the minimum number of bits that can represent the maximum difference run length as the number of bits of the length part, and returns the process.

<ランレングス符号化処理>
次に、図11のS3のランレングス符号化処理の詳細について説明する。図14は、図11のランレングス符号化処理のサブルーチンを示すフローチャートである。まず、差分ランレングス符号化部143は、各種パラメータを初期化する(S41)。次に、差分ランレングス符号化部143は、処理対象となるOSD表示パターンの最後のランの抽出が終了したか否かを判定し、終了した場合(S42でYES)、処理をリターンする。一方、最後のランの抽出が終了していない場合(S42でNO)、差分ランレングス符号化部143はラン抽出処理を行う(S43)。このラン抽出処理は、図15で示した処理と同じである。
<Run-length encoding process>
Next, details of the run length encoding process of S3 of FIG. 11 will be described. FIG. 14 is a flowchart showing a subroutine of the run-length encoding process of FIG. First, the differential run length encoding unit 143 initializes various parameters (S41). Next, the differential run length encoding unit 143 determines whether or not the extraction of the last run of the OSD display pattern to be processed has ended, and if it has ended (YES in S42), returns the processing. On the other hand, if the last run has not been extracted (NO in S42), the differential run length encoding unit 143 performs a run extraction process (S43). This run extraction process is the same as the process shown in FIG.

次に、差分ランレングス符号化部143は、S43で抽出したランの色コードを算出する(S44)。この処理は図13のS34と同じである。   Next, the differential run length encoding unit 143 calculates the color code of the run extracted in S43 (S44). This process is the same as S34 in FIG.

次に、差分ランレングス符号化部143は、S44で算出した色コードをランレングスデータ保持部16に出力する(S45)。次に、差分ランレングス符号化部143は、S43で抽出したランのランレングスから対応する色コードのベース値から差し引き差分ランレングスを求める。そして、差分ランレングスを対応する色コードの長さ部のビット数で符号化することで、差分ランレングスを符号化し、長さ部を算出する(S46)。次に、差分ランレングス符号化部143は、S46で算出した長さ部をランレングスデータ保持部16に出力する(S47)。   Next, the differential run length encoding unit 143 outputs the color code calculated in S44 to the run length data holding unit 16 (S45). Next, the differential run length encoding unit 143 obtains a subtracted differential run length from the base value of the corresponding color code from the run length of the run extracted in S43. Then, by encoding the difference run length with the number of bits of the corresponding color code length portion, the difference run length is encoded and the length portion is calculated (S46). Next, the differential run length encoding unit 143 outputs the length portion calculated in S46 to the run length data holding unit 16 (S47).

このように、OSD表示パターンから順次ランが抽出され、抽出したランの色コードと長さ部とが順次に出力され、ランレングスデータが算出される。   In this manner, the runs are sequentially extracted from the OSD display pattern, and the color code and the length portion of the extracted runs are sequentially output to calculate run length data.

図27は、色コード分割処理が行われた図17に示すOSD表示パターンに対し、差分ランレングスを求めて符号化した場合の効果を示す表である。   FIG. 27 is a table showing the effect when the difference run length is obtained and encoded with respect to the OSD display pattern shown in FIG. 17 subjected to the color code division processing.

図27において、“長さ部ビット数(変更前)”は、差分ランレングスを求める前の長さ部のビット数を示している。“ランレングス”は、差分ランレングスを求める前のランレングスの範囲を示している。“ベース値”は、差分ランレングスを求める際に使用されたランレングスの最小値である。“最大差分ランレングス”は、差分ランレングスの最大値である。“長さ部ビット数(変更後)”は、差分ランレングスを求めた場合の長さ部のビット数を示している。“ラン数”は、各色コードにおけるランの数を示している。“符号長削減量”は、差分ランレングスを採用したことによる符号長の削減量を色コード別に示している。   In FIG. 27, “number of bits in the length part (before change)” indicates the number of bits in the length part before the difference run length is obtained. “Run length” indicates a range of run lengths before the differential run length is obtained. The “base value” is the minimum value of the run length used when obtaining the differential run length. “Maximum differential run length” is the maximum value of the differential run length. “Number of bits in the length part (after change)” indicates the number of bits in the length part when the differential run length is obtained. “Run number” indicates the number of runs in each color code. “Code length reduction amount” indicates the reduction amount of the code length by adopting the differential run length for each color code.

例えば、色コード1について、差分ランレングスを求めずに、ランレングスを符号化した場合、長さ部のビット数は12ビットであった。一方、色コード1について、差分ランレングスを求めて符号化を行うと、長さ部のビット数は0ビットとなった。色コード1のラン数は2であるため、符号長削減量は、2×12=24ビットとなった。   For example, when the run length is encoded without obtaining the differential run length for the color code 1, the number of bits of the length portion is 12 bits. On the other hand, when the color code 1 is encoded by obtaining the difference run length, the number of bits in the length part becomes 0 bits. Since the number of runs of color code 1 is 2, the code length reduction amount is 2 × 12 = 24 bits.

同様に、色コード6については、符号長削減量は、463×6=2778ビットとなった。他の色コードは、符号長削減量は0であった。よって、符号長削減量の合計は2802であった。   Similarly, for color code 6, the code length reduction amount is 463 × 6 = 2778 bits. For the other color codes, the code length reduction amount was zero. Therefore, the total code length reduction amount was 2802.

一方、差分ランレングスを求めずにランレングス符号化した場合のランレングスデータの符号長は13395ビットであった。よって、差分ランレングスを求めることにより、ランレングスデータの符号長は、13395−2802=10,593bitとなる。   On the other hand, the code length of the run-length data when run-length encoding is performed without obtaining the differential run-length is 13395 bits. Therefore, by obtaining the differential run length, the code length of the run length data is 13395-2802 = 10,593 bits.

図28は、実施例2の結果をまとめた表である。色コード分割処理及びベース値処理を適用しない場合、つまり、従来のランレングス符号化を用いた場合、図17に示すOSD表示パターンの符号長は17,563ビットであった。一方、色コード分割処理のみ適用した場合、図17に示すOSD表示パターンの符号長は、13,395ビットであった。また、色コード分割処理及びベース値処理を適用した場合、図17に示すOSD表示パターンの符号長は、10,593ビットであった。   FIG. 28 is a table summarizing the results of Example 2. When color code division processing and base value processing are not applied, that is, when conventional run-length encoding is used, the code length of the OSD display pattern shown in FIG. 17 is 17,563 bits. On the other hand, when only the color code division processing is applied, the code length of the OSD display pattern shown in FIG. 17 is 13,395 bits. When the color code division process and the base value process are applied, the code length of the OSD display pattern shown in FIG. 17 is 10,593 bits.

なお、本実施の形態では、色コード分割処理とベース値処理及びランレングス符号化処理とが組み合わされていたが、これに限定されず、色コード分割処理のみ行ってランレングスデータを生成してもよい。また、ベース値処理及びランレングス符号化処理のみ行ってランレングスデータを生成してもよい。   In this embodiment, the color code division processing, the base value processing, and the run length encoding processing are combined. However, the present invention is not limited to this, and only the color code division processing is performed to generate run length data. Also good. Alternatively, only the base value processing and the run length encoding processing may be performed to generate run length data.

また、上記説明では、各色コードにつき、差分ランレングスを表すことができる最小のビット数を長さ部のビット数として採用したが、これに限定されず、各色コードにつき、差分ランレングスで表された全ランの符号化結果が最小となるビット数を長さ部のビット数として採用してもよい。   In the above description, the minimum number of bits that can represent the difference run length is adopted as the number of bits of the length portion for each color code. Alternatively, the number of bits that minimizes the encoding result of all runs may be adopted as the number of bits in the length portion.

11 画像取得部
12 テーブル保持部
13 色コード割当部
14 符号化部
16 ランレングスデータ保持部
51 ベース値テーブル保持部
52 色情報保持部
53 差分ランレングス抽出部
54 加算部
55 復号化部
DESCRIPTION OF SYMBOLS 11 Image acquisition part 12 Table holding part 13 Color code allocation part 14 Encoding part 16 Run length data holding part 51 Base value table holding part 52 Color information holding part 53 Differential run length extraction part 54 Addition part 55 Decoding part

Claims (8)

所定ビット数で色コードを格納する色コード部と、前記色コード毎にビット数が定められた長さ部とで各ランを表すランレングスデータに原画像データを符号化するランレングス符号化装置であって、
前記原画像データを色コードとランレングスとでコード化し、ランレングスコードを生成し、前記ランレングスコードを構成する各色コードにつき、各ランのランレングスのヒストグラムを算出し、算出したヒストグラムに基づいて、ある色コードが割り当てられたランの一部を抽出し、未使用の色コードに割り当てる色コード割当部と、
前記色コード割当部による割り当てが終了した後、各色コードにつき、全ランの符号化結果が最小となるビット数を前記長さ部のビット数として求め、各ランを符号化する符号化部とを備えるランレングス符号化装置。
A run-length encoding device that encodes original image data into run-length data representing each run with a color code part that stores a color code with a predetermined number of bits and a length part in which the number of bits is determined for each color code Because
The original image data is encoded with a color code and a run length, a run length code is generated, a run length histogram of each run is calculated for each color code constituting the run length code, and based on the calculated histogram A color code assigning unit that extracts a part of a run to which a certain color code is assigned and assigns it to an unused color code;
After the assignment by the color code assigning unit is finished, for each color code, obtain the number of bits that minimizes the encoding result of all runs as the number of bits of the length part, and an encoding unit that encodes each run. A run-length encoding device.
前記符号化部は、
各色コードにつき、ランレングスの最小値をベース値として算出するベース値算出部と、
各ランにつき、ランレングスから対応する色コードのベース値を差し引き、各ランの差分ランレングスを算出する差分ランレングス算出部と、
各色コードにつき、全ランの差分ランレングスを表すことができる最小のビット数を前記長さ部のビット数として求め、各ランを符号化する差分ランレングス符号化部とを備える請求項1記載のランレングス符号化装置。
The encoding unit includes:
For each color code, a base value calculation unit that calculates a minimum run length as a base value,
For each run, a difference run length calculation unit that subtracts the base value of the corresponding color code from the run length and calculates the difference run length of each run;
The difference run length encoding part which calculates | requires the minimum bit number which can represent the difference run length of all the runs for each color code as a bit number of the said length part, and encodes each run. Run-length encoding device.
前記符号化部は、各色コードにつき、前記ベース値を、前記長さ部のビット数と対応付けてベース値テーブルを生成するベース値テーブル生成部を更に備える請求項2記載のランレングス符号化装置。   The run-length encoding apparatus according to claim 2, wherein the encoding unit further includes a base value table generating unit that generates a base value table by associating the base value with the number of bits of the length part for each color code. . 前記色コード割当部は、前記ヒストグラムからランレングスに複数の偏りがある色コードを特定し、特定した色コードに対し、同じ偏りに属するランを抽出し、前記未使用の色コードを割り当てる請求項1〜3のいずれかに記載のランレングス符号化装置。   The color code assigning unit identifies color codes having a plurality of deviations in run length from the histogram, extracts runs belonging to the same deviation for the specified color codes, and assigns the unused color codes. The run-length encoding apparatus according to any one of 1 to 3. 前記色コード割当部は、各色コードにつき、前記長さ部のビット数の分割位置を変えながら符号長の削減量を算出し、前記削減量を最大化する分割位置を持つ色コードを、前記複数の偏りがある色コードとして特定し、特定した色コードにおいて、前記削減量を最大化する分割位置より大きなビット数で表されるランレングスを持つランを抽出し、前記未使用の色コードを割り当てる請求項4記載のランレングス符号化装置。   The color code allocating unit calculates a code length reduction amount while changing the division position of the number of bits of the length portion for each color code, and assigns the color code having a division position that maximizes the reduction amount to the plurality of color codes. In the specified color code, a run having a run length represented by a bit number larger than the division position that maximizes the reduction amount is extracted, and the unused color code is assigned. The run-length encoding apparatus according to claim 4. 所定ビット数で色コードを格納する色コード部と、前記色コード毎にビット数が定められた長さ部とを用いて各ランを表すランレングスデータを原画像データに復号化するランレングス復号化装置であって、
前記長さ部は、各ランのランレングスから各ランのベース値を差し引いた差分ランレングスを格納し、
前記ベース値は、各色コードにおけるランレングスの最小値を示し、
各色コードにつき、前記ベース値と前記長さ部のビット数とが対応付けられたベース値テーブルを保持するベース値テーブル保持部と、
各色コードをビットマップ形式で表すための色情報を保持する色情報保持部と、
前記ランレングスデータから色コードを特定し、特定した色コードに対応する前記長さ部のビット数を前記ベース値テーブルから特定し、特定したビット数分の前記色コードに続く前記ランレングスデータを差分ランレングスとして抽出する差分ランレングス抽出部と、
前記差分ランレングス抽出部により抽出された差分ランレングスに対応するベース値を加算し、ランレングスを算出する加算部と、
前記加算部により算出されたランレングス及び前記色情報に基づいて前記ランレングスデータを前記原画像データに復号化する復号化部とを備えるランレングス復号化装置。
Run-length decoding that decodes run-length data representing each run into original image data using a color code part that stores a color code with a predetermined number of bits and a length part in which the number of bits is determined for each color code Device.
The length part stores a differential run length obtained by subtracting the base value of each run from the run length of each run,
The base value indicates the minimum run length of each color code,
For each color code, a base value table holding unit that holds a base value table in which the base value and the number of bits of the length part are associated;
A color information holding unit that holds color information for representing each color code in a bitmap format;
A color code is identified from the run-length data, the number of bits of the length portion corresponding to the identified color code is identified from the base value table, and the run-length data following the color code for the identified number of bits is A differential run length extracting unit for extracting as a differential run length;
An addition unit for calculating a run length by adding a base value corresponding to the difference run length extracted by the difference run length extraction unit;
A run-length decoding apparatus comprising: a decoding unit that decodes the run-length data into the original image data based on the run length calculated by the adding unit and the color information.
所定ビット数で色コードを格納する色コード部と、前記色コード毎にビット数が定められた長さ部とで各ランを表すランレングスデータに原画像データを符号化するランレングス符号化方法であって、
前記ランレングス符号化装置が、前記原画像データを色コードとランレングスとでコード化し、ランレングスコードを生成し、前記原画像データを構成する各色コードにつき、各ランのランレングスのヒストグラムを算出し、算出したヒストグラムに基づいて、ある色コードが割り当てられたランの一部を抽出し、未使用の色コードに割り当てる色コード割当ステップと、
前記ランレングス符号化装置が、前記色コード割当ステップによる割り当てが終了した後、各色コードにつき、全ランの符号化結果が最小となるビット数を前記長さ部のビット数として求め、各ランを符号化する符号化ステップとを備えるランレングス符号化方法。
A run-length encoding method that encodes original image data into run-length data representing each run by a color code part that stores a color code with a predetermined number of bits and a length part in which the number of bits is determined for each color code Because
The run-length encoding device encodes the original image data with a color code and a run length, generates a run-length code, and calculates a run-length histogram of each run for each color code constituting the original image data. A color code assigning step for extracting a part of a run to which a certain color code is assigned based on the calculated histogram and assigning it to an unused color code;
The run-length encoding apparatus obtains, as the number of bits of the length part, the number of bits that minimizes the encoding result of all the runs for each color code after the assignment by the color code assigning step is completed. A run-length encoding method comprising: an encoding step for encoding.
所定ビット数で色コードを格納する色コード部と、前記色コード毎にビット数が定められた長さ部とを用いて、各ランを表すランレングスデータをランレングス復号化装置が原画像データに復号化するランレングス復号化方法であって、
前記長さ部は、各ランのランレングスから各ランのベース値を差し引いた差分ランレングスを格納し、
前記ベース値は、各色コードにおけるランレングスの最小値を示し、
前記ランレングス復号化装置は、
各色コードにつき、前記ベース値と前記長さ部のビット数とが対応付けられたベース値テーブルを保持するベース値テーブル保持部と、
各色コードを前記原画像データで表すための色情報を保持する色情報保持部とを備え、
前記ランレングス復号化装置が、前記ランレングスデータから色コードを特定し、特定した色コードに対応する前記長さ部のビット数を前記ベース値テーブルから特定し、特定したビット数分の前記色コードに続く前記ランレングスデータを差分ランレングスとして抽出する差分ランレングス抽出ステップと、
前記差分ランレングス抽出ステップにより抽出された差分ランレングスに対応するベース値を加算し、ランレングスを算出する加算ステップと、
前記加算ステップにより算出されたランレングス及び前記色情報に基づいて前記ランレングスデータを前記原画像データに復号化する復号化ステップとを備えるランレングス復号化方法。
The run-length decoding device converts the run-length data representing each run into the original image data using a color code portion that stores a color code with a predetermined number of bits and a length portion in which the number of bits is determined for each color code. A run-length decoding method for decoding
The length part stores a differential run length obtained by subtracting the base value of each run from the run length of each run,
The base value indicates the minimum run length of each color code,
The run length decoding device comprises:
For each color code, a base value table holding unit that holds a base value table in which the base value and the number of bits of the length part are associated;
A color information holding unit for holding color information for representing each color code by the original image data,
The run-length decoding apparatus specifies a color code from the run-length data, specifies the number of bits of the length portion corresponding to the specified color code from the base value table, and the color for the specified number of bits A differential run length extracting step of extracting the run length data following the code as a differential run length;
An addition step of adding a base value corresponding to the difference run length extracted by the difference run length extraction step, and calculating a run length;
A run-length decoding method comprising: a decoding step of decoding the run-length data into the original image data based on the run length calculated in the adding step and the color information.
JP2011118968A 2011-05-27 2011-05-27 Run length coding device, run length decoding device, run length coding method, and run length decoding method Withdrawn JP2012249061A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2011118968A JP2012249061A (en) 2011-05-27 2011-05-27 Run length coding device, run length decoding device, run length coding method, and run length decoding method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2011118968A JP2012249061A (en) 2011-05-27 2011-05-27 Run length coding device, run length decoding device, run length coding method, and run length decoding method

Publications (1)

Publication Number Publication Date
JP2012249061A true JP2012249061A (en) 2012-12-13

Family

ID=47469100

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2011118968A Withdrawn JP2012249061A (en) 2011-05-27 2011-05-27 Run length coding device, run length decoding device, run length coding method, and run length decoding method

Country Status (1)

Country Link
JP (1) JP2012249061A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111384960A (en) * 2018-12-28 2020-07-07 上海寒武纪信息科技有限公司 Decoding method, processor, decoding device and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111384960A (en) * 2018-12-28 2020-07-07 上海寒武纪信息科技有限公司 Decoding method, processor, decoding device and storage medium
CN111384960B (en) * 2018-12-28 2022-05-10 上海寒武纪信息科技有限公司 Decoding method, processor, decoding device and storage medium

Similar Documents

Publication Publication Date Title
CN109427047B (en) Image processing method and device
US9584701B2 (en) Image processing system and method
US7750927B2 (en) Image processing apparatus, image processing method, and computer program
CN101097710A (en) Image processor and image processing method
CN112118449B (en) Method and device for compressing and decompressing image
US20090256852A1 (en) Character display apparatus
CN114040246A (en) Image format conversion method, device, equipment and storage medium of graphic processor
JP2017204811A5 (en)
JPH1188700A (en) Coding method of color image signal, and decoding method and color image processor thereof
JP2017204811A (en) Image compressor, image developer, image compression and development system and display driver
JP4179255B2 (en) Image processing apparatus, image transmission apparatus, display apparatus, image processing method, and image transmission method
JP2008193263A (en) Image processing method, image processing device, image processing program, and record medium
JP2012249061A (en) Run length coding device, run length decoding device, run length coding method, and run length decoding method
JP2702408B2 (en) Image conversion system
CN115576513A (en) Target image display method, display device, electronic device, and storage medium
JP5367552B2 (en) Image processing apparatus and image processing program
JP5337250B2 (en) Image processing apparatus and method
JP2010541094A (en) Method, compressor, decompressor and signal representation for lossless compression of pixel block values using row tilt codewords and column tilt codewords
US9077993B2 (en) Method of converting a video file to a graphics interchange format image using same palette table for consecutive frames
JP2005055824A (en) Image display device, image display method and image display program
JP2703223B2 (en) Color image processing equipment
JP2004213464A (en) Image processor
JP3911986B2 (en) Method and apparatus for compressing and decompressing image data
US6067380A (en) Image compression method
JP3711104B2 (en) Image compression apparatus and image compression method

Legal Events

Date Code Title Description
A711 Notification of change in applicant

Free format text: JAPANESE INTERMEDIATE CODE: A712

Effective date: 20130418

A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20140805