JP4793175B2 - Image processing program and image processing apparatus - Google Patents

Image processing program and image processing apparatus Download PDF

Info

Publication number
JP4793175B2
JP4793175B2 JP2006231553A JP2006231553A JP4793175B2 JP 4793175 B2 JP4793175 B2 JP 4793175B2 JP 2006231553 A JP2006231553 A JP 2006231553A JP 2006231553 A JP2006231553 A JP 2006231553A JP 4793175 B2 JP4793175 B2 JP 4793175B2
Authority
JP
Japan
Prior art keywords
image
value
reduced
retinex
pixel
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
JP2006231553A
Other languages
Japanese (ja)
Other versions
JP2008060627A (en
Inventor
雅司 久野
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Brother Industries Ltd
Original Assignee
Brother Industries Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Brother Industries Ltd filed Critical Brother Industries Ltd
Priority to JP2006231553A priority Critical patent/JP4793175B2/en
Priority to US11/837,817 priority patent/US7920752B2/en
Publication of JP2008060627A publication Critical patent/JP2008060627A/en
Application granted granted Critical
Publication of JP4793175B2 publication Critical patent/JP4793175B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、画像処理プログラムおよび画像処理装置に関し、特にレティネックス処理とヒストグラム処理とを行う画像処理プログラムおよび画像処理装置に関するものである。   The present invention relates to an image processing program and an image processing apparatus, and more particularly to an image processing program and an image processing apparatus that perform Retinex processing and histogram processing.

逆光条件下で被写体が撮像された場合、被写体部分の画像は、詳細な態様が判別困難となるほど明度やコントラストの低い不明瞭な逆光画像となる。かかる逆光画像のみならず、露光の過不足や、撮像時のぶれやぼけ、ノイズ、光量不足などによる劣悪な画像を、画像処理によって明度やコントラストを向上させて画質を改良することが行われている。かかる画像処理の1手法として、レティネックス処理(Retinex処理)が知られている。   When a subject is imaged under backlight conditions, the image of the subject portion becomes an unclear backlight image with low brightness and contrast as the detailed mode becomes difficult to distinguish. In addition to such backlit images, poor images due to overexposure and underexposure, blurring and blurring during shooting, noise, insufficient light quantity, etc. are being used to improve image quality by improving brightness and contrast through image processing. Yes. As one method of such image processing, Retinex processing (Retinex processing) is known.

レティネックス処理は、高画質部分については入力画像データを保持し、主に低画質部分の画質改良を行うものである。このレティネックス処理では、ガウスフィルタにより、元の画像の各画素データを周辺画素の画素データを反映させた値に補正し、その補正された画素データの自然対数から元の画像のリファレンス成分データを算出し、元画像の画素成分で元の画像の画素データを除してイルミナンス成分データを算出する。つまり、元の画像を、リファレンス成分とイルミナンス成分との2の構成成分に分けるのである。そして、イルミナンス成分に対してガンマ補正等の明度や階調(コントラスト)を補正する処理を行った後、その補正されたイルミナンス成分と、リファレンス成分とを合成することにより、元の画像に対し逆光画像部分などの低画質部分の画質が改良された画像データを生成することができる。リファレンス成分を求めるには、反射率R(x,y)の正規化を行う。   In the Retinex process, the input image data is held for the high-quality part, and the image quality is mainly improved for the low-quality part. In this Retinex processing, each pixel data of the original image is corrected to a value reflecting the pixel data of the surrounding pixels by a Gaussian filter, and the reference component data of the original image is obtained from the natural logarithm of the corrected pixel data. The illuminance component data is calculated by dividing the pixel data of the original image by the pixel component of the original image. That is, the original image is divided into two constituent components, a reference component and an illuminance component. Then, after performing processing for correcting the brightness and gradation (contrast) such as gamma correction for the illuminance component, the corrected illuminance component and the reference component are combined, and the original image is backlit. Image data in which the image quality of a low image quality portion such as an image portion is improved can be generated. In order to obtain the reference component, the reflectance R (x, y) is normalized.

ここで、図7を参照して、反射率R(x,y)の正規化について説明する。反射率R(x,y)は、次式により算出される。   Here, normalization of the reflectance R (x, y) will be described with reference to FIG. The reflectance R (x, y) is calculated by the following equation.

Figure 0004793175
ここで、xは、横方向の座標を、yは、縦方向の座標を、I(x,y)は、座標(x,y)における強度値を、F(x,y)は、座標(x,y)のフィルタ係数を、*は、畳み込み演算(コンボリューション)をそれぞれ示す。
Figure 0004793175
Here, x is a coordinate in the horizontal direction, y is a coordinate in the vertical direction, I (x, y) is an intensity value at the coordinate (x, y), and F (x, y) is a coordinate ( x, y) and * indicate convolution operations (convolution), respectively.

図7は、ある静止画像について、上式により求められた反射率R(x,y)の最小値を0、最大値を255とする0から255の範囲の整数値に正規化し、各整数の出現頻度を集計したヒストグラムである。   FIG. 7 shows the normalization of an integer value in the range of 0 to 255, where the minimum value of the reflectance R (x, y) obtained by the above equation is 0 and the maximum value is 255 for a certain still image. It is the histogram which totaled appearance frequency.

このヒストグラムからメディアン値Mを求め、メディアン値から大きい側へ45%の画素数を含む範囲の上限値をU、メディアン値から小さい側へ45%の画素数を含む範囲の下限値をDとする。   The median value M is obtained from this histogram, the upper limit value of the range including 45% of pixels from the median value to the larger side is U, and the lower limit value of the range including 45% of pixels from the median value to the smaller side is D. .

UおよびDの値に対応するR(x,y)の値を、UpR、DownRとし、正規化反射率(正規化レティネックス値)refle(x,y)は、R(x,y)の値がDownR以下の場合は、0.0とし、R(x,y)の値がUpR以上の場合は、1.0とし、R(x,y)の値がDownRより大きくUpRより小さい場合は、   The values of R (x, y) corresponding to the values of U and D are UpR and DownR, and the normalized reflectance (normalized Retinex value) refle (x, y) is the value of R (x, y). Is 0.0 when the value is equal to or less than DownR, 1.0 when the value of R (x, y) is equal to or greater than UpR, and when the value of R (x, y) is greater than DownR and smaller than UpR,

Figure 0004793175
とする。
Figure 0004793175
And

このように処理するとrefle(x,y)は、0.0から1.0の間の値を取るように正規化される。実験によれば、こうして得られた値に、0.3を加算し、refle(x,y)の値が0.3から1.3の値を取るようにするのがよいことが判明している。   When processed in this way, refle (x, y) is normalized to take a value between 0.0 and 1.0. Experiments have shown that it is better to add 0.3 to the value thus obtained so that the value of refle (x, y) takes a value from 0.3 to 1.3. Yes.

このようにしてrefle(x,y)が求められるので、クリップされる範囲(UpRとDownRとの間)を求めるため、R(x,y)を全画素分記憶しなければならない。尚かつ、R(x,y)は、対数演算により求まる数値であるので、小数点を用いて記録する必要がある。浮動小数点で記憶する場合は、例えば、これらの処理をパーソナルコンピュータ(以下、PCと称す)で行うような場合、一般的なPCのCPU、オペレーティング・システムのデータ処理単位は32ビットであるから4バイトで、倍精度実数の場合には8バイトで記憶するため、対数演算処理したR(x,y)を記録する膨大な記憶容量が必要である。   Since refle (x, y) is obtained in this way, R (x, y) must be stored for all pixels in order to obtain the clipped range (between UpR and DownR). Furthermore, R (x, y) is a numerical value obtained by logarithmic calculation, so it must be recorded using a decimal point. When storing in floating point, for example, when these processes are performed by a personal computer (hereinafter referred to as a PC), the data processing unit of a general PC CPU and operating system is 32 bits. In the case of a double precision real number in bytes, since it is stored in 8 bytes, a huge storage capacity for recording R (x, y) obtained by logarithmic calculation processing is required.

特開2001−69525号公報(特許文献1)には、このレティネックス処理をRGBの各プレーンで独立に行った場合に、カラーバランスが崩れたり色ずれが発生するという問題点を解決するために、RGB値をYCbCrやYIQという輝度成分と色成分により構成される座標空間に変換し、輝度成分Yに対してのみレティネックス処理を施し、色成分を維持したまま、RGBに戻すという方法が開示されている。この方法を用いると輝度成分のみが調整され、色成分は調整されないのでカラーバランスが崩れたり色ずれが発生することがない。また、この方法では、輝度成分のみにレティネックス処理を行うので、RGBの各プレーンそれぞれにレティネックス処理を行う場合に比べ、計算量が少なく、高速で処理を実行することができる。   Japanese Patent Laid-Open No. 2001-69525 (Patent Document 1) discloses a solution to the problem that color balance is lost or color misregistration occurs when this Retinex process is performed independently for each of the RGB planes. Discloses a method of converting RGB values into a coordinate space composed of luminance components and color components such as YCbCr and YIQ, performing Retinex processing only on the luminance component Y, and returning to RGB while maintaining the color components. Has been. When this method is used, only the luminance component is adjusted, and the color component is not adjusted, so that the color balance is not lost and color shift does not occur. Further, in this method, since the Retinex process is performed only on the luminance component, the calculation amount is small and the process can be executed at a high speed compared to the case where the Retinex process is performed on each of the RGB planes.

また、特許3731577号(特許文献2)には、このレティネックス処理の処理速度を高速にする方法が開示されている。この方法は、元画像を平均画素法などの方法により縮小画像(解像度が低い)を形成し、その縮小画像の各画素について周辺平均輝度を求めた周辺平均輝度画像(ボケ画像)を形成し、そのボケ画像を拡大した画像と元画像からレティネックス処理画像を形成し、更に、そのレティネックス処理画像と元画像とから出力画像を形成している。
特開2001−69525号公報 特許3731577号公報
Japanese Patent No. 3731577 (Patent Document 2) discloses a method for increasing the processing speed of the Retinex processing. In this method, a reduced image (low resolution) is formed from the original image by a method such as an average pixel method, and a peripheral average luminance image (blurred image) obtained by calculating a peripheral average luminance for each pixel of the reduced image is formed. A retinex processed image is formed from the enlarged image of the blurred image and the original image, and an output image is formed from the retinex processed image and the original image.
JP 2001-69525 A Japanese Patent No. 3731577

しかしながら、従来の文献に開示された処理では、反射率を記憶するメモリのサイズが、元画像と同じ大きさ(例えば、文献1:(0090)、「元のFULL(2,560x1,920)の解像度に戻して、Retinex処理部407で処理を実行する」)なので、元画像が大きくなるにつれて反射率を記憶するメモリのサイズが大きくなるという問題点と、処理された画像を出力する際に、元画像が大きくなるにつれて、R(x,y)のデータ量も対応して大きくなるために、R(x,y)の対数演算量も増えて、画像の出力開始までの時間が長くなるという問題点とがあった。   However, in the processing disclosed in the conventional literature, the size of the memory for storing the reflectance is the same as that of the original image (for example, literature 1: (0090), “original FULL (2,560 × 1,920) The resolution is returned to the resolution and the processing is executed by the Retinex processing unit 407)), so that the size of the memory for storing the reflectance increases as the original image becomes larger, and when the processed image is output, As the original image becomes larger, the data amount of R (x, y) also correspondingly increases, so the logarithmic calculation amount of R (x, y) also increases, and the time until image output starts increases. There was a problem.

本発明は、上記問題点を解決するためになされたものであり、レティネックス処理とヒストグラム処理とを少ない記憶容量のメモリを用いて高速で行うことができる画像処理プログラムおよび画像処理装置を提供することを目的としている。   The present invention has been made to solve the above-described problems, and provides an image processing program and an image processing apparatus capable of performing Retinex processing and histogram processing at high speed using a memory having a small storage capacity. The purpose is that.

この目的を達成するために、請求項1記載の画像処理プログラムは、画像の補正処理を行う画像処理装置により実行されるものであり、元画像を縮小した縮小画像の各画素について、画素の値とその画素の周辺平均輝度とから反射率を求めることにより縮小レティネックス画像を形成する縮小レティネックス画像形成ステップと、その縮小レティネックス画像形成ステップにより形成された縮小レティネックス画像の画素値が取る値の全範囲における各画素値の頻度を集計し、正規化を行う際の上限値および下限値を設定する正規化パラメータ設定ステップと、前記縮小レティネックス画像形成ステップにより形成された縮小レティネックス画像を前記正規化パラメータ設定ステップにより設定された上限値および下限値に基づいて正規化し、その正規化した値が大きくなるほど補正後の前記縮小画像の画素値が大きくなるように前記縮小画像の画素値の補正を行う縮小画像補正ステップと、その縮小画像補正ステップにより補正された縮小画像の画素値が取る全範囲における各画素値の頻度を集計し、ヒストグラム処理を行うパラメータを取得するヒストグラム処理パラメータ取得ステップと、前記元画像の各画素について、画素の値とその画素の周辺平均輝度とから反射率を求め、その反射率を前記正規化パラメータ設定ステップにより設定された上限値および下限値に基づいて正規化した正規化レティネックス値を求め、その正規化レティネックス値が大きくなるほど補正後の前記元画像の画素値が大きくなるように前記元画像の画素値の補正を行い、前記ヒストグラム処理パラメータ取得ステップにより取得されたヒストグラム処理パラメータに基づいて、補正された画素値をヒストグラム補正する元画像補正ステップとを、前記画像処理装置に実行させる
In order to achieve this object, the image processing program according to claim 1 is executed by an image processing apparatus that performs image correction processing. For each pixel of a reduced image obtained by reducing the original image, a pixel value is obtained. And a pixel value of the reduced Retinex image formed by the reduced Retinex image forming step, which forms a reduced Retinex image by calculating the reflectance from the peripheral average luminance of the pixel and the pixel. A normalization parameter setting step for setting an upper limit value and a lower limit value for performing normalization by summing up the frequency of each pixel value in the entire range of values, and a reduced Retinex image formed by the reduced Retinex image forming step Is normalized based on the upper limit value and the lower limit value set by the normalization parameter setting step. A reduced image correcting step of correcting the pixel value of the normalized value is larger as the reduced image of the pixel values becomes large so that the reduced image after correction, the corrected reduced image by the reduced image correction step The histogram processing parameter acquisition step for acquiring the parameters for performing histogram processing by summing up the frequency of each pixel value in the entire range taken by the pixel value, and for each pixel of the original image, the pixel value and the peripheral average luminance of the pixel The reflectance is obtained from the above, and the normalized Retinex value obtained by normalizing the reflectance based on the upper limit value and the lower limit value set by the normalization parameter setting step is obtained, and the corrected value increases as the normalized Retinex value increases. wherein as the pixel values of the original image increases corrects the pixel values of the original image, the histogram processing Based on the obtained histogram processing parameter by parameter obtaining step, and an original image correction step of the histogram correcting corrected pixel values, to be executed by the image processing apparatus.

請求項2記載の画像処理プログラムは、請求項1記載の画像処理プログラムにおいて、前記縮小レティネックス画像形成ステップは、縮小画像の輝度信号のみについて縮小レティネックス画像を形成し、前記縮小画像補正ステップは、前記縮小レティネックス画像形成ステップにより形成された縮小レティネックス画像を前記正規化パラメータ設定ステップにより設定された上限値および下限値に基づいて正規化し、その正規化した値が大きくなるほど補正後の前記縮小画像の輝度信号が大きくなるように前記縮小画像の輝度信号の補正をした後カラー画像に戻し、前記ヒストグラム処理パラメータ取得ステップは、前記縮小画像補正ステップにより補正されたカラー画像の画素値が取る全範囲における各画素値の頻度を集計し、ヒストグラム処理を行うパラメータを取得し、前記元画像補正ステップは、元画像の輝度信号のみについてレティネックス値求め、そのレティネックス値を前記正規化パラメータ設定ステップにより設定された上限値および下限値に基づいて正規化し、その正規化したレティネックス値が大きくなるほど補正後の前記元画像の輝度信号が大きくなるように前記元画像の輝度信号の補正を行うとともにカラー画素値に戻し、そのカラー画素値を前記ヒストグラム処理パラメータ取得ステップにより取得されたパラメータに基づいてヒストグラム補正する。
The image processing program according to claim 2 is the image processing program according to claim 1, wherein the reduced Retinex image forming step forms a reduced Retinex image only for the luminance signal of the reduced image, and the reduced image correction step includes The reduced Retinex image formed by the reduced Retinex image forming step is normalized based on the upper limit value and the lower limit value set by the normalization parameter setting step , and the corrected value increases as the normalized value increases. After the luminance signal of the reduced image is corrected so that the luminance signal of the reduced image is increased, the reduced image is returned to the color image. In the histogram processing parameter acquisition step, the pixel value of the color image corrected by the reduced image correction step is Aggregate the frequency of each pixel value in the entire range The parameter for processing is acquired, and the original image correction step obtains a Retinex value for only the luminance signal of the original image, and the Retinex value is based on the upper limit value and the lower limit value set by the normalization parameter setting step. Normalization, correcting the luminance signal of the original image so that the luminance signal of the original image after correction increases as the normalized Retinex value increases , and returns the color pixel value to the color pixel value. Histogram correction is performed based on the parameters acquired in the histogram processing parameter acquisition step.

請求項3記載の画像処理プログラムは、請求項1または2記載の画像処理プログラムにおいて、前記正規化パラメータ設定ステップは、前記縮小レティネックス画像形成ステップにより形成された縮小レティネックス画像の全画素が取る値の最大値から最小値の範囲の値のうち、全画素に対する所定の割合の画素を含むクリップ範囲の上限値と下限値とを正規化パラメータとして設定する。   The image processing program according to claim 3 is the image processing program according to claim 1 or 2, wherein the normalization parameter setting step takes all pixels of the reduced Retinex image formed by the reduced Retinex image forming step. Among the values in the range from the maximum value to the minimum value, the upper limit value and the lower limit value of the clip range including a predetermined ratio of pixels with respect to all pixels are set as normalization parameters.

請求項4記載の画像処理装置は、画像の補正処理を行うものであり、元画像を縮小した縮小画像の各画素について、画素の値とその画素の周辺平均輝度とから反射率を求めることにより縮小レティネックス画像を形成する縮小レティネックス画像形成手段と、その縮小レティネックス画像形成手段により形成された縮小レティネックス画像の画素値が取る値の全範囲における各画素値の頻度を集計し、正規化を行う際の上限値および下限値を設定する正規化パラメータ設定手段と、前記縮小レティネックス画像形成手段により形成された縮小レティネックス画像を前記正規化パラメータ設定手段により設定された上限値および下限値に基づいて正規化し、その正規化した値が大きくなるほど補正後の前記縮小画像の画素値が大きくなるように前記縮小画像の画素値の補正を行う縮小画像補正手段と、その縮小画像補正手段により補正された縮小画像の画素値が取る全範囲における各画素値の頻度を集計し、ヒストグラム処理を行うパラメータを取得するヒストグラム処理パラメータ取得手段と、前記元画像の各画素について、画素の値とその画素の周辺平均輝度とから反射率を求め、その反射率を前記正規化パラメータ設定手段により設定された上限値および下限値に基づいて正規化した正規化レティネックス値を求め、その正規化レティネックス値が大きくなるほど補正後の前記元画像の画素値が大きくなるように前記元画像の画素値の補正を行い、前記ヒストグラム処理パラメータ取得手段により取得されたヒストグラム処理パラメータに基づいて、補正された画素値をヒストグラム補正する元画像補正手段とを備えている。
The image processing apparatus according to claim 4 performs image correction processing, and for each pixel of a reduced image obtained by reducing the original image, the reflectance is obtained from the pixel value and the peripheral average luminance of the pixel. The reduced Retinex image forming means for forming the reduced Retinex image, and the frequency of each pixel value in the entire range of values taken by the pixel values of the reduced Retinex image formed by the reduced Retinex image forming means Normalization parameter setting means for setting an upper limit value and a lower limit value when performing normalization, and an upper limit value and a lower limit set by the normalization parameter setting means for the reduced Retinex image formed by the reduced Retinex image forming means normalized based on the value, so that the pixel values of the reduced image after correction as the normalized value is increased becomes larger A reduced image correcting means for correcting the pixel value of the serial reduced image, counts the frequency of each pixel value in the full range of pixel values take the corrected reduced image by the reduced image correcting unit, a parameter for performing histogram processing For each pixel of the original image to be acquired, the histogram processing parameter acquisition means to obtain the reflectance from the pixel value and the peripheral average luminance of the pixel, and the reflectance is the upper limit value set by the normalization parameter setting means Then, a normalized Retinex value normalized based on the lower limit value is obtained, and the pixel value of the original image is corrected so that the pixel value of the original image after correction increases as the normalized Retinex value increases. , Based on the histogram processing parameter acquired by the histogram processing parameter acquisition means, And an original image correcting means for ram corrected.

請求項5記載の画像処理装置は、請求項4記載の画像処理装置において、前記縮小レティネックス画像形成手段は、縮小画像の輝度信号のみについて縮小レティネックス画像を形成し、前記縮小画像補正手段は、前記縮小レティネックス画像形成手段により形成された縮小レティネックス画像を前記正規化パラメータ設定手段により設定された上限値および下限値に基づいて正規化し、その正規化した値が大きくなるほど補正後の前記縮小画像の輝度信号が大きくなるように前記縮小画像の輝度信を補正した後カラー画像に戻し、前記ヒストグラム処理パラメータ取得手段は、前記縮小画像補正手段により補正されたカラー画像の画素値が取る全範囲における各画素値の頻度を集計し、ヒストグラム処理を行うパラメータを取得し、前記元画像補正手段は、元画像の輝度信号のみについてレティネックス値求め、そのレティネックス値を前記正規化パラメータ設定手段により設定された上限値および下限値に基づいて正規化し、その正規化レティネックス値が大きくなるほど補正後の前記元画像の輝度信号が大きくなるように前記元画像の輝度信号の補正を行うとともにカラー画素値に戻し、そのカラー画素値を前記ヒストグラム処理パラメータ取得手段により取得されたパラメータに基づいてヒストグラム補正する。
The image processing device according to claim 5 is the image processing device according to claim 4, wherein the reduced Retinex image forming unit forms a reduced Retinex image only for the luminance signal of the reduced image, and the reduced image correcting unit includes The reduced Retinex image formed by the reduced Retinex image forming unit is normalized based on the upper limit value and the lower limit value set by the normalization parameter setting unit, and the corrected value increases as the normalized value increases. The luminance signal of the reduced image is corrected so that the luminance signal of the reduced image is increased and then returned to the color image, and the histogram processing parameter acquisition unit is configured to take all pixel values of the color image corrected by the reduced image correction unit. The frequency of each pixel value in the range is totaled, a parameter for performing histogram processing is acquired, and the original image Correcting means, only for the luminance signal of the original image determined Retinex value, the Retinex value normalized based on the set upper limit value and the lower limit value by the normalization parameter setting means, the normalized Retinex value is greater The correction of the luminance signal of the original image is performed so that the luminance signal of the original image after correction becomes larger and the color pixel value is restored, and the color pixel value is based on the parameter acquired by the histogram processing parameter acquisition unit. To correct the histogram.

請求項6記載の画像処理装置は、請求項4または5記載の画像処理装置において、前記正規化パラメータ設定手段は、前記縮小レティネックス画像形成手段により形成された縮小レティネックス画像の全画素が取る値の最大値から最小値の範囲の値のうち、全画素に対する所定の割合の画素を含むクリップ範囲の上限値と下限値とを正規化パラメータとして設定する。   The image processing apparatus according to claim 6 is the image processing apparatus according to claim 4 or 5, wherein the normalization parameter setting means takes all pixels of the reduced Retinex image formed by the reduced Retinex image forming means. Among the values in the range from the maximum value to the minimum value, the upper limit value and the lower limit value of the clip range including a predetermined ratio of pixels with respect to all pixels are set as normalization parameters.

請求項1記載の画像処理プログラムによれば、縮小レティネックス画像形成ステップは、元画像を縮小した縮小画像の各画素について、画素の値とその画素の周辺平均輝度とから反射率を求めることにより縮小レティネックス画像を形成し、正規化パラメータ設定ステップは、縮小レティネックス画像の画素値が取る値の全範囲における各画素値の頻度を集計し、正規化を行う際の上限値および下限値を設定する。   According to the image processing program of the first aspect, the reduced Retinex image forming step obtains the reflectance from the pixel value and the peripheral average luminance of the pixel for each pixel of the reduced image obtained by reducing the original image. The reduced Retinex image is formed, and the normalization parameter setting step totals the frequency of each pixel value in the entire range of values taken by the pixel values of the reduced Retinex image, and calculates the upper limit value and the lower limit value for normalization. Set.

ヒストグラム処理パラメータ取得ステップは、縮小レティネックス画像形成ステップにより形成された縮小レティネックス画像を正規化パラメータ設定ステップにより設定された上限値および下限値に基づいて正規化し、その正規化した値と縮小画像の画素値とに基づいて補正を行い、その補正された縮小画像の画素値が取る全範囲における各画素値の頻度を集計し、ヒストグラム処理を行うパラメータを取得する。   The histogram processing parameter acquisition step normalizes the reduced Retinex image formed by the reduced Retinex image forming step based on the upper limit value and the lower limit value set by the normalization parameter setting step, and the normalized value and the reduced image And the frequency of each pixel value in the entire range taken by the pixel value of the corrected reduced image is totaled to obtain a parameter for performing histogram processing.

よって、縮小画像や、途中の演算結果を記憶するメモリの容量を小さくすることができるとともに、正規化を行うパラメータとヒストグラム処理を行うパラメータとを元画像を縮小した縮小画像に基づいて取得するので、高速で取得することができる。   Therefore, it is possible to reduce the capacity of the memory for storing the reduced image and the intermediate calculation result, and obtain the parameters for normalization and the parameters for histogram processing based on the reduced image obtained by reducing the original image. Can be acquired at high speed.

元画像補正ステップは、元画像の各画素について、画素の値とその画素の周辺平均輝度とから反射率を求め、その反射率を正規化パラメータ設定ステップにより設定された上限値および下限値に基づいて正規化した正規化レティネックス値を求め、その正規化レティネックス値と、元画像の画素値とに基づいて補正を行い、ヒストグラム処理パラメータ取得ステップにより取得されたヒストグラム処理パラメータに基づいて、補正された画素値をヒストグラム補正する。この元画像補正ステップでは、元画像の各画素について順次処理を行うことができるので、処理された画素の値を順次出力することができる。従って、レティネックス処理を開始してから、出力が開始されるまでの時間を短縮ることができるという効果がある。   In the original image correction step, for each pixel of the original image, the reflectance is obtained from the pixel value and the peripheral average luminance of the pixel, and the reflectance is based on the upper limit value and the lower limit value set in the normalization parameter setting step. Normalized normalized Retinex value, corrected based on the normalized Retinex value and the pixel value of the original image, and corrected based on the histogram processing parameter acquired by the histogram processing parameter acquisition step Histogram correction is performed on the pixel values. In this original image correction step, since each pixel of the original image can be sequentially processed, the processed pixel values can be sequentially output. Therefore, there is an effect that it is possible to shorten the time from the start of Retinex processing until the start of output.

請求項2記載の画像処理プログラムによれば、請求項1記載の画像処理プログラムの奏する効果に加え、縮小レティネックス画像形成ステップは、縮小画像の輝度信号のみについて縮小レティネックス画像を形成し、縮小画像補正ステップは、縮小レティネックス画像形成ステップにより形成された縮小レティネックス画像を正規化パラメータ設定ステップにより設定された上限値および下限値に基づいて正規化し、その正規化した値と、縮小画像の輝度信号とに基づいて縮小画像を補正した後カラー画像に戻し、ヒストグラム処理パラメータ取得ステップは、縮小画像補正ステップにより補正されたカラー画像の画素値が取る全範囲における各画素値の頻度を集計し、ヒストグラム処理を行うパラメータを取得し、元画像補正ステップは、元画像の輝度信号のみについてレティネックス値求め、そのレティネックス値を正規化パラメータ設定ステップにより設定された上限値および下限値に基づいて正規化し、その正規化レティネックス値と、元画像の輝度信号とに基づいて補正を行うとともにカラー画素値に戻し、そのカラー画素値をヒストグラム処理パラメータ取得ステップにより取得されたパラメータに基づいてヒストグラム補正するので、カラー画像を構成するRGB値それぞれについてレティネックス処理を行う場合に比べて、処理が速いとともに、色ずれが発生しないという効果がある。   According to the image processing program of the second aspect, in addition to the effect of the image processing program of the first aspect, the reduced Retinex image forming step forms a reduced Retinex image only for the luminance signal of the reduced image, and The image correction step normalizes the reduced Retinex image formed by the reduced Retinex image forming step based on the upper limit value and the lower limit value set by the normalization parameter setting step, and the normalized value and the reduced image The reduced image is corrected based on the luminance signal and then returned to the color image, and the histogram processing parameter acquisition step totals the frequency of each pixel value in the entire range taken by the pixel value of the color image corrected by the reduced image correction step. The parameter for performing histogram processing is acquired, and the original image correction step is The Retinex value is obtained only for the luminance signal of the image, the Retinex value is normalized based on the upper limit value and the lower limit value set by the normalization parameter setting step, the normalized Retinex value, the luminance signal of the original image, and The color pixel value is corrected and returned to the color pixel value, and the color pixel value is histogram-corrected based on the parameter acquired in the histogram processing parameter acquisition step. Therefore, Retinex processing is performed for each of the RGB values constituting the color image. Compared to the case, there are effects that the processing is fast and color misregistration does not occur.

請求項3記載の画像処理プログラムによれば、請求項1または2記載の画像処理プログラムの奏する効果に加え、正規化パラメータ設定ステップは、縮小レティネックス画像形成ステップにより形成された縮小レティネックス画像の全画素が取る値の最大値から最小値の範囲の値のうち、全画素に対する所定の割合の画素を含むクリップ範囲の上限値と下限値とを正規化パラメータとして設定するので、決定される上限値および下限値は、元画像を用いて決定した上限値および下限値とほぼ同一の値を得ることができる。したがって、この上限値および下限値の精度を維持したままで高速で求めることができるという効果がある。なお、正規化パラメータとして上限値、下限値ではなく最大値、最小値を用いた場合は、元画像により求めた値と、縮小画像により求めた値とが大きく異なる場合がある。   According to the image processing program of the third aspect, in addition to the effect produced by the image processing program of the first or second aspect, the normalization parameter setting step includes the step of reducing the Retinex image formed by the reduction Retinex image forming step. Since the upper and lower limit values of the clip range including a predetermined percentage of all the pixels in the range from the maximum value to the minimum value of all pixels are set as normalization parameters, the upper limit determined As the value and the lower limit, it is possible to obtain substantially the same value as the upper limit and the lower limit determined using the original image. Therefore, there is an effect that the upper limit value and the lower limit value can be obtained at a high speed while maintaining the accuracy. When the maximum value and the minimum value are used as normalization parameters instead of the upper limit value and the lower limit value, the value obtained from the original image and the value obtained from the reduced image may be greatly different.

請求項4記載の画像処理装置によれば、縮小レティネックス画像形成手段は、元画像を縮小した縮小画像の各画素について、画素の値とその画素の周辺平均輝度とから反射率を求めることにより縮小レティネックス画像を形成し、正規化パラメータ設定手段は、縮小レティネックス画像の画素値が取る値の全範囲における各画素値の頻度を集計し、正規化を行う際の上限値および下限値を設定する。   According to the image processing apparatus of the fourth aspect, the reduced Retinex image forming unit obtains the reflectance for each pixel of the reduced image obtained by reducing the original image from the pixel value and the peripheral average luminance of the pixel. A reduced Retinex image is formed, and the normalization parameter setting means totals the frequency of each pixel value in the entire range of values taken by the pixel values of the reduced Retinex image, and calculates an upper limit value and a lower limit value for normalization. Set.

ヒストグラム処理パラメータ取得手段は、縮小レティネックス画像形成手段により形成された縮小レティネックス画像を正規化パラメータ設定手段により設定された上限値および下限値に基づいて正規化し、その正規化した値と縮小画像の画素値とに基づいて補正を行い、その補正された縮小画像の画素値が取る全範囲における各画素値の頻度を集計し、ヒストグラム処理を行うパラメータを取得する。   The histogram processing parameter acquisition unit normalizes the reduced Retinex image formed by the reduced Retinex image forming unit based on the upper limit value and the lower limit value set by the normalization parameter setting unit, and the normalized value and the reduced image And the frequency of each pixel value in the entire range taken by the pixel value of the corrected reduced image is totaled to obtain a parameter for performing histogram processing.

よって、縮小画像を記憶したり途中の演算結果を記憶するメモリの容量を小さくすることができるとともに、正規化を行うパラメータとヒストグラム処理を行うパラメータとを元画像を縮小した縮小画像に基づいて取得するので、高速で取得することができる。   Therefore, it is possible to reduce the capacity of the memory for storing the reduced image and the intermediate calculation result, and obtain the parameter for normalization and the parameter for histogram processing based on the reduced image obtained by reducing the original image. So you can get at high speed.

元画像補正手段は、元画像の各画素について、画素の値とその画素の周辺平均輝度とから反射率を求め、その反射率を正規化パラメータ設定手段により設定された上限値および下限値に基づいて正規化した正規化レティネックス値を求め、その正規化レティネックス値と、元画像の画素値とに基づいて補正を行い、ヒストグラム処理パラメータ取得手段により取得されたヒストグラム処理パラメータに基づいて、補正された画素値をヒストグラム補正する。この元画像補正手段では、元画像の各画素について順次処理を行うことができるので、処理された画素の値を順次出力することができる。従って、レティネックス処理を開始してから、出力が開始されるまでの時間を短縮ることができるという効果がある。   The original image correction means obtains a reflectance for each pixel of the original image from the pixel value and the peripheral average luminance of the pixel, and the reflectance is based on the upper limit value and the lower limit value set by the normalization parameter setting means. Normalized normalized Retinex value, corrected based on the normalized Retinex value and the pixel value of the original image, and corrected based on the histogram processing parameter acquired by the histogram processing parameter acquisition means Histogram correction is performed on the pixel values. In this original image correction means, since each pixel of the original image can be sequentially processed, the value of the processed pixel can be sequentially output. Therefore, there is an effect that it is possible to shorten the time from the start of Retinex processing until the start of output.

請求項5記載の画像処理装置によれば、請求項4記載の画像処理装置の奏する効果に加え、縮小レティネックス画像形成手段は、縮小画像の輝度信号のみについて縮小レティネックス画像を形成し、縮小画像補正手段は、縮小レティネックス画像形成手段により形成された縮小レティネックス画像を正規化パラメータ設定手段により設定された上限値および下限値に基づいて正規化し、その正規化した値と、縮小画像の輝度信号とに基づいて縮小画像を補正した後カラー画像に戻し、ヒストグラム処理パラメータ取得手段は、縮小画像補正手段により補正されたカラー画像の画素値が取る全範囲における各画素値の頻度を集計し、ヒストグラム処理を行うパラメータを取得し、元画像補正手段は、元画像の輝度信号のみについてレティネックス値求め、そのレティネックス値を正規化パラメータ設定手段により設定された上限値および下限値に基づいて正規化し、その正規化レティネックス値と、元画像の輝度信号とに基づいて補正を行うとともにカラー画素値に戻し、そのカラー画素値をヒストグラム処理パラメータ取得手段により取得されたパラメータに基づいてヒストグラム補正するので、カラー画像を構成するRGB値それぞれについてレティネックス処理を行う場合に比べて、処理が速いとともに、色ずれが発生しないという効果がある。   According to the image processing apparatus of the fifth aspect, in addition to the effect produced by the image processing apparatus of the fourth aspect, the reduced Retinex image forming unit forms a reduced Retinex image only for the luminance signal of the reduced image, and The image correction means normalizes the reduced Retinex image formed by the reduced Retinex image forming means based on the upper limit value and the lower limit value set by the normalization parameter setting means, and the normalized value and the reduced image After correcting the reduced image based on the luminance signal, the reduced image is returned to the color image, and the histogram processing parameter acquisition means sums up the frequency of each pixel value in the entire range taken by the pixel values of the color image corrected by the reduced image correction means. The parameter for performing the histogram processing is acquired, and the original image correction means performs the retinex only for the luminance signal of the original image. Obtain the value, normalize the Retinex value based on the upper limit value and the lower limit value set by the normalization parameter setting means, perform correction based on the normalized Retinex value and the luminance signal of the original image, and color Returning to the pixel value, the color pixel value is subjected to histogram correction based on the parameter acquired by the histogram processing parameter acquisition means, so the processing is faster than when Retinex processing is performed for each of the RGB values constituting the color image. In addition, there is an effect that no color misregistration occurs.

請求項6記載の画像処理装置によれば、請求項4または5記載の画像処理装置の奏する効果に加え、正規化パラメータ設定手段は、縮小レティネックス画像形成手段により形成された縮小レティネックス画像の全画素が取る値の最大値から最小値の範囲の値のうち、全画素に対する所定の割合の画素を含むクリップ範囲の上限値と下限値とを正規化パラメータとして設定するので、決定される上限値および下限値は、元画像を用いて決定した上限値および下限値とほぼ同一の値を得ることができる。したがって、この上限値および下限値の精度を維持したままで高速で求めることができるという効果がある。なお、正規化パラメータとして上限値、下限値ではなく最大値、最小値を用いた場合は、元画像により求めた値と、縮小画像により求めた値とが大きく異なる場合がある。   According to the image processing apparatus of the sixth aspect, in addition to the effect produced by the image processing apparatus of the fourth or fifth aspect, the normalization parameter setting unit is configured to reduce the reduced Retinex image formed by the reduced Retinex image forming unit. Since the upper and lower limit values of the clip range including a predetermined percentage of all the pixels in the range from the maximum value to the minimum value of all pixels are set as normalization parameters, the upper limit determined As the value and the lower limit, it is possible to obtain substantially the same value as the upper limit and the lower limit determined using the original image. Therefore, there is an effect that the upper limit value and the lower limit value can be obtained at a high speed while maintaining the accuracy. When the maximum value and the minimum value are used as normalization parameters instead of the upper limit value and the lower limit value, the value obtained from the original image and the value obtained from the reduced image may be greatly different.

以下、本発明の好ましい実施形態について添付図面を参照して説明する。図1は、本実施形態の画像処理を行う機能を有するプリンタ1の電気的な構成を示したブロック図である。本実施形態においては、プリンタ1に搭載された画像処理プログラムは、パーソナルコンピュータ(以下「PC」と称する)2や、デジタルカメラ21や、外部メディア20から入力された画像データ(原画像データなど)に対しレティネックス処理(Retinex処理)およびヒストグラム処理を実行して、画像データの逆光画像部分などの低画質領域の補正を実行するように構成されている。   Hereinafter, preferred embodiments of the present invention will be described with reference to the accompanying drawings. FIG. 1 is a block diagram illustrating an electrical configuration of a printer 1 having a function of performing image processing according to the present embodiment. In the present embodiment, the image processing program installed in the printer 1 is image data (original image data or the like) input from the personal computer (hereinafter referred to as “PC”) 2, the digital camera 21, or the external medium 20. On the other hand, a Retinex process (Retinex process) and a histogram process are executed to correct a low image quality region such as a backlight image portion of image data.

図1に示すように、プリンタ1には、CPU11、ROM12、RAM13、印刷ヘッドなどから構成され、印刷媒体(例えば、紙媒体など)への印刷(出力)を行う印刷部15、出力画像サイズなどの入力値をユーザが入力可能なユーザ操作部(例えば、テンキーなど)を有する操作パネル16とを備えている。   As shown in FIG. 1, the printer 1 includes a CPU 11, a ROM 12, a RAM 13, a print head, and the like, and includes a printing unit 15 that performs printing (output) on a print medium (for example, a paper medium), an output image size, and the like. And an operation panel 16 having a user operation unit (for example, a numeric keypad) through which the user can input the input value.

また、プリンタ1は、ケーブル5を介してPC2と接続可能なインターフェイス(以下「I/F」と称する)17と、ケーブル6を介してデジタルカメラ21と接続可能なI/F18と、外部メディア20(例えば、SDメモリカード、メモリスティックなどのフラッシュメモリにより構成される)を着脱自在に装着可能な外部メディアスロット19とを備えている。これらのI/F17、18により行われる通信方法としてUSB(Universal Serial Bus)が使用される。   The printer 1 includes an interface (hereinafter referred to as “I / F”) 17 that can be connected to the PC 2 via the cable 5, an I / F 18 that can be connected to the digital camera 21 via the cable 6, and an external medium 20. And an external media slot 19 that can be detachably mounted (for example, a flash memory such as an SD memory card or a memory stick). As a communication method performed by these I / Fs 17 and 18, USB (Universal Serial Bus) is used.

よって、プリンタ1は、PC2に記憶されている画像データをケーブル5及びI/F17を介して入力することが可能であると共に、デジタルカメラ21によって撮影された画像データをケーブル6及びI/F18を介して入力することが可能である。さらに、外部メディアスロット19に装着された外部メディア20から、その外部メディア20に記憶されている画像データを入力することが可能である。   Therefore, the printer 1 can input the image data stored in the PC 2 via the cable 5 and the I / F 17 and also the image data photographed by the digital camera 21 via the cable 6 and the I / F 18. It is possible to input via. Further, it is possible to input image data stored in the external medium 20 from the external medium 20 mounted in the external media slot 19.

CPU11は、プリンタ1全体を制御する演算処理装置である。ROM12は、CPU11により実行される各種制御プログラムやそのプログラムを実行する際に用いられる固定値などを記憶するものであり、レティネックス処理やヒストグラム処理などの画像の処理を行う画像処理プログラムを記憶する画像処理プログラムメモリ12aや、印刷を行うための印刷制御プログラムを記憶する印刷制御プログラムメモリ12b等が備えられている。   The CPU 11 is an arithmetic processing device that controls the entire printer 1. The ROM 12 stores various control programs executed by the CPU 11 and fixed values used when the programs are executed, and stores an image processing program for performing image processing such as Retinex processing and histogram processing. An image processing program memory 12a, a print control program memory 12b for storing a print control program for performing printing, and the like are provided.

RAM13は、制御プログラムがCPU11により実行される際に必要な各種レジスタ群などが記憶されるワーキングエリアや、処理中のデータを一時的に格納するテンポラリエリア等を有しランダムにアクセスできる書き換え可能なメモリであり、元画像データを記憶する元画像メモリ13aと、元画像を縮小し、縮小した画像のレティネックス処理において求められる反射率を記憶する縮小レティネックス画像メモリ13bと、ヒストグラム処理において各画素値の頻度が記憶されるヒストグラムメモリ13c等を備えている。   The RAM 13 has a working area for storing various register groups required when the control program is executed by the CPU 11, a temporary area for temporarily storing data being processed, and the like, and can be accessed at random. An original image memory 13a for storing original image data; a reduced Retinex image memory 13b for storing the reflectance required in the Retinex processing of the reduced image after reducing the original image; and each pixel in the histogram processing A histogram memory 13c for storing the frequency of values is provided.

元画像データメモリ13aは、PC2、デジタルカメラ21、及び外部メディア20から、それぞれ、I/F17、I/F18、及び外部メディアスロット19を介して入力した画像データを記憶するものである。なお、本実施形態では、元画像データ及び出力画像データはいずれも、RGB値から構成され、これらの各RGB値は、「0」〜「255」の範囲の値である。   The original image data memory 13 a stores image data input from the PC 2, the digital camera 21, and the external media 20 via the I / F 17, I / F 18, and external media slot 19, respectively. In the present embodiment, both the original image data and the output image data are composed of RGB values, and these RGB values are values in the range of “0” to “255”.

RGB値は、光の3原色である赤を表すR値と、緑を表すG値と、青を示すB値とを構成成分とする値である。光の3原色の混色により各種の色は生成されるので、入力画像の各画素の色は、R値とG値とB値との組合せ(RGB値)により1の色(色相や階調など)が示される。このRGB値の値が大きいほど、輝度(明度)は高くなる。   The RGB value is a value having as constituent components an R value representing red, which is the three primary colors of light, a G value representing green, and a B value representing blue. Since various colors are generated by mixing the three primary colors of light, the color of each pixel of the input image is one color (hue, gradation, etc.) by a combination of R value, G value, and B value (RGB value). ) Is displayed. The luminance (lightness) increases as the RGB value increases.

縮小レティネックス画像メモリ13bは、元画像を縮小し、その縮小した画像の輝度信号のみについてレティネックス処理において求められる反射率Rs(x,y)を記憶するメモリである。元画像を縮小する方法としては、縮小する画像の画素に対応する元画像の位置に最も近い画素の値をサンプリングし、そのサンプリングした画素の値をそのまま用いる最近傍(Nearest Neighbor)法や、縮小する画像の画素に対応する元画像の位置の周囲の画素を用いて補間演算を行うバイキュービック法や、平均画素法などが知られている。画質より処理速度を優先する場合は、最近傍法が用いられ、処理速度より画質を優先する場合は、バイキュービック法や、平均画素法が用いられる。   The reduced Retinex image memory 13b is a memory that stores the reflectance Rs (x, y) obtained in the Retinex process for only the luminance signal of the reduced image by reducing the original image. As a method for reducing the original image, the value of the pixel closest to the position of the original image corresponding to the pixel of the image to be reduced is sampled, and the value of the sampled pixel is used as it is. There are known a bicubic method for performing an interpolation operation using pixels around a position of an original image corresponding to a pixel of an image to be performed, an average pixel method, and the like. When the processing speed is prioritized over the image quality, the nearest neighbor method is used, and when the image quality is prioritized over the processing speed, the bicubic method or the average pixel method is used.

これらいずれかの方法により元画像が縮小され、その縮小された画像の各画素(ピクセル)について反射率が上述の数式1を用いて演算され、この縮小レティネックス画像メモリ13bに記憶される。   The original image is reduced by any one of these methods, and the reflectance is calculated for each pixel (pixel) of the reduced image using Equation 1 described above, and stored in the reduced Retinex image memory 13b.

ヒストグラムメモリ13cは、レティネックス処理を完了した後のヒストグラム処理において、画像のRGB値が、0〜255の各整数値を取る頻度(画素数)が集計され、その頻度を集計するためのメモリである。ヒストグラムが作成されると、そのヒストグラムに基づいて、ヒストグラム処理を行うための上限値Uおよび下限値D、メディアン値などが定められる。   The histogram memory 13c is a memory for summing up the frequency (number of pixels) in which the RGB value of the image takes each integer value from 0 to 255 in the histogram processing after completing the Retinex processing, and summing up the frequencies. is there. When the histogram is created, an upper limit value U, a lower limit value D, a median value, and the like for performing histogram processing are determined based on the histogram.

次に、図2および図3を参照して、CPU11により実行される画像処理について説明する。図2および図3は、画像処理を示すフローチャートである。図2に示す処理は、いわゆる前処理と呼ばれる処理であり、この処理では、反射率Rの正規化を行うためのクリップ範囲が設定される。なお、この前処理が行われている間は、画像の出力が行われない。   Next, image processing executed by the CPU 11 will be described with reference to FIGS. 2 and 3. 2 and 3 are flowcharts showing the image processing. The process shown in FIG. 2 is a so-called pre-process, and in this process, a clip range for normalizing the reflectance R is set. Note that no image is output while this pre-processing is being performed.

この前処理では、まず、元画像データをPC2やデジタルカメラ21から読み込み、RAM13の元画像メモリ13aに記憶する(S1)。次に、元画像を縮小して縮小画像を形成し、その縮小画像の各画素について輝度信号Yと色信号Cb,Crに変換する(S2)。   In this preprocessing, first, original image data is read from the PC 2 or the digital camera 21 and stored in the original image memory 13a of the RAM 13 (S1). Next, the original image is reduced to form a reduced image, and each pixel of the reduced image is converted into a luminance signal Y and color signals Cb and Cr (S2).

縮小画像を形成する方法としては、最近傍法や平均画素法が用いられ、輝度信号Yおよび色信号Cb,Crは、次式により演算される。   As a method for forming a reduced image, a nearest neighbor method or an average pixel method is used, and the luminance signal Y and the color signals Cb and Cr are calculated by the following equations.

Figure 0004793175
演算された輝度信号および色信号をRAM13などに一時記憶し、後の処理で使用するようにしてもよいが、記憶容量を削減したい場合には、これらを記憶せずに、必要な場合、元画像から画素値を読み出して上式により演算で求めてもよい。
Figure 0004793175
The calculated luminance signal and color signal may be temporarily stored in the RAM 13 or the like and used in later processing. However, if it is desired to reduce the storage capacity, these are not stored, and if necessary, the original The pixel value may be read from the image and calculated by the above formula.

次に、上式により演算された輝度信号Yについて、反射率Rs(x,y)を算出する。なお、「s」は、縮小画像についての接尾辞であり、元画像については、接尾辞を付さないものとする。反射率Rsは、縮小画像の各画素の輝度値をIs(x,y)、縮小画像用のフィルタをFs(x,y)として、次式により演算される。   Next, the reflectance Rs (x, y) is calculated for the luminance signal Y calculated by the above equation. Note that “s” is a suffix for the reduced image, and no suffix is added to the original image. The reflectance Rs is calculated by the following equation, assuming that the luminance value of each pixel of the reduced image is Is (x, y) and the filter for the reduced image is Fs (x, y).

Figure 0004793175
なお、「*」は、畳み込み演算(コンボリューション)を示し、logは、eを底とする自然対数である。
Figure 0004793175
Note that “*” indicates a convolution operation (convolution), and log is a natural logarithm with e as the base.

次に、上記演算により求められた反射率Rs(x,y)をRAM13の縮小レティネックス画像メモリ13bに記憶する(S4)。   Next, the reflectance Rs (x, y) obtained by the above calculation is stored in the reduced Retinex image memory 13b of the RAM 13 (S4).

次に、Rs(x,y)を最大値および最小値と比較する(S5)。詳細には、最初の座標について求めた反射率Rs(x,y)を最大値および最小値とし、そのつぎから求めた反射率Rs(x,y)と最大値および最小値とをそれぞれ比較し、今回求めた反射率Rs(x,y)が、最大値より大きい場合は、今回求めた反射率Rs(x,y)を新たな最大値とし、今回求めた反射率Rs(x,y)が、最小値より小さい場合は、今回求めた反射率Rs(x,y)を新たな最小値とし、今回求めた反射率Rs(x,y)が、最大値より小さく、最小値より大きい場合は、最大値、最小値を変更しないという処理である。   Next, Rs (x, y) is compared with the maximum value and the minimum value (S5). Specifically, the reflectance Rs (x, y) obtained for the first coordinate is set as the maximum value and the minimum value, and the reflectance Rs (x, y) obtained from the next is compared with the maximum value and the minimum value, respectively. When the reflectance Rs (x, y) obtained this time is larger than the maximum value, the reflectance Rs (x, y) obtained this time is set as a new maximum value, and the reflectance Rs (x, y) obtained this time is obtained. Is smaller than the minimum value, the reflectance Rs (x, y) obtained this time is set as a new minimum value, and the reflectance Rs (x, y) obtained this time is smaller than the maximum value and larger than the minimum value. Is a process of not changing the maximum value and the minimum value.

次に、縮小画像の全ての座標についてS3〜S5の処理を行ったか否かを判断し(S6)、まだ、未処理の座標がある場合は(S6:No)、S3の処理に戻り、全ての座標についての処理を終了した場合は(S6:Yes)、S5の処理により求めた最大値と最小値に基づいて、反射率Rs(x,y)を正規化し、ヒストグラムを形成する(S7)。   Next, it is determined whether or not the processing of S3 to S5 has been performed for all the coordinates of the reduced image (S6). If there are still unprocessed coordinates (S6: No), the processing returns to S3 and all of them are performed. When the process for the coordinates of (5) is completed (S6: Yes), the reflectance Rs (x, y) is normalized based on the maximum value and the minimum value obtained by the process of S5, and a histogram is formed (S7). .

次に、その形成されたヒストグラムからメディアン値を求め(S8)、そのメディアン値とヒストグラムとから反射率Rs(x,y)のクリップされる範囲(クリップ範囲)を定める(S9)。このクリップ範囲は、例えば、メディアン値より大きい値で、全標本の45%の標本が含まれる上限値をクリップ範囲の上限値とし、メディアン値より小さい値で、全標本の45%が含まれる下限値をクリップ範囲の下限値とするものである。   Next, a median value is obtained from the formed histogram (S8), and a clipped range (clip range) of the reflectance Rs (x, y) is determined from the median value and the histogram (S9). This clip range is, for example, a value larger than the median value, and an upper limit value that includes 45% of all samples is the upper limit value of the clip range, and a lower value that is less than the median value and includes 45% of all samples. The value is the lower limit value of the clip range.

以上の前処理により、元画像を縮小した縮小画像の反射率により構成される縮小レティネックス画像を形成し、その縮小レティネックス画像から、元画像の反射率を正規化する際のクリップ範囲が求められる。このことにより、クリップ範囲を求めるための演算の回数が、元画像について求める演算の回数より非常に少なくすることができ、処理速度が速くなる。また、縮小された画像のレティネックス画像を記憶するので、元画像のレティネックス画像を記憶する場合に比べ、少ない記憶容量で処理することができるという利点がある。また、縮小画像を用いて求めたクリップ範囲と、元画像を用いて求めたクリップ範囲とは、大差がない。次表は、縮小画像により求めたクリップ範囲(上限値と下限値)と元画像により求めたクリップ範囲との差異を示すものである。   Through the above pre-processing, a reduced Retinex image composed of the reduced image reflectance obtained by reducing the original image is formed, and the clip range for normalizing the reflectance of the original image is obtained from the reduced Retinex image. It is done. As a result, the number of calculations for obtaining the clip range can be made much smaller than the number of calculations for the original image, and the processing speed is increased. Further, since the Retinex image of the reduced image is stored, there is an advantage that the processing can be performed with a small storage capacity compared with the case of storing the Retinex image of the original image. Further, there is no large difference between the clip range obtained using the reduced image and the clip range obtained using the original image. The following table shows the difference between the clip range (upper limit and lower limit) obtained from the reduced image and the clip range obtained from the original image.

Figure 0004793175
この表が示すように、元画像により求めた最大値は、2.712、最小値は、−4.063であり、縮小画像により求めた最大値は、1.729、最小値は、−2.607である。よって、元画像により求めた最大値と縮小画像により求めた最大値との差は、0.983であり、元画像により求めた最小値と縮小画像により求めた最小値との差は、1.456であって、かなり大きな差が認められる。
Figure 0004793175
As shown in this table, the maximum value obtained from the original image is 2.712, the minimum value is −4.063, the maximum value obtained from the reduced image is 1.729, and the minimum value is −2 .607. Therefore, the difference between the maximum value obtained from the original image and the maximum value obtained from the reduced image is 0.983, and the difference between the minimum value obtained from the original image and the minimum value obtained from the reduced image is 1. 456, and a considerable difference is recognized.

一方、元画像により求めたクリップ範囲の上限値は、0.825、下限値は、−0.822であり、縮小画像により求めた上限値は、0.742、下限値は、−0.755である。よって、元画像により求めた上限値と縮小画像により求めた上限値との差は、0.083であり、元画像により求めた下限値と縮小画像により求めた下限値との差は、0.067であって、これらの差が小さいことが分かる。   On the other hand, the upper limit value of the clip range obtained from the original image is 0.825, the lower limit value is −0.822, the upper limit value obtained from the reduced image is 0.742, and the lower limit value is −0.755. It is. Therefore, the difference between the upper limit value obtained from the original image and the upper limit value obtained from the reduced image is 0.083, and the difference between the lower limit value obtained from the original image and the lower limit value obtained from the reduced image is 0. 0. 067, and it can be seen that these differences are small.

次に、図2に示す処理により求められたクリップ範囲に基づいて行う後処理である元画像のレティネックス処理について説明する。図3は、元画像のレティネックス処理を示すフローチャートである。なお、この後処理では、元画像の各画素について処理が行われ、処理された画素値は、順次印刷部15に出力される。   Next, the Retinex process of the original image, which is a post process performed based on the clip range obtained by the process shown in FIG. 2, will be described. FIG. 3 is a flowchart showing the original image Retinex processing. In this post-processing, each pixel of the original image is processed, and the processed pixel value is sequentially output to the printing unit 15.

まず、元画像について、反射率R(x,y)を算出する(S11)。次に、縮小画像を用いて求めたクリップ範囲に基づいて、R(x,y)を正規化し、正規化反射率(正規化レティネックス値)refle(x,y)を得る(S12)。   First, the reflectance R (x, y) is calculated for the original image (S11). Next, based on the clip range obtained using the reduced image, R (x, y) is normalized to obtain a normalized reflectance (normalized Retinex value) refle (x, y) (S12).

次に、このrefle(x,y)を用いて、次式により輝度についてレティネックス処理を行った画素の値Out(x,y)を得る(S13)。   Next, using this refle (x, y), a pixel value Out (x, y) subjected to Retinex processing for luminance is obtained by the following equation (S13).

Figure 0004793175
次に、このOut(x,y)と、色信号Cb、Crとに基づいて、RGB値に変換する(S14)。この変換は、次式により算出される。
Figure 0004793175
Next, based on this Out (x, y) and the color signals Cb and Cr, conversion into RGB values is performed (S14). This conversion is calculated by the following equation.

Figure 0004793175
以上の処理により元画像の輝度信号にレティネックス処理が施され、色信号に基づいてRGB値に戻した画素値が求められる。次に、この処理された画素値を印刷部15に出力する(S15)。よって、前処理により、正規化を行うクリップ範囲が特定されているので、後処理では、順次各画素について処理を行い印刷部15に出力することができる。その結果、処理を開始してから、印刷が開始されるまでの時間を短縮することができる。
Figure 0004793175
Through the above processing, the Retinex processing is performed on the luminance signal of the original image, and the pixel value returned to the RGB value is obtained based on the color signal. Next, the processed pixel value is output to the printing unit 15 (S15). Therefore, since the clip range to be normalized is specified by the preprocessing, each pixel can be sequentially processed and output to the printing unit 15 in the postprocessing. As a result, the time from the start of processing to the start of printing can be shortened.

次に、元画像の全画素について処理を終了したか否かを判断し(S16)、まだ処理を終了していない画素がある場合は(S16:No)、S11の処理に戻り、全ての画素について処理を終了した場合は(S16:Yes)、この後処理を終了する。   Next, it is determined whether or not the process has been completed for all the pixels of the original image (S16). If there is a pixel that has not been processed yet (S16: No), the process returns to S11 and all the pixels are processed. When the process is finished for (S16: Yes), the process is finished.

以上、第1の実施形態について説明したように、元画像を縮小した縮小画像の輝度信号についてレティネックス処理を行い、その縮小されたレティネックス画像からクリップ範囲を求めて、そのクリップ範囲に基づいて、元画像についてレティネックス処理を行うので、レティネックス画像を記憶するメモリの記憶容量を小さくすることができるとともに、クリップ範囲を求める処理を高速で行うことができる。また、前処理において、クリップ範囲が求められ、後処理においては、前処理において求められたクリップ範囲に基づいて、順次元画像の画素についてレティネックス処理を行い、出力することができるので、処理を開始してから出力が開始されるまでの時間を短縮することができる。   As described above, as described in the first embodiment, the Retinex process is performed on the luminance signal of the reduced image obtained by reducing the original image, the clip range is obtained from the reduced Retinex image, and based on the clip range. Since the Retinex processing is performed on the original image, the storage capacity of the memory for storing the Retinex image can be reduced, and the processing for obtaining the clip range can be performed at high speed. In addition, the clip range is obtained in the pre-processing, and in the post-processing, the Retinex process can be performed on the pixels of the forward dimension image based on the clip range obtained in the pre-processing, and the processing can be performed. The time from the start to the start of output can be shortened.

次に、第2の実施形態について説明する。レティネックス処理を行うと、ダイナミックレンジが狭くなったり、暗部が明るくなりすぎて、不自然になる場合がある。そこで、レティネックス処理を行った後、ヒストグラム処理を行うと画質を改善することができる。第2の実施形態では、レティネックス処理を行った後、ヒストグラム処理を行う。   Next, a second embodiment will be described. When Retinex processing is performed, the dynamic range may become narrow, or the dark part may become too bright, which may cause unnaturalness. Therefore, image quality can be improved by performing histogram processing after performing Retinex processing. In the second embodiment, histogram processing is performed after performing Retinex processing.

図4を参照してヒストグラム処理について説明する。図4(a)は、画像の一例であり、図4(b)は、その画像から形成したヒストグラムである。このヒストグラムは、画素値がとる値の全範囲の各値について、頻度(画素数)を集計したものである。カラー画像の場合には、R,G,Bの各値を8ビット、すなわち0から255までの値をとる場合には、0から255の各整数値について、その値となる画素のR,G,B値について1を加算することにより集計する。例えば、ある画素のR,G,B値が(100,200,200)である場合には、100の値に1を、200の値に2を加算するというようにして集計する。   The histogram processing will be described with reference to FIG. FIG. 4A is an example of an image, and FIG. 4B is a histogram formed from the image. This histogram is a total of frequencies (number of pixels) for each value in the entire range of values taken by pixel values. In the case of a color image, each value of R, G, B is 8 bits, that is, when a value from 0 to 255 is taken, for each integer value from 0 to 255, R, G of the pixel that is the value , B values are added up by adding 1. For example, when the R, G, and B values of a certain pixel are (100, 200, 200), the values are aggregated by adding 1 to the value of 100 and 2 to the value of 200.

このようにして作成されたヒストグラムにおいて、明部と暗部とを除く割合(カット割合)が設定され、その割合から上限値Uと下限値Dとが求められる。例えば、明部と暗部とを除く割合として、それぞれ3%とした場合に、明部に含まれる画素数が全画素数の3倍(1画素につき、R,G,Bの3つの値をとる)の3%に当たる数を、最大値255から上限値Uまでに含むように上限値Uを設定し、同様に、暗部に含まれる画素数が全画素数の3倍の3%に当たる数を、最小値0から下限値Dまでに含むように下限値Uを設定する。   In the histogram created in this way, a ratio (cut ratio) excluding the bright part and the dark part is set, and the upper limit value U and the lower limit value D are obtained from the ratio. For example, when the ratio excluding the bright part and the dark part is 3%, the number of pixels included in the bright part is three times the total number of pixels (three values of R, G, and B per pixel). ), The upper limit value U is set so as to include the number corresponding to 3% from the maximum value 255 to the upper limit value U. Similarly, the number corresponding to 3% of the number of pixels included in the dark portion is 3 times the total number of pixels. The lower limit value U is set so as to include from the minimum value 0 to the lower limit value D.

このようにして、上限値Uおよび下限値Dを設定すると、画素値の最小値から下限値Dまでの範囲の値を最小値とし、上限値Uから最大値までの範囲の値を最大値とし、下限値Dから上限値Uまでの範囲の値を線形、または非線形な関数で補正する。   In this way, when the upper limit value U and the lower limit value D are set, the value in the range from the minimum pixel value to the lower limit value D is set as the minimum value, and the value in the range from the upper limit value U to the maximum value is set as the maximum value. The value in the range from the lower limit value D to the upper limit value U is corrected with a linear or non-linear function.

即ち、入力する画素値をinput、補正した画素値をoutput、画素値が取る範囲を0から255、γ2を定数とした場合に、
inputが、下限値D以下の場合は、0、
inputが、上限値U以上の場合は、255
inputが、下限値Dより大きく上限値Uより小さい場合は、
a=(input−D)/(U−D)
That is, when the input pixel value is input, the corrected pixel value is output, the range that the pixel value takes is 0 to 255, and γ2 is a constant,
0 if input is less than or equal to lower limit D
255 if input is greater than or equal to upper limit U
When input is larger than the lower limit value D and smaller than the upper limit value U,
a = (input-D) / (UD)

Figure 0004793175
この式でγ2=1とすると、outputは、下限値と上限値との間の値を線形に拡大することになる。
Figure 0004793175
When γ2 = 1 in this equation, output is a linear expansion of the value between the lower limit value and the upper limit value.

レティネックス処理における数式5のγ1の値に応じて設定してもよい。このγ1の値を大きくすると、より明るく補正されることになり、γの値が小さいと、あまり補正されないことになる。したがって、γ1が大きい場合は、ヒストグラム処理における下限値Uの値を大きく(暗部のカット量またはカット割合を大きく)し、全体的に暗い方へ画素値を変更すると画像に締まりがでる。   You may set according to the value of (gamma) 1 of Numerical formula 5 in Retinex processing. If the value of γ1 is increased, the correction is performed brighter. If the value of γ is small, the correction is not performed much. Therefore, when γ1 is large, the lower limit value U in the histogram processing is increased (the cut amount or the cut ratio of the dark portion is increased), and the pixel value is changed to the darker side as a whole, thereby tightening the image.

また、レティネックス処理により、逆光などの部分は、明るく補正されるが、全体的にも明るく補正され、元の画像とは、異なった印象となる。そこでレティネックス処理におけるガンマ補正とは逆のガンマ補正をヒストグラム処理によかけることにより、明るく成りすぎた部分を自然な状態に戻すことができる。   In addition, the portion of backlight or the like is corrected brightly by Retinex processing, but is corrected brightly as a whole, resulting in an impression different from the original image. Therefore, by applying a gamma correction opposite to the gamma correction in the Retinex process by the histogram process, it is possible to return the brightened part to a natural state.

また、レティネックス処理におけるガンマ補正に用いたガンマγ1に応じて、ヒストグラム処理におけるガンマγ2を次式により求めるようにしてもよい。すなわち、
γ2=(γ1−1.0)/A+1.0
(但し、Aは、5から20の値)とする。
Further, in accordance with gamma γ1 used for gamma correction in Retinex processing, gamma γ2 in histogram processing may be obtained by the following equation. That is,
γ2 = (γ1-1.0) /A+1.0
(Where A is a value from 5 to 20).

レティネックス処理前のメディアン値にレティネックス処理後のメディアン値が近づくようにγ2を設定する。   Γ2 is set so that the median value after Retinex processing approaches the median value before Retinex processing.

元の画素値をinput、補正した画素値をoutput、画素値が取る全範囲をB、画素値がとる全範囲の値の最大値をMAX、最小値をMIN、クリップ範囲の上限値をU、下限値をD、元画像のメディアン値をOM、前記レティネックス処理ステップにより処理された画像のメディアン値をRM、定数をαとした場合に、
inputが、下端範囲(D以下)の場合は、MINとし、
inputが、上端範囲(U以上)の場合は、MAXとし、
inputが、上記範囲以外の場合は、
a=(input−D)/(U−D)
outputをaのγ2べき乗にBを乗じた値とし、
γ2=log(target/MAX)/log(RM/MAX)
但し、target=(OM×α+RM)/(1+α)
ここで、定数αを1とした場合は、レティネックス処理前のメディアン値とレティネックス処理後のメディアン値との中間にtargetが設定され、定数αの値を1より大きくするとtargetが元画像のメディアン値に近づき、定数αの値を1より小さい値とすると元画像のメディアン値から離れるように設定される。なお、定数αは、予め所定の値に設定してもよいし、使用者が任意に設定できるようにしてもよい。
The original pixel value is input, the corrected pixel value is output, the whole range that the pixel value takes is B, the maximum value of the whole range that the pixel value takes is MAX, the minimum value is MIN, the upper limit value of the clip range is U, When the lower limit is D, the median value of the original image is OM, the median value of the image processed by the Retinex processing step is RM, and the constant is α,
If input is in the lower end range (D or less), it is set to MIN.
When input is the upper end range (U or more), it is set to MAX,
If input is outside the above range,
a = (input-D) / (UD)
Let output be the value of a raised to the power of γ2 by B,
γ2 = log (target / MAX) / log (RM / MAX)
However, target = (OM × α + RM) / (1 + α)
Here, when the constant α is 1, the target is set in the middle between the median value before Retinex processing and the median value after Retinex processing. If the value of the constant α is larger than 1, the target becomes the original image. When the value approaches the median value and the constant α is set to a value smaller than 1, the median value is set so as to be separated from the median value of the original image. The constant α may be set to a predetermined value in advance or may be arbitrarily set by the user.

図5は、第2の実施形態における前処理を示すフローチャートである。この前処理のうち、S1〜S9の処理については、図2に示す処理と同一であるので、その説明を省略する。   FIG. 5 is a flowchart showing pre-processing in the second embodiment. Among the pre-processing, the processing of S1 to S9 is the same as the processing shown in FIG.

S9の処理の次に、縮小レティネックスメモリ13bに記憶したRs(x,y)をS9の処理で求められたクリップ範囲で正規化し、refles(x,y)を数式4により求め(S21)、
次に、Outs(x,y)を次式により求める(S22)。
Subsequent to the process of S9, Rs (x, y) stored in the reduced retinex memory 13b is normalized with the clip range obtained in the process of S9, and refles (x, y) is obtained by Expression 4 (S21).
Next, Outs (x, y) is obtained by the following equation (S22).

Figure 0004793175
次に、このOuts(x,y)を輝度信号として、数式6によりRGB値に変換し、ヒストグラムに登録する(S23)。このヒストグラムの登録とは、RGB値それぞれが取る値は、0から255までの整数値であり、ここで得られた、R値、G値、B値の各値に対応する値の頻度に1を加算することである。加算された値は、ヒストグラムメモリ13cに記憶される。
Figure 0004793175
Next, this Outs (x, y) is converted into an RGB value by Equation 6 using the luminance signal as a luminance signal and registered in the histogram (S23). In this histogram registration, each RGB value takes an integer value from 0 to 255, and the frequency of the value corresponding to each of the R value, G value, and B value obtained here is one. Is to add. The added value is stored in the histogram memory 13c.

このS21からS23までの処理を縮小画像の全ての座標について処理を行ったか否かを判断し(S24)、まだ処理を行っていない座標が残っている場合は(S24:No)、S21の処理に戻り、全ての座標について処理を行った場合は(S24:Yes)、ヒストグラムメモリ13cに形成されたヒストグラムから、ヒストグラム処理におけるパラメータを取得する(S25)。このヒストグラム処理におけるパラメータとは、上記した通り、下限値D、上限値U、または、ガンマ値γ2である。   It is determined whether or not the processing from S21 to S23 has been performed for all the coordinates of the reduced image (S24). If there are coordinates that have not yet been processed (S24: No), the processing of S21 is performed. Returning to FIG. 5, if all the coordinates have been processed (S24: Yes), parameters in the histogram processing are acquired from the histogram formed in the histogram memory 13c (S25). As described above, the parameters in this histogram processing are the lower limit value D, the upper limit value U, or the gamma value γ2.

以上の処理により元画像を縮小した縮小画像を用いて、レティネックス処理における正規化パラメータと、レティネックス処理の後、実行されるヒストグラム処理におけるパラメータとが取得される。   Using the reduced image obtained by reducing the original image by the above processing, a normalization parameter in the Retinex process and a parameter in the histogram process that is executed after the Retinex process are acquired.

次に、これらのパラメータが予め設定された後の、後処理について図6を参照して説明する。図6は、後処理を示すフローチャートである。   Next, post-processing after these parameters are set in advance will be described with reference to FIG. FIG. 6 is a flowchart showing post-processing.

後処理では、まず、元画像の画素について輝度信号を求め、その輝度信号について反射率R(x,y)を数式1により算出し(S31)、クリップ範囲に基づいてR(x,y)を正規化したrefle(x,y)を求める(S32)。   In the post-processing, first, a luminance signal is obtained for a pixel of the original image, a reflectance R (x, y) is calculated for the luminance signal by Equation 1 (S31), and R (x, y) is calculated based on the clip range. Normalized refle (x, y) is obtained (S32).

次に、Out(x,y)を数式5により算出し(S33)、算出したOut(x,y)を輝度信号として数式6によりRGB値に戻し(S34)、そのRGB値をS25で求めたパラメータに基づいてヒストグラム補正を行い(S35)、印刷部15に出力する(S36)。   Next, Out (x, y) is calculated by Equation 5 (S33), and the calculated Out (x, y) is returned to the RGB value by Equation 6 as a luminance signal (S34), and the RGB value is obtained in S25. Histogram correction is performed based on the parameters (S35) and output to the printing unit 15 (S36).

次に、元画像の全画素についての処理を終了したか否かを判断し(S37)、まだ、処理していない画素がある場合は(S37:No)、S31の処理に戻り、全画素についての処理を終了した場合は(S37:Yes)、この後処理を終了する。   Next, it is determined whether or not the processing for all the pixels of the original image has been completed (S37). If there is a pixel that has not yet been processed (S37: No), the processing returns to S31 and all pixels are processed. When the above process is completed (S37: Yes), the subsequent process is terminated.

以上、説明したように第2の実施形態によれば、カラー画像の輝度についてレティネックス処理を行い、カラー画像に戻した後、ヒストグラム処理を行う。このことにより、画像のダイナミックレンジを広げ、より高画質の画像を得ることができる。ヒストグラム処理を行う場合は、レティネックス処理におけるパラメータに応じてヒストグラム処理におけるパラメータを設定することにより、より良く画質を向上させることができる。   As described above, according to the second embodiment, Retinex processing is performed on the luminance of a color image, and after returning to a color image, histogram processing is performed. As a result, the dynamic range of the image can be expanded and a higher quality image can be obtained. In the case of performing the histogram processing, the image quality can be further improved by setting the parameters in the histogram processing according to the parameters in the Retinex processing.

なお、請求項に記載の縮小レティネックス画像形成ステップおよび縮小レティネックス画像形成手段は、図5に示すフローチャートのS3の処理が該当し、正規化パラメータ設定ステップおよび正規化パラメータ設定手段は、図5に示すフローチャートのS7〜S9の処理が該当し、縮小画像補正ステップおよび縮小画像補正手段は、図5に示すフローチャートのS21〜S23の処理が該当し、元画像補正ステップおよび元画像補正手段は、図6に示すフローチャートの処理が該当する。   Note that the reduced Retinex image forming step and the reduced Retinex image forming means described in the claims correspond to the processing of S3 in the flowchart shown in FIG. 5, and the normalization parameter setting step and the normalization parameter setting means are the same as those in FIG. 5 corresponds to the processing of S7 to S9 in the flowchart shown in FIG. 5, the reduced image correction step and the reduced image correction means correspond to the processing of S21 to S23 in the flowchart shown in FIG. 5, and the original image correction step and the original image correction means include The process of the flowchart shown in FIG.

以上、実施形態に基づいて本発明を説明したが、本発明は上記各実施形態に何ら限定されるものでなく、本発明の趣旨を逸脱しない範囲内で種々の改良変形が可能であることは容易に推察できるものである。   As described above, the present invention has been described based on the embodiments. However, the present invention is not limited to the above embodiments, and various improvements and modifications can be made without departing from the spirit of the present invention. It can be easily guessed.

例えば、上記実施形態では、色表現系はRGB形式としたが、RGB形式以外の他の色表現系、例えば、CMY形式などに本発明を適用してもよい。   For example, in the above embodiment, the color expression system is the RGB format, but the present invention may be applied to other color expression systems other than the RGB format, for example, the CMY format.

また、上記実施形態では、本発明の画像処理プログラムは、プリンタ1に組み込まれたCPU11により実行されるものとしたが、パーソナルコンピュータにアプリケーションとして供給され、パーソナルコンピュータに組み込まれたCPUなどにより実行されるようにしてもよい。   In the above embodiment, the image processing program of the present invention is executed by the CPU 11 incorporated in the printer 1, but is supplied as an application to the personal computer and executed by the CPU incorporated in the personal computer. You may make it do.

また、レティネックス処理は、SSR(シングルスケール法)であってもMSR(マルチスケール法)であってもよい。   The Retinex process may be SSR (single scale method) or MSR (multiscale method).

また、上記実施形態の画像処理では、CPU11によりレティネックス処理などを行うものとしたが、DSP(Digital Signal Processor)により行ってもよい。DSPを用いると、より高速に積和演算などの処理を実行することができる。   In the image processing of the above embodiment, the Retinex processing or the like is performed by the CPU 11, but may be performed by a DSP (Digital Signal Processor). If a DSP is used, processing such as a product-sum operation can be executed at a higher speed.

本発明の実施形態の画像処理プログラムを搭載したプリンタの電気的構成を示すブロック図である。1 is a block diagram showing an electrical configuration of a printer equipped with an image processing program according to an embodiment of the present invention. 画像処理プログラムにより行われる前処理を示すフロー図である。It is a flowchart which shows the pre-processing performed by an image processing program. 前処理に続いて実行される後処理を示すフローチャートである。It is a flowchart which shows the post-process performed following a pre-process. ヒストグラム処理を説明するための図であり、(a)は、画像の一例を示す画像図であり、(b)は、その画像の画素値のヒストグラムである。It is a figure for demonstrating a histogram process, (a) is an image figure which shows an example of an image, (b) is a histogram of the pixel value of the image. 第2の実施形態における前処理を示すフローチャートである。It is a flowchart which shows the pre-processing in 2nd Embodiment. 第2の実施形態における後処理を示すフローチャートである。It is a flowchart which shows the post-process in 2nd Embodiment. 正規化を行うためのクリップ範囲について説明するためのヒストグラムである。It is a histogram for demonstrating the clip range for performing normalization.

符号の説明Explanation of symbols

1 プリンタ
2 パーソナルコンピュータ
11 CPU
12 ROM
12a 画像処理プログラムメモリ
13 RAM
13a 元画像メモリ
13b レティネックス画像メモリ
1 Printer 2 Personal Computer 11 CPU
12 ROM
12a Image processing program memory 13 RAM
13a Original image memory 13b Retinex image memory

Claims (6)

画像の補正処理を行う画像処理装置により実行される画像処理プログラムにおいて、
元画像を縮小した縮小画像の各画素について、画素の値とその画素の周辺平均輝度とから反射率を求めることにより縮小レティネックス画像を形成する縮小レティネックス画像形成ステップと、
その縮小レティネックス画像形成ステップにより形成された縮小レティネックス画像の画素値が取る値の全範囲における各画素値の頻度を集計し、正規化を行う際の上限値および下限値を設定する正規化パラメータ設定ステップと、
前記縮小レティネックス画像形成ステップにより形成された縮小レティネックス画像を前記正規化パラメータ設定ステップにより設定された上限値および下限値に基づいて正規化し、その正規化した値が大きくなるほど補正後の前記縮小画像の画素値が大きくなるように前記縮小画像の画素値の補正を行う縮小画像補正ステップと、
その縮小画像補正ステップにより補正された縮小画像の画素値が取る全範囲における各画素値の頻度を集計し、ヒストグラム処理を行うパラメータを取得するヒストグラム処理パラメータ取得ステップと、
前記元画像の各画素について、画素の値とその画素の周辺平均輝度とから反射率を求め、その反射率を前記正規化パラメータ設定ステップにより設定された上限値および下限値に基づいて正規化した正規化レティネックス値を求め、その正規化レティネックス値が大きくなるほど補正後の前記元画像の画素値が大きくなるように前記元画像の画素値の補正を行い、前記ヒストグラム処理パラメータ取得ステップにより取得されたヒストグラム処理パラメータに基づいて、補正された画素値をヒストグラム補正する元画像補正ステップとを、前記画像処理装置に実行させるための画像処理プログラム。
In an image processing program executed by an image processing apparatus that performs image correction processing,
For each pixel of the reduced image obtained by reducing the original image, a reduced Retinex image forming step for forming a reduced Retinex image by obtaining a reflectance from the pixel value and the peripheral average luminance of the pixel;
Normalization that counts the frequency of each pixel value in the entire range of values taken by the pixel values of the reduced Retinex image formed by the reduced Retinex image forming step and sets the upper and lower limits for normalization A parameter setting step;
The reduced Retinex image formed by the reduced Retinex image forming step is normalized based on the upper limit value and the lower limit value set by the normalization parameter setting step, and the reduced image after correction becomes larger as the normalized value becomes larger A reduced image correction step for correcting the pixel value of the reduced image so that the pixel value of the image is increased ;
A histogram processing parameter acquisition step for totalizing the frequency of each pixel value in the entire range taken by the pixel values of the reduced image corrected by the reduced image correction step, and acquiring a parameter for performing the histogram processing;
For each pixel of the original image, a reflectance is obtained from the pixel value and the peripheral average luminance of the pixel, and the reflectance is normalized based on the upper limit value and the lower limit value set by the normalization parameter setting step. Obtaining a normalized Retinex value, correcting the pixel value of the original image so that the pixel value of the original image after correction increases as the normalized Retinex value increases , and is acquired by the histogram processing parameter acquisition step An image processing program for causing the image processing apparatus to execute an original image correction step of performing histogram correction on a corrected pixel value based on the histogram processing parameter that has been corrected.
前記縮小レティネックス画像形成ステップは、縮小画像の輝度信号のみについて縮小レティネックス画像を形成し、
前記縮小画像補正ステップは、前記縮小レティネックス画像形成ステップにより形成された縮小レティネックス画像を前記正規化パラメータ設定ステップにより設定された上限値および下限値に基づいて正規化し、その正規化した値が大きくなるほど補正後の前記縮小画像の輝度信号が大きくなるように前記縮小画像の輝度信号の補正をした後カラー画像に戻し、
前記ヒストグラム処理パラメータ取得ステップは、前記縮小画像補正ステップにより補正されたカラー画像の画素値が取る全範囲における各画素値の頻度を集計し、ヒストグラム処理を行うパラメータを取得し、
前記元画像補正ステップは、元画像の輝度信号のみについてレティネックス値求め、そのレティネックス値を前記正規化パラメータ設定ステップにより設定された上限値および下限値に基づいて正規化し、その正規化したレティネックス値が大きくなるほど補正後の前記元画像の輝度信号が大きくなるように前記元画像の輝度信号の補正を行うとともにカラー画素値に戻し、そのカラー画素値を前記ヒストグラム処理パラメータ取得ステップにより取得されたパラメータに基づいてヒストグラム補正することを特徴とする請求項1記載の画像処理プログラム。
The reduced Retinex image forming step forms a reduced Retinex image for only the luminance signal of the reduced image,
The reduced image correction step normalizes the reduced Retinex image formed by the reduced Retinex image forming step based on the upper limit value and the lower limit value set by the normalization parameter setting step, and the normalized value is The luminance signal of the reduced image is corrected so that the luminance signal of the reduced image after correction becomes larger as it becomes larger , and then returned to the color image.
The histogram processing parameter acquisition step totals the frequency of each pixel value in the entire range taken by the pixel values of the color image corrected by the reduced image correction step, and acquires a parameter for performing histogram processing,
In the original image correction step, a Retinex value is obtained only for the luminance signal of the original image, the Retinex value is normalized based on the upper limit value and the lower limit value set in the normalization parameter setting step, and the normalized latency The luminance signal of the original image is corrected and returned to the color pixel value so that the luminance signal of the original image after correction increases as the Nex value increases , and the color pixel value is acquired by the histogram processing parameter acquisition step. The image processing program according to claim 1, wherein histogram correction is performed based on the parameters.
前記正規化パラメータ設定ステップは、前記縮小レティネックス画像形成ステップにより形成された縮小レティネックス画像の全画素が取る値の最大値から最小値の範囲の値のうち、全画素に対する所定の割合の画素を含むクリップ範囲の上限値と下限値とを正規化パラメータとして設定することを特徴とする請求項1または2記載の画像処理プログラム。   In the normalization parameter setting step, pixels in a predetermined ratio with respect to all the pixels out of values in a range from a maximum value to a minimum value of all the pixels of the reduced Retinex image formed by the reduced Retinex image forming step. The image processing program according to claim 1, wherein an upper limit value and a lower limit value of a clip range including a normalization parameter are set. 画像の補正処理を行う画像処理装置において、
元画像を縮小した縮小画像の各画素について、画素の値とその画素の周辺平均輝度とから反射率を求めることにより縮小レティネックス画像を形成する縮小レティネックス画像形成手段と、
その縮小レティネックス画像形成手段により形成された縮小レティネックス画像の画素値が取る値の全範囲における各画素値の頻度を集計し、正規化を行う際の上限値および下限値を設定する正規化パラメータ設定手段と、
前記縮小レティネックス画像形成手段により形成された縮小レティネックス画像を前記正規化パラメータ設定手段により設定された上限値および下限値に基づいて正規化し、その正規化した値が大きくなるほど補正後の前記縮小画像の画素値が大きくなるように前記縮小画像の画素値の補正を行う縮小画像補正手段と、
その縮小画像補正手段により補正された縮小画像の画素値が取る全範囲における各画素値の頻度を集計し、ヒストグラム処理を行うパラメータを取得するヒストグラム処理パラメータ取得手段と、
前記元画像の各画素について、画素の値とその画素の周辺平均輝度とから反射率を求め、その反射率を前記正規化パラメータ設定手段により設定された上限値および下限値に基づいて正規化した正規化レティネックス値を求め、その正規化レティネックス値が大きくなるほど補正後の前記元画像の画素値が大きくなるように前記元画像の画素値の補正を行い、前記ヒストグラム処理パラメータ取得手段により取得されたヒストグラム処理パラメータに基づいて、補正された画素値をヒストグラム補正する元画像補正手段とを備えていることを特徴とする画像処理装置。
In an image processing apparatus that performs image correction processing,
For each pixel of the reduced image obtained by reducing the original image, a reduced Retinex image forming unit that forms a reduced Retinex image by obtaining a reflectance from the pixel value and the peripheral average luminance of the pixel;
Normalization that aggregates the frequency of each pixel value in the entire range of values taken by the pixel values of the reduced Retinex image formed by the reduced Retinex image forming means and sets the upper and lower limits for normalization Parameter setting means;
The reduced Retinex image formed by the reduced Retinex image forming unit is normalized based on the upper limit value and the lower limit value set by the normalization parameter setting unit, and the reduced image after correction is increased as the normalized value increases. Reduced image correction means for correcting the pixel value of the reduced image so as to increase the pixel value of the image;
Histogram processing parameter acquisition means for totalizing the frequency of each pixel value in the entire range taken by the pixel values of the reduced image corrected by the reduced image correction means, and acquiring parameters for performing histogram processing;
For each pixel of the original image, the reflectance is obtained from the pixel value and the peripheral average luminance of the pixel, and the reflectance is normalized based on the upper limit value and the lower limit value set by the normalization parameter setting means. A normalized Retinex value is obtained, the pixel value of the original image is corrected so that the pixel value of the original image after correction increases as the normalized Retinex value increases , and is acquired by the histogram processing parameter acquisition means An image processing apparatus comprising: an original image correcting unit that performs histogram correction on a corrected pixel value based on the histogram processing parameter that has been corrected.
前記縮小レティネックス画像形成手段は、縮小画像の輝度信号のみについて縮小レティネックス画像を形成し、
前記縮小画像補正手段は、前記縮小レティネックス画像形成手段により形成された縮小レティネックス画像を前記正規化パラメータ設定手段により設定された上限値および下限値に基づいて正規化し、その正規化した値が大きくなるほど補正後の前記縮小画像の輝度信号が大きくなるように前記縮小画像の輝度信を補正した後カラー画像に戻し、
前記ヒストグラム処理パラメータ取得手段は、前記縮小画像補正手段により補正されたカラー画像の画素値が取る全範囲における各画素値の頻度を集計し、ヒストグラム処理を行うパラメータを取得し、
前記元画像補正手段は、元画像の輝度信号のみについてレティネックス値求め、そのレティネックス値を前記正規化パラメータ設定手段により設定された上限値および下限値に基づいて正規化し、その正規化レティネックス値が大きくなるほど補正後の前記元画像の輝度信号が大きくなるように前記元画像の輝度信号の補正を行うとともにカラー画素値に戻し、そのカラー画素値を前記ヒストグラム処理パラメータ取得手段により取得されたパラメータに基づいてヒストグラム補正することを特徴とする請求項4記載の画像処理装置。
The reduced Retinex image forming means forms a reduced Retinex image for only the luminance signal of the reduced image,
The reduced image correction means normalizes the reduced Retinex image formed by the reduced Retinex image forming means based on the upper limit value and the lower limit value set by the normalization parameter setting means, and the normalized value is The luminance signal of the reduced image is corrected so that the luminance signal of the reduced image after correction becomes larger as it becomes larger , and then returned to the color image.
The histogram processing parameter acquisition means aggregates the frequency of each pixel value in the entire range taken by the pixel values of the color image corrected by the reduced image correction means, and acquires a parameter for performing histogram processing,
The original image correcting means obtains a Retinex value for only the luminance signal of the original image, normalizes the Retinex value based on the upper limit value and the lower limit value set by the normalization parameter setting means, and the normalized Retinex The luminance signal of the original image is corrected so that the luminance signal of the original image after correction becomes larger as the value becomes larger, and is returned to the color pixel value, and the color pixel value is acquired by the histogram processing parameter acquisition unit The image processing apparatus according to claim 4, wherein histogram correction is performed based on the parameter.
前記正規化パラメータ設定手段は、前記縮小レティネックス画像形成手段により形成された縮小レティネックス画像の全画素が取る値の最大値から最小値の範囲の値のうち、全画素に対する所定の割合の画素を含むクリップ範囲の上限値と下限値とを正規化パラメータとして設定することを特徴とする請求項4または5記載の画像処理装置。   The normalization parameter setting means includes a predetermined proportion of pixels in the range from the maximum value to the minimum value of all the pixels of the reduced Retinex image formed by the reduced Retinex image forming means. The image processing apparatus according to claim 4, wherein an upper limit value and a lower limit value of a clip range including are set as normalization parameters.
JP2006231553A 2006-08-17 2006-08-29 Image processing program and image processing apparatus Expired - Fee Related JP4793175B2 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2006231553A JP4793175B2 (en) 2006-08-29 2006-08-29 Image processing program and image processing apparatus
US11/837,817 US7920752B2 (en) 2006-08-17 2007-08-13 Image processing device that quickly performs retinex process

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2006231553A JP4793175B2 (en) 2006-08-29 2006-08-29 Image processing program and image processing apparatus

Publications (2)

Publication Number Publication Date
JP2008060627A JP2008060627A (en) 2008-03-13
JP4793175B2 true JP4793175B2 (en) 2011-10-12

Family

ID=39242924

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2006231553A Expired - Fee Related JP4793175B2 (en) 2006-08-17 2006-08-29 Image processing program and image processing apparatus

Country Status (1)

Country Link
JP (1) JP4793175B2 (en)

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6941028B2 (en) * 2001-04-30 2005-09-06 Hewlett-Packard Development Company, L.P. System and method for image enhancement, dynamic range compensation and illumination correction
JP4096613B2 (en) * 2002-05-10 2008-06-04 松下電器産業株式会社 Image processing method and image processing apparatus
JP2005004510A (en) * 2003-06-12 2005-01-06 Minolta Co Ltd Image processing program
US7760943B2 (en) * 2003-10-02 2010-07-20 Hewlett-Packard Development Company, L.P. Method to speed-up Retinex-type algorithms

Also Published As

Publication number Publication date
JP2008060627A (en) 2008-03-13

Similar Documents

Publication Publication Date Title
JP4867529B2 (en) Image processing program and image processing apparatus
US8290259B2 (en) Device adaptively switching color emphasis processing for image
JP2008059287A (en) Image processor and image processing program
JP4862554B2 (en) Image processing program and image processing apparatus
US8472711B2 (en) Image processing device for processing images according to the available storage capacity
JP4997846B2 (en) Image processing program and image processing apparatus
US7920752B2 (en) Image processing device that quickly performs retinex process
JP2008072604A (en) Image processing system, apparatus, medium, and program
JP4353233B2 (en) Image processing program and image processing apparatus
US7689065B2 (en) Image processing method and apparatus for suppressing positional shift image degradation
JP4687667B2 (en) Image processing program and image processing apparatus
JP4793175B2 (en) Image processing program and image processing apparatus
JP4793166B2 (en) Image processing program and image processing apparatus
JP4661754B2 (en) Image processing apparatus and image processing program
JP4710761B2 (en) Image processing program and image processing apparatus
JP4345027B2 (en) Image processing program and image processing apparatus
JP4353234B2 (en) Image processing program and image processing apparatus
JP4345026B2 (en) Image processing program and image processing apparatus
JP2008059307A (en) Image processor and image processing program
US8031973B2 (en) Data processing device capable of executing retinex processing at high speed
JP4281786B2 (en) Image processing program and image processing apparatus
JP4735499B2 (en) Image processing program and image processing apparatus
JP4375223B2 (en) Image processing apparatus, image processing method, and image processing program
JP2008060944A (en) Image processor
JP2008060914A (en) Image processor

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20090330

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20100902

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20100914

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20110329

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20110530

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

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20110628

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20110711

R150 Certificate of patent or registration of utility model

Ref document number: 4793175

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

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

Free format text: PAYMENT UNTIL: 20140805

Year of fee payment: 3

LAPS Cancellation because of no payment of annual fees