TWI601091B - Multiple light sources color balance algorithm - Google Patents

Multiple light sources color balance algorithm Download PDF

Info

Publication number
TWI601091B
TWI601091B TW105122076A TW105122076A TWI601091B TW I601091 B TWI601091 B TW I601091B TW 105122076 A TW105122076 A TW 105122076A TW 105122076 A TW105122076 A TW 105122076A TW I601091 B TWI601091 B TW I601091B
Authority
TW
Taiwan
Prior art keywords
layer
color
fuzzification
output
pixel
Prior art date
Application number
TW105122076A
Other languages
Chinese (zh)
Other versions
TW201802766A (en
Inventor
陳正倫
林孟緯
Original Assignee
國立中興大學
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 國立中興大學 filed Critical 國立中興大學
Priority to TW105122076A priority Critical patent/TWI601091B/en
Application granted granted Critical
Publication of TWI601091B publication Critical patent/TWI601091B/en
Publication of TW201802766A publication Critical patent/TW201802766A/en

Links

Description

多光源色彩平衡演算法Multi-source color balance algorithm

本發明係關於一種色彩平衡方法,尤指一種多光源色彩平衡演算法。The invention relates to a color balance method, in particular to a multi-source color balance algorithm.

色彩平衡 (color balance) 便是為了補償光照影響而被發展出來之一類影像處理演算法則。通常未經過色彩平衡之影像會呈現整體色彩偏向某種顏色,即所謂該影像有色偏 (color cast)。而色彩平衡演算法可透過調整影像的紅、綠、藍三個基本顏色層的值以使得有色偏之影像中的各種顏色回復正常,即所謂去除色偏。一般演算法基本上包含兩大步驟:(1) 估測擷取影像之光照條件、(2) 調整影像,以下進一步說明。Color balance is a type of image processing algorithm developed to compensate for the effects of light. Generally, an image that has not been color-balanced will have an overall color biased to a certain color, that is, the image has a color cast. The color balance algorithm can adjust the values of the three basic color layers of red, green and blue of the image to make the various colors in the color-shifted image return to normal, that is, remove the color cast. The general algorithm basically consists of two major steps: (1) estimating the lighting conditions of the captured image, and (2) adjusting the image, as further explained below.

一般的數位相機中,通常內建有色彩平衡的演算方法,其主要彩色平衡的演算法係由使用者選定估測光源之色溫,再以選定之色溫所對應的一組色彩平衡修正值對影像進行色彩平衡處理,亦有提供使用者將相機對準環境光源下參考顏色之參考物體 (例如白色色卡),再依據擷取之顏色值估算一組色彩平衡修正值,並再以該組色彩平衡修正值進行色彩平衡處理,一般而言,係將某一色溫作為標準(例如D65標準光源),將該標準光源的R 65\G 65\B 65值,除上各種參考色溫的R w\G w\B w值,得到各種色溫下的色彩平衡修正值,並建為一對照表,使用者設定參考色溫後,即可以查表方式取得對應該參考色溫的色彩平衡修正值,將各像素的R、G、B值乘上該色彩平衡修正值即可。 In a general digital camera, a color balance calculation method is usually built in, and the main color balance algorithm is selected by the user to estimate the color temperature of the light source, and then a set of color balance correction values corresponding to the selected color temperature is used for the image. Perform color balance processing, and also provide a reference object (such as a white color card) for the user to align the camera with the reference color under the ambient light source, and then estimate a set of color balance correction values according to the captured color value, and then use the color set. The balance correction value is used for color balance processing. Generally speaking, a certain color temperature is used as a standard (for example, D65 standard light source), and the R 65 \G 65 \B 65 value of the standard light source is divided by R w of various reference color temperatures. G w \B w value, the color balance correction value at various color temperatures is obtained, and is built as a comparison table. After the user sets the reference color temperature, the color balance correction value corresponding to the reference color temperature can be obtained by looking up the table mode, and each pixel is obtained. The R, G, and B values are multiplied by the color balance correction value.

上述色彩平衡的處理方式皆係以單一光源作為評估基礎,計算出單一組色彩平衡修正值後,將影像中的所有像素依照同一色彩平衡修正值做色彩平衡修正,然而,現實的攝影環境多半為多光源環境,因此,現有技術在推估整體影像的色溫後,通常只能取平均值或峰值作為代表整張影像的色溫,進而計算該組色彩平衡修正值,而將影像中所有像素以相同色彩平衡修正值做色彩平衡修正者,將會使整個影像中某些色群的像素往暖色系或冷色系偏移,色彩平衡的效果並不佳,而目前為解決多光源之問題,目前多半僅能藉由人工修圖方式處理,程序複雜且相當耗時。The above-mentioned color balance processing method is based on a single light source as an evaluation basis. After calculating a single color balance correction value, all the pixels in the image are corrected according to the same color balance correction value. However, the actual photography environment is mostly Multi-light source environment. Therefore, after estimating the color temperature of the overall image, the prior art usually only takes the average value or the peak value as the color temperature of the entire image, and then calculates the color balance correction value of the group, and uses all the pixels in the image to have the same color. Balance correction value for color balance correction will shift the pixels of some color groups in the whole image to warm color or cool color. The effect of color balance is not good. At present, most of the problems of solving multiple light sources are currently only It can be processed by manual retouching, and the program is complicated and time consuming.

有鑒於現有色彩平衡無法處理多光源環境而必須仰賴人工處理之技術缺陷,本發明係提出一種多光源色彩平衡演算法,可將影像中各像素依色溫分群,並依照分群結果以不同色彩平衡修正值進行色彩平衡處理,以取代人工處理。In view of the fact that the existing color balance cannot handle the multi-light source environment and must rely on the technical defects of manual processing, the present invention proposes a multi-source color balance algorithm, which can group the pixels in the image according to the color temperature and correct the colors according to the grouping result. The values are color balanced to replace manual processing.

為達上述目的,係令該多光源色彩平衡演算法包含以下步驟:To achieve the above objectives, the multi-source color balance algorithm includes the following steps:

輸入原始影像,係以一顏色空間輸入一原始影像,且該原始影像包含複數像素;Inputting the original image, inputting an original image in a color space, and the original image includes a plurality of pixels;

執行一光源估測演算,以計算該複數像素之初估色溫;Performing a light source estimation calculation to calculate an initial estimated color temperature of the plurality of pixels;

執行一光源分群演算,係設定一光源分群數,並依據該複數像素之初估色溫及該光源分群數進行分群並計算分別對應的複數決定色溫,再依據該複數決定色溫,以查表法估算該原始影像中複數像素所分別對應的複數組色彩平衡修正值;Performing a light source grouping calculation, setting a light source grouping number, and performing grouping according to the initial color temperature of the complex pixel and the number of the light source grouping, and calculating the corresponding complex number to determine the color temperature, and then determining the color temperature according to the complex number, and estimating by the table method a complex array color balance correction value corresponding to the plurality of pixels in the original image;

執行影像補償運算,係將該複數像素分別乘上對應的色彩平衡修正值,以輸出色彩平衡後的一修正影像。The image compensation operation is performed by multiplying the plurality of pixels by a corresponding color balance correction value to output a corrected image after color balance.

上述多光源色彩平衡演算法係以光源估測演算計算每個像素的初估色溫,再以光源分群演算分群計算每個像素的決定色溫,其中,光源分群數即環境光源數,經過該光源分群演算可有效將像素的初估色溫依環境光源分群,此後再以查表法得到色彩平衡修正值對各像素逐一進行修正,即可避免修正後的像素產生過暖或過冷的色偏現象,達到多光源影像色彩平衡的目的。The multi-source color balance algorithm calculates the initial estimated color temperature of each pixel by using the light source estimation calculation, and then calculates the determined color temperature of each pixel by the grouping of the light source grouping, wherein the number of the light source group is the number of ambient light sources, and the light source is grouped by the light source. The calculus can effectively group the initial estimated color temperature of the pixels according to the ambient light source. After that, the color balance correction value is corrected by the look-up table method to correct each pixel one by one, so as to avoid the color-shift phenomenon of the corrected pixels being overheated or too cold. Achieve the color balance of multi-source image.

上述多光源色彩平衡演算法可進一步執行一過飽和點處理,包含:The multi-source color balance algorithm described above can further perform an over-saturation processing, including:

設定一過飽和條件;Set a supersaturation condition;

標記初估色溫符合該過飽和條件的像素為一過飽和點;Marking the pixel whose initial color temperature meets the supersaturation condition is a supersaturation point;

執行一擴張處理,以重設該過飽和點的初估色溫。An expansion process is performed to reset the initial estimated color temperature of the supersaturation point.

上述多光源色彩平衡演算法,執行擴張處理包含:The above multi-source color balance algorithm, performing expansion processing includes:

設定一擴張矩陣;Setting an expansion matrix;

以被標記的該過飽和點為中心,依據該擴張矩陣延伸一搜尋範圍;Centering on the marked supersaturation point, extending a search range according to the expansion matrix;

搜尋該搜尋範圍中一最高色溫;Search for the highest color temperature in the search range;

設定過飽和點的初估色溫值為該最高色溫。The initial estimated color temperature value for setting the supersaturation point is the highest color temperature.

上述多光源色彩平衡演算法中,執行該光源分群演算之步驟包含:In the multi-source color balance algorithm described above, the step of performing the source group calculus includes:

設定該光源分群數及一空間函數;Setting the number of clusters of the light source and a spatial function;

估算中心值及歸屬函數,依據該光源分群數計算對應該光源分群數的複數中心值,以及依據該中心值、該光源分群數及該複數像素的初估色溫計算複數歸屬函數;Estimating the central value and the attribution function, calculating a complex center value corresponding to the number of the light source groups according to the number of the light source groups, and calculating a complex attribution function according to the central value, the number of the light source group, and the initial estimated color temperature of the complex pixel;

執行迴旋積分處理,係依據該光源分群數,將該複數歸屬函數與該空間函數進行迴旋積分運算;Performing a cyclotron integral process, performing a convolution integral operation on the complex attribution function and the spatial function according to the number of the light source group;

計算各像素的決定色溫,係將歸屬函數與空間函數迴旋積分的結果與中心值相乘,並依據光源分群數進行加總,取得個像素對應的決定色溫;Calculating the determined color temperature of each pixel, multiplying the result of the home function and the spatial function by the convolution integral with the center value, and summing according to the number of the light source groups, and obtaining the determined color temperature corresponding to each pixel;

計算色彩平衡修正值,係依據各像素的決定色溫對照一上查表,取得該複數組色彩平衡修正值。The color balance correction value is calculated, and the color balance correction value of the complex array is obtained according to the determined color temperature of each pixel.

上述該顏色空間為RGB顏色空間或YCbCr顏色空間。The color space described above is an RGB color space or a YCbCr color space.

上述該光源估測演算可為一Type-1 模糊推論演算系統,或可為一Type-2 TSK 模糊推論演算系統。The above-mentioned light source estimation calculus may be a Type-1 fuzzy inference calculation system, or may be a Type-2 TSK fuzzy inference calculation system.

上述Type-1 模糊推論演算系統包含一輸入層、一模糊化層、一規則層及一輸出層,其中:由該輸入層分別輸入該原始影像之顏色空間,並將該像素傳送至該模糊化層;該模糊化層對輸入之該原始影像之像素進行一模糊化運算,以計算出該中心值及歸屬函數;該規則層對該模糊化層的結果進行一AND運算;及該輸出層進行一解模糊運算,輸出該複數像素應分別對應的該複數初估色溫。The Type-1 fuzzy inference calculation system includes an input layer, a fuzzification layer, a regular layer and an output layer, wherein: the input layer respectively inputs a color space of the original image, and transmits the pixel to the fuzzification a layer; the fuzzification layer performs a fuzzification operation on the input pixel of the original image to calculate the center value and the attribution function; the rule layer performs an AND operation on the result of the fuzzification layer; and the output layer performs A de-fuzzification operation outputs the initial estimated color temperature of the complex number corresponding to the complex pixel.

上述Type-2 TSK 模糊推論演算系統包含一輸入層、一模糊化層、一規則層、一TSK函數層、一KM函數層及一輸出層,其中:由該輸入層分別輸入該原始影像之顏色空間,並將該像素傳送至該模糊化層及該TSK函數層;該模糊化層對輸入之該原始影像之像素進行一模糊化運算,以計算出該中心值及歸屬函數,Type-2 TSK的歸屬函數及中心值有二個,故本層輸出可分別以上下界輸出二個中心值及歸屬函數;該規則層對該模糊化層的結果進行一AND運算,本實施例中,與模糊化層相同,同樣為上下界輸出;該TSK函數層係將顏色空間轉為單輸出;該KM計算層係將TSK函數層之輸出由小至大排序後,再與第三層之上下界輸出進行KM演算法之計算;該輸出層係進行一解模糊運算,輸出該複數像素應分別對應的該複數初估色溫。The Type-2 TSK fuzzy inference calculation system includes an input layer, a fuzzification layer, a rule layer, a TSK function layer, a KM function layer and an output layer, wherein: the input layer respectively inputs the color of the original image Space, and transmitting the pixel to the fuzzification layer and the TSK function layer; the fuzzification layer performs a fuzzification operation on the input pixel of the original image to calculate the center value and the attribution function, Type-2 TSK There are two attribution functions and the central value, so the output of the layer can output two central values and the attribution function respectively above and below the lower bound; the rule layer performs an AND operation on the result of the fuzzification layer, in this embodiment, and the fuzzification The layers are the same, and the output is also the upper and lower bounds; the TSK function layer converts the color space into a single output; the KM computing layer sorts the output of the TSK function layer from small to large, and then outputs the upper and lower bounds of the third layer. The calculation of the KM algorithm; the output layer performs a defuzzification operation, and outputs the complex initial color temperature corresponding to the complex pixels.

本發明為一種多光源色彩平衡演算法,主要係將一原始影像以一種顏色空間的格式逐一輸入其像素至色彩平衡演算法中,由色彩平衡演算法中所包含的光源分群演算估算出分別對應複數像素的色溫 。如以6500K色溫作為標準,則將該標準光源的R 65\G 65\B 65值,除上色溫 的R\G\B值,得到對應色溫共n個色彩平衡修正值 ,將原始影像各像素的R I、G I、B I值乘上該色彩平衡修正值即可得到輸出影像,如式1所示。 【式1】 The invention relates to a multi-source color balance algorithm, which mainly inputs an original image into a pixel-to-color balance algorithm one by one in a color space format, and estimates the corresponding correspondence by the source group calculus included in the color balance algorithm. Color temperature of complex pixels . If the color temperature of 6500K is used as the standard, the R 65 \G 65 \B 65 value of the standard light source, in addition to the color temperature R\G\B value, get the corresponding color temperature, a total of n color balance correction values The R I , G I , and B I values of the pixels of the original image are multiplied by the color balance correction value to obtain an output image, as shown in Equation 1. 【Formula 1】

請配合參閱圖1,本發明多光源色彩平衡演算法主要包含以下步驟:Referring to FIG. 1 , the multi-source color balance algorithm of the present invention mainly includes the following steps:

輸入原始影像,係以一顏色空間輸入一原始影像,且該原始影像包含複數像素;Inputting the original image, inputting an original image in a color space, and the original image includes a plurality of pixels;

執行一光源估測演算,以計算該複數像素之初估色溫,請進一步配合參閱圖2A,係以一5*5像素的色溫為例,此步驟即初步估算每個像素對應的初估色溫,但實作結果顯示,此步驟估算出的初估色溫並沒有數個明顯的峰值,亦即複數像素的初估色溫仍是雜亂地分布,因此需進一步進行下一步驟;Performing a light source estimation calculation to calculate the initial color temperature of the complex pixel, please further refer to FIG. 2A, taking a color temperature of 5*5 pixels as an example, this step preliminarily estimates the initial estimated color temperature of each pixel. However, the results show that the initial estimated color temperature estimated by this step does not have several obvious peaks, that is, the initial estimated color temperature of the complex pixels is still scattered, so further steps are needed;

執行一光源分群演算,係設定一光源分群數,並依據該複數像素之初估色溫及該光源分群數進行分群並計算對應的複數決定色溫,再依據該複數決定色溫,以查表法估算該原始影像中複數像素所分別對應的複數組色彩平衡修正值,其詳細步驟請容後說明;Performing a light source grouping calculation, setting a number of light source groups, and grouping according to the initial color temperature of the plurality of pixels and the number of the light source groups, and calculating a corresponding complex number to determine the color temperature, and then determining the color temperature according to the complex number, and estimating the table by the table method The complex array color balance correction value corresponding to the complex pixels in the original image, the detailed steps, please explain later;

執行影像補償運算,係將該複數像素分別乘上對應的色彩平衡修正值,以輸出色彩平衡後的一修正影像。The image compensation operation is performed by multiplying the plurality of pixels by a corresponding color balance correction value to output a corrected image after color balance.

上述多光源色彩平衡演算法色彩平衡方法可進一步執行一過飽和點處理,係設定一過飽和條件,並於執行光源估測演算而取得每個像素對應的初估色溫後執行:The multi-source color balance algorithm color balance method may further perform an over-saturation processing, set an over-saturation condition, and perform the light source estimation calculation to obtain the initial estimated color temperature corresponding to each pixel:

標記初估色溫符合該過飽和條件的像素為過飽和點,誠如圖2A所示,係設定6300為過飽和點,對應初估色溫6385的像素將被標註為過飽和點;The pixel whose initial color temperature is consistent with the supersaturation condition is a supersaturation point, as shown in FIG. 2A, the setting 6300 is a supersaturation point, and the pixel corresponding to the initial estimated color temperature 6385 will be marked as a supersaturation point;

執行一擴張處理,以重設過飽和點的初估色溫,詳細步驟容後說明。Perform an expansion process to reset the initial estimated color temperature of the supersaturation point. The detailed steps are explained later.

於本實施例中,該過飽和條件可設定為:RGB空間中,R值大於225且G值大於225且B值大於225,或者RGB空間中R值小於40且G值小於40且B值小於40。In this embodiment, the supersaturation condition may be set to: in the RGB space, the R value is greater than 225 and the G value is greater than 225 and the B value is greater than 225, or the R value in the RGB space is less than 40 and the G value is less than 40 and the B value is less than 40. .

上述多光源色彩平衡演算法中,執行該擴張處理,係設定一擴張矩陣,以下配合圖2A、2B說明之,本實施例係設定擴張矩陣唯一5*5矩陣,並於標記過飽和點後執行以下步驟:In the multi-source color balance algorithm described above, the expansion process is performed to set an expansion matrix. As described below with reference to FIGS. 2A and 2B, this embodiment sets a unique 5*5 matrix of the expansion matrix, and performs the following after marking the supersaturation point. step:

以被標記的過飽和點為中心,依據該擴張矩陣延伸一搜尋範圍,即設定該5*5矩陣為搜尋範圍;Centering on the marked supersaturation point, extending a search range according to the expansion matrix, that is, setting the 5*5 matrix as a search range;

搜尋該搜尋範圍中一最高色溫,於圖2A實施例中,即找到4385為最高色溫;Searching for a highest color temperature in the search range. In the embodiment of FIG. 2A, 4385 is found as the highest color temperature;

設定過飽和點的初估色溫值為該最高色溫,如圖2B表示,即將過飽和點的初估色溫設定為4385。The initial estimated color temperature value of the supersaturation point is set to the highest color temperature, as shown in Fig. 2B, that is, the initial estimated color temperature of the supersaturation point is set to 4385.

上述多光源色彩平衡演算法中,執行光源分群演算之步驟包含:In the multi-source color balance algorithm described above, the steps of performing the source group calculus include:

設定一光源分群數C及一空間函數h ij,其中光源分群數C即代表環境光源的數量,空間函數為一矩陣,其中N ij為以第ij像素為中心之5*5範圍之矩陣,k為範圍內除中心點外之歸屬函數,如以下式2所示; 【式2】 A light source grouping number C and a spatial function h ij are set , wherein the light source grouping number C represents the number of ambient light sources, and the spatial function is a matrix, wherein N ij is a matrix of 5*5 range centered on the ij pixel, k a attribution function other than the center point in the range, as shown in the following formula 2; [Equation 2]

估算中心值v i及歸屬函數u ij,依據該光源分群數C以模糊分群法,進行光源分群,其主要係計算對應該光源分群數的複數中心值v i,以及依據該中心值、該光源分群數及該複數像素的初估色溫計算出的複數歸屬函數u ij,其分別如下式3及式4表示;n為輸入影像之像素總數 【式3】 【式4】 Estimating the central value v i and the attribution function u ij , performing light source grouping according to the number of clusters of the light source by fuzzy grouping method, which mainly calculates a complex center value v i corresponding to the number of clusters of the light source, and according to the central value, the light source The complex number attribute function u ij calculated by the number of clusters and the initial estimated color temperature of the complex pixel is represented by Equations 3 and 4, respectively; n is the total number of pixels of the input image [Equation 3] [Formula 4]

執行迴旋積分處理,係依據該光源分群數,將該複數歸屬函數與該空間函數h ij進行迴旋積分運算,複數歸屬函數經迴旋積分處理後表示如以下式5; 【式5】 Performing a cyclotron integral process, performing a convolution integral operation on the complex number attribution function and the spatial function h ij according to the number of the light source group, and the complex attribution function is represented by the following formula 5 after the convolution integral processing; [Equation 5]

計算各像素的決定色溫L e,係將歸屬函數u ij與空間函數h ij迴旋積分的結果與中心值v i相乘,並依據光源分群數進行加總,取得個像素對應的決定色溫L e,決定色溫L e如以下式6表示; 【式6】 Calculating the determined color temperature L e of each pixel, multiplying the result of the rotation of the attribution function u ij and the spatial function h ij by the center value v i , and summing according to the number of light source groups, and obtaining the determined color temperature L e corresponding to each pixel Determining the color temperature L e as expressed by the following formula 6; [Equation 6]

計算色彩平衡修正值,係依據各像素的決定色溫對照一上查表,取得該複數組色彩平衡修正值。The color balance correction value is calculated, and the color balance correction value of the complex array is obtained according to the determined color temperature of each pixel.

上述該光源估測演算可為一Type-1 模糊推論演算系統,或可為一Type-2 TSK 模糊推論演算系統。The above-mentioned light source estimation calculus may be a Type-1 fuzzy inference calculation system, or may be a Type-2 TSK fuzzy inference calculation system.

請進一步配合參閱圖3,上述Type-1 模糊推論演算系統包含一輸入層、一模糊化層、一規則層及一輸出層,其中:由該輸入層分別輸入該原始影像之顏色空間,並將該像素傳送至該模糊化層;該模糊化層對輸入之該原始影像之像素進行一模糊化運算,以計算出該中心值及歸屬函數;該規則層對該模糊化層的結果進行一AND運算;及該輸出層進行一解模糊運算,輸出該複數像素應分別對應的該複數初估色溫。Please further refer to FIG. 3, the Type-1 fuzzy inference calculation system includes an input layer, a fuzzification layer, a regular layer and an output layer, wherein: the input layer respectively inputs the color space of the original image, and The pixel is transmitted to the fuzzification layer; the fuzzification layer performs a fuzzification operation on the input pixel of the original image to calculate the center value and the attribution function; the rule layer performs an AND on the result of the fuzzification layer And the output layer performs a defuzzification operation, and outputs the complex initial color temperature corresponding to the complex pixel respectively.

圖3中標示之參數說明如下:R i、G i、B i為輸入像素的R、G、B值,β為規則數, 為欲處理之影像之複數初估色溫。 The parameters indicated in Figure 3 are as follows: R i , G i , B i are the R, G, and B values of the input pixel, and β is the rule number. The color temperature is initially estimated for the plural of the image to be processed.

請進一步配合參閱圖4,上述Type-2 TSK 模糊推論演算系統包含一輸入層、一模糊化層、一規則層、一TSK函數層、一KM函數層及一輸出層,其中:由該輸入層分別輸入該原始影像之顏色空間,並將該像素傳送至該模糊化層及該TSK函數層;該模糊化層對輸入之該原始影像之像素進行一模糊化運算,以計算出該中心值及歸屬函數,Type-2 TSK的歸屬函數及中心值有二個,故本層輸出可分別以上下界輸出二個中心值及歸屬函數;該規則層對該模糊化層的結果進行一AND運算,本實施例中,與模糊化層相同,同樣為上下界輸出;該TSK函數層係將顏色空間轉為單輸出;該KM計算層係將TSK函數層之輸出由小至大排序後,再與第三層之上下界輸出進行KM演算法之計算;該輸出層係進行一解模糊運算,輸出該複數像素應分別對應的該複數初估色溫。Please further refer to FIG. 4, the Type-2 TSK fuzzy inference calculation system includes an input layer, a fuzzification layer, a rule layer, a TSK function layer, a KM function layer and an output layer, wherein: the input layer Inputting the color space of the original image separately, and transmitting the pixel to the fuzzification layer and the TSK function layer; the fuzzification layer performs a fuzzification operation on the input pixel of the original image to calculate the center value and The attribution function, Type-2 TSK has two attribution functions and center values, so the output of this layer can output two center values and the attribution function respectively above and below the lower bound; the rule layer performs an AND operation on the result of the fuzzification layer. In the embodiment, the same as the fuzzification layer, the output is also the upper and lower bounds; the TSK function layer converts the color space into a single output; the KM computing layer sorts the output of the TSK function layer from small to large, and then The lower bound output of the three layers performs the calculation of the KM algorithm; the output layer performs a defuzzification operation, and outputs the complex estimated initial color temperature corresponding to the complex pixels.

圖4中標示之參數說明如下:R (m,n)、G (m,n)、B (m,n)為座標(m,n)像素的R、G、B值,q (i)為輸出,上標指出位於第i層之輸出,T (m,n)為座標(m,n)像素的初估色溫。 The parameters indicated in Figure 4 are as follows: R (m,n) , G (m,n) , B (m,n) are the R, G, B values of the coordinates (m,n) pixels, and q (i) is The output, superscript indicates the output at the ith layer, and T (m, n) is the initial estimated color temperature of the coordinates (m, n) pixels.

再請進一步配合參閱圖5,經由實作,將拍攝物體至於色溫6500K及3000K混合光源的環境之下拍攝取得原始影像,經由上述多光源色彩平衡演算法處理過程中,光源分群數C設定為2,經過該光源分群演算進行分群及估算後,其所輸出的該複數決定色溫值統計如圖4所示,其明顯集中於2個峰值,與實際拍攝環境光源接近,得以證實,藉由上述光源分群演算,得以準確地推估出實際拍攝影像的多種環境光源,且環境光源之數量可供使用者自行設定,不以2個為限。Please further refer to Figure 5, through the implementation, the original image is captured under the environment of the color light 6500K and 3000K mixed light source. Through the multi-light source color balance algorithm processing, the light source grouping number C is set to 2 After the grouping and estimation by the light source grouping calculation, the complex color determining color temperature value output is shown in FIG. 4, which is obviously concentrated on two peaks, which is close to the actual shooting environment light source, and is confirmed by the above light source. The group calculus can accurately estimate the various ambient light sources of the actual captured image, and the number of ambient light sources can be set by the user, not limited to two.

依本發明多光源色彩平衡演算法進行影像修正時,使用者可先設定光源分群數為環境光源數,如本實施例即設定2個環境光源為光源分群數,經上述第一及光源分群演算法估算出複數像素對應的決定色溫即可如圖5所示,再利用查表法,便可得到分別對應複數像素的複數色彩平衡修正值,最後,將複數像素乘上對應的色彩平衡修正值即可得到色彩平衡後的影像,如此,可避免修正後的像素產生過暖或過冷的色偏現象,達到多光源影像色彩平衡的目的。According to the multi-source color balance algorithm of the present invention for image correction, the user may first set the number of light source groups to the number of ambient light sources. For example, in this embodiment, two ambient light sources are set as the number of light source groups, and the first and the light source grouping calculation are performed. The method estimates the color temperature corresponding to the complex pixel as shown in FIG. 5, and then uses the look-up table method to obtain the complex color balance correction values corresponding to the complex pixels, and finally, multiplies the complex pixel by the corresponding color balance correction value. The color-balanced image can be obtained, so that the corrected pixel can be caused by excessive or too cold color shift phenomenon, and the color balance of the multi-light source image can be achieved.

綜上所述,本發明多光源色彩平衡演算法具有以下優點:In summary, the multi-source color balance algorithm of the present invention has the following advantages:

使用者可設定環境光源數,以此來估算像素的色溫,並依據像素的色溫個別進行色彩平衡,達到多光源影像色彩平衡的目的。The user can set the number of ambient light sources to estimate the color temperature of the pixels, and individually perform color balance according to the color temperature of the pixels to achieve the color balance of the multi-source image.

可應用於各種數位影像擷取工具(如數位相機、攝影機……等),亦可用於離線作業(後製影像),取代人工修圖。Can be applied to a variety of digital image capture tools (such as digital cameras, cameras, etc.), can also be used for offline operations (post-production images), instead of manual retouching.

利用空間函數可進一步提升色溫分群的精確度。The use of spatial functions can further improve the accuracy of color temperature grouping.

無。no.

圖1:為本發明之流程示意圖。 圖2A:為本發明初步估算色溫之示意圖。 圖2B:為圖2A經過飽和點處理之示意圖。 圖3:為光源估測演算架構之一較佳實施例的示意圖。 圖4:為光源估測演算架構之另一較佳實施例的示意圖。 圖5:為光源分群演算後決定色溫的分佈示意圖。Figure 1 is a schematic flow chart of the present invention. Fig. 2A is a schematic view showing the preliminary estimation of color temperature of the present invention. Figure 2B is a schematic diagram of the processing of the saturation point of Figure 2A. Figure 3 is a schematic illustration of one preferred embodiment of a light source estimation algorithm architecture. 4 is a schematic diagram of another preferred embodiment of a light source estimation algorithm architecture. Figure 5: Schematic diagram of the distribution of color temperature after the clustering of the light source.

Claims (8)

一種多光源色彩平衡演算法包含以下步驟:輸入原始影像,係以一顏色空間輸入一原始影像,且該原始影像包含複數像素;執行一光源估測演算,以計算該複數像素之初估色溫;於執行光源估測演算而取得每個像素對應的初估色溫後執行一過飽和點處理,該過飽和點處理包含:設定一過飽和條件;標記初估色溫符合該過飽和條件的像素為一過飽和點;以及執行一擴張處理,以重設該過飽和點的初估色溫;其中,執行該擴張處理之步驟包含:設定一擴張矩陣;以被標記的該過飽和點為中心,依據該擴張矩陣延伸一搜尋範圍;搜尋該搜尋範圍中一最高色溫;以及設定過飽和點的初估色溫為該最高色溫;執行一光源分群演算,係設定一光源分群數,並依據該複數像素之初估色溫及該光源分群數進行分群並計算分別對應的複數決定色溫,再依據該複數決定色溫,以查表法估算該原始影像中複數像素所分別對應的複數組色彩平衡修正值;執行影像補償運算,係將該複數像素分別乘上對應的色彩平衡修正值,以輸出色彩平衡後的一修正影像。 A multi-source color balance algorithm includes the following steps: inputting an original image, inputting an original image in a color space, and the original image includes a plurality of pixels; performing a light source estimation calculation to calculate an initial estimated color temperature of the plurality of pixels; Performing a light source estimation calculation to obtain an initial estimated color temperature corresponding to each pixel, and performing an oversaturation point processing, the supersaturation point processing includes: setting a supersaturation condition; marking a pixel whose initial color temperature is consistent with the supersaturation condition is a supersaturation point; Performing an expansion process to reset the initial estimated color temperature of the supersaturation point; wherein performing the expansion process comprises: setting an expansion matrix; extending a search range according to the expansion matrix centered on the marked supersaturation point; Searching for a highest color temperature in the search range; and setting an initial color temperature of the supersaturation point to the highest color temperature; performing a light source grouping calculation, setting a light source grouping number according to the initial color temperature of the plurality of pixels and the number of the light source grouping Grouping and calculating the corresponding complex numbers to determine the color temperature, and then determining according to the complex number Temperature, the complex array color balance correction value corresponding to the plurality of pixels in the original image is estimated by the look-up table method; the image compensation operation is performed, and the plurality of pixels are respectively multiplied by the corresponding color balance correction values to output the color balanced A corrected image. 如請求項1所述的多光源色彩平衡演算法,執行該光源分群演算之步驟包含:設定該光源分群數及一空間函數; 估算中心值及歸屬函數,依據該光源分群數計算對應該光源分群數的複數中心值,以及依據該中心值、該光源分群數及該複數像素的初估色溫計算複數歸屬函數;執行迴旋積分處理,係依據該光源分群數,將該複數歸屬函數與該空間函數進行迴旋積分運算;計算各像素的決定色溫,係將歸屬函數與空間函數迴旋積分的結果與中心值相乘,並依據光源分群數進行加總,取得個像素對應的決定色溫;計算色彩平衡修正值,係依據各像素的決定色溫值對照一上查表,取得該複數組色彩平衡修正值。 The multi-source color balance algorithm according to claim 1, the step of performing the source group calculus includes: setting the number of the source group and a spatial function; Estimating the central value and the attribution function, calculating a complex center value corresponding to the number of clusters of the light source according to the number of clusters of the light source, and calculating a complex attribution function according to the central value, the number of the light source clusters, and the initial estimated color temperature of the complex pixel; performing a swing integral processing According to the number of the light source group, the complex attribute function and the spatial function are subjected to a convolution integral operation; calculating the determined color temperature of each pixel, multiplying the result of the home function and the spatial function by the convolution integral with the center value, and grouping according to the light source The number is summed to obtain a determined color temperature corresponding to each pixel; the color balance correction value is calculated, and the color balance correction value of the complex array is obtained by comparing the determined color temperature value of each pixel with a lookup table. 如請求項1所述的多光源色彩平衡演算法,該顏色空間為RGB顏色空間或YCbCr顏色空間。 The multi-source color balance algorithm as claimed in claim 1, wherein the color space is an RGB color space or a YCbCr color space. 如請求項2所述的多光源色彩平衡演算法,該顏色空間為RGB顏色空間或YCbCr顏色空間。 The multi-source color balance algorithm as claimed in claim 2, wherein the color space is an RGB color space or a YCbCr color space. 如請求項1所述的多光源色彩平衡演算法,該光源估測演算為一Type-1模糊推論演算系統,其包含一輸入層、模糊化層、規則層及一輸出層,其中:由該輸入層分別輸入該原始影像之顏色空間,並將該像素傳送至該模糊化層;該模糊化層對輸入之該原始影像之像素進行一模糊化運算,以計算出該中心值及歸屬函數;該規則層對該模糊化層的結果進行一AND運算;及該輸出層進行一解模糊運算,輸出該複數像素應分別對應的該複數初估色溫。 The multi-source color balance algorithm according to claim 1, wherein the light source estimation algorithm is a Type-1 fuzzy inference calculation system, which comprises an input layer, a fuzzification layer, a rule layer and an output layer, wherein: The input layer respectively inputs the color space of the original image, and transmits the pixel to the fuzzification layer; the fuzzification layer performs a fuzzification operation on the input pixel of the original image to calculate the center value and the attribution function; The rule layer performs an AND operation on the result of the fuzzification layer; and the output layer performs a defuzzification operation to output the initial estimated color temperature corresponding to the complex pixels. 如請求項4所述的多光源色彩平衡演算法,該光源估測演算為一Type-1模糊推論演算系統,其包含一輸入層、模糊化層、規則層及一輸出層,其中:由該輸入層分別輸入該原始影像之顏色空間,並將該像素傳送至該模糊化層;該模糊化層對輸入之該原始影像之像素進行一模糊化運算,以計算出該 中心值及歸屬函數;該規則層對該模糊化層的結果進行一AND運算;及該輸出層進行一解模糊運算,輸出該複數像素應分別對應的該複數初估色溫。 The multi-source color balance algorithm according to claim 4, wherein the light source estimation algorithm is a Type-1 fuzzy inference calculation system, comprising an input layer, a fuzzification layer, a rule layer and an output layer, wherein: The input layer respectively inputs the color space of the original image, and transmits the pixel to the fuzzification layer; the fuzzification layer performs a fuzzification operation on the input pixel of the original image to calculate the The central value and the attribution function; the rule layer performs an AND operation on the result of the fuzzification layer; and the output layer performs a defuzzification operation to output the initial estimated color temperature corresponding to the complex pixel respectively. 如請求項1所述的多光源色彩平衡演算法,該光源估測演算為一Type-2 TSK模糊推論演算系統,其包含包含一輸入層、一模糊化層、一規則層、一TSK函數層、一KM函數層及一輸出層,其中:由該輸入層分別輸入該原始影像之顏色空間,並將該像素傳送至該模糊化層及該TSK函數層;該模糊化層對輸入之該原始影像之像素進行一模糊化運算,以計算出該中心值及歸屬函數,Type-2 TSK的歸屬函數及中心值有二個,故本層輸出可分別以上下界輸出二個中心值及歸屬函數;該規則層對該模糊化層的結果進行一AND運算,本實施例中,與模糊化層相同,同樣為上下界輸出;該TSK函數層係將顏色空間轉為單輸出;該KM計算層係將TSK函數層之輸出由小至大排序後,再與第三層之上下界輸出進行KM演算法之計算;該輸出層係進行一解模糊運算,輸出該複數像素應分別對應的該複數初估色溫。 The multi-source color balance algorithm according to claim 1, wherein the light source estimation algorithm is a Type-2 TSK fuzzy inference calculation system, comprising: an input layer, a fuzzification layer, a rule layer, and a TSK function layer. a KM function layer and an output layer, wherein: the input layer respectively inputs a color space of the original image, and transmits the pixel to the fuzzification layer and the TSK function layer; the fuzzification layer inputs the original The pixel of the image is subjected to a fuzzification operation to calculate the center value and the attribution function. The Type-2 TSK has two attribution functions and a central value, so the output of the layer can output two center values and a attribution function respectively above and below the lower bound; The rule layer performs an AND operation on the result of the fuzzification layer. In this embodiment, the same as the fuzzification layer, which is also an upper and lower bound output; the TSK function layer converts the color space into a single output; the KM computing layer system The output of the TSK function layer is sorted from small to large, and then the KM algorithm is calculated with the lower bound output of the third layer; the output layer performs a defuzzification operation, and outputs the complex pixel corresponding to the complex Preliminary estimates suggest that the color temperature. 如請求項4所述的多光源色彩平衡演算法,該光源估測演算為一Type-2 TSK模糊推論演算系統,其包含包含一輸入層、一模糊化層、一規則層、一TSK函數層、一KM函數層及一輸出層,其中:由該輸入層分別輸入該原始影像之顏色空間,並將該像素傳送至該模糊化層及該TSK函數層;該模糊化層對輸入之該原始影像之像素進行一模糊化運算,以計算出該中心值及歸屬函數,Type-2 TSK的歸屬函數及中心值有二個,故本層輸出可分別以上下界輸出二個中心值及歸屬函數;該規則層對該模糊化層的結果進行一AND運算,本實施例中,與模糊化層相同,同樣為上下界輸出;該TSK函數層係將顏色空間轉為單輸出;該KM計算層係將TSK函數層之輸出由小至大排序後,再與第三層之上下界輸出進行KM演算法之計算;該輸出層係進行一解模糊運算,輸出該複數像素應分別對應的該複數初估色溫。The multi-source color balance algorithm according to claim 4, wherein the light source estimation algorithm is a Type-2 TSK fuzzy inference calculation system, comprising: an input layer, a fuzzification layer, a rule layer, and a TSK function layer a KM function layer and an output layer, wherein: the input layer respectively inputs a color space of the original image, and transmits the pixel to the fuzzification layer and the TSK function layer; the fuzzification layer inputs the original The pixel of the image is subjected to a fuzzification operation to calculate the center value and the attribution function. The Type-2 TSK has two attribution functions and a central value, so the output of the layer can output two center values and a attribution function respectively above and below the lower bound; The rule layer performs an AND operation on the result of the fuzzification layer. In this embodiment, the same as the fuzzification layer, which is also an upper and lower bound output; the TSK function layer converts the color space into a single output; the KM computing layer system The output of the TSK function layer is sorted from small to large, and then the KM algorithm is calculated with the lower bound output of the third layer; the output layer performs a defuzzification operation, and outputs the complex pixel corresponding to the complex Preliminary estimates suggest that the color temperature.
TW105122076A 2016-07-13 2016-07-13 Multiple light sources color balance algorithm TWI601091B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW105122076A TWI601091B (en) 2016-07-13 2016-07-13 Multiple light sources color balance algorithm

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW105122076A TWI601091B (en) 2016-07-13 2016-07-13 Multiple light sources color balance algorithm

Publications (2)

Publication Number Publication Date
TWI601091B true TWI601091B (en) 2017-10-01
TW201802766A TW201802766A (en) 2018-01-16

Family

ID=61010903

Family Applications (1)

Application Number Title Priority Date Filing Date
TW105122076A TWI601091B (en) 2016-07-13 2016-07-13 Multiple light sources color balance algorithm

Country Status (1)

Country Link
TW (1) TWI601091B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080055479A1 (en) * 2006-09-01 2008-03-06 Texas Instruments Incorporated Color Space Appearance Model Video Processor
US20110293174A1 (en) * 2010-05-27 2011-12-01 Samsung Electronics Co., Ltd. Image Processing Apparatus, Image Processing Method And Recording Medium For Storing Program To Execute The Method
US20150326842A1 (en) * 2014-12-10 2015-11-12 Xiaoning Huai Automatic White Balance with Facial Color Features as Reference Color Surfaces

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080055479A1 (en) * 2006-09-01 2008-03-06 Texas Instruments Incorporated Color Space Appearance Model Video Processor
US20110293174A1 (en) * 2010-05-27 2011-12-01 Samsung Electronics Co., Ltd. Image Processing Apparatus, Image Processing Method And Recording Medium For Storing Program To Execute The Method
US20150326842A1 (en) * 2014-12-10 2015-11-12 Xiaoning Huai Automatic White Balance with Facial Color Features as Reference Color Surfaces

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
Arjan Gijsenij, Rui Lu, and Theo Gevers, "Color Constancy for Multiple Light Sources," IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 21, NO. 2, pp. 697-707, February 2012. *

Also Published As

Publication number Publication date
TW201802766A (en) 2018-01-16

Similar Documents

Publication Publication Date Title
TWI293742B (en)
CN111292246B (en) Image color correction method, storage medium, and endoscope
JPWO2007007788A1 (en) Color correction method and color correction apparatus
JP4687673B2 (en) Monotone processing of color image
CN111861922A (en) Method and device for adjusting color correction matrix and storage medium
US6483940B1 (en) Method for dividing image
JP2002152772A (en) White balance correcting device, white balance correcting method, density correcting method and recording medium with program for executing the method recorded thereon
Faridul et al. Approximate cross channel color mapping from sparse color correspondences
US10224004B2 (en) Automatic white balance based on surface reflection decomposition
WO2023016468A1 (en) De-pixelating method, electronic device and storage medium
WO2019015553A1 (en) Image color correction method, device, storage medium and computer equipment
JP2009033361A (en) Color adjustment unit, image-forming device, and program
TWI523542B (en) White balance compensation method and electronic apparatus using the same
TWI649724B (en) Method and apparatus for determining a light source of an image and performing color vision adaptation on the image
TWI601091B (en) Multiple light sources color balance algorithm
US20180176420A1 (en) Automatic white balance based on surface reflection decomposition and chromatic adaptation
TWI524760B (en) Camera array correction method
CN107251554A (en) Color table creating device, camera review correction/control device and its method
JP5824423B2 (en) Illumination light color estimation device, illumination light color estimation method, and illumination light color estimation program
WO2018209984A1 (en) Image processing method and apparatus
Bianco et al. Computational color constancy
CN112788251A (en) Image brightness processing method and device, and image processing method and device
JP4626776B2 (en) Color correction method and color correction apparatus
CN115965541A (en) Color correction method, color correction device, electronic device, and storage medium
JP4640850B2 (en) Image processing program

Legal Events

Date Code Title Description
MM4A Annulment or lapse of patent due to non-payment of fees