TW201738841A - Method of dynamic adjustment to automatic white balance under hybrid light sources - Google Patents
Method of dynamic adjustment to automatic white balance under hybrid light sources Download PDFInfo
- Publication number
- TW201738841A TW201738841A TW105112811A TW105112811A TW201738841A TW 201738841 A TW201738841 A TW 201738841A TW 105112811 A TW105112811 A TW 105112811A TW 105112811 A TW105112811 A TW 105112811A TW 201738841 A TW201738841 A TW 201738841A
- Authority
- TW
- Taiwan
- Prior art keywords
- image
- color temperature
- brightness
- white balance
- area
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 24
- 239000003086 colorant Substances 0.000 claims description 3
- 230000006870 function Effects 0.000 description 7
- 230000003247 decreasing effect Effects 0.000 description 4
- 238000010586 diagram Methods 0.000 description 4
- 230000000694 effects Effects 0.000 description 2
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000002156 mixing Methods 0.000 description 1
- 239000000203 mixture Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000007935 neutral effect Effects 0.000 description 1
- 230000002028 premature Effects 0.000 description 1
- 238000012216 screening Methods 0.000 description 1
Landscapes
- Color Television Image Signal Generators (AREA)
- Processing Of Color Television Signals (AREA)
Abstract
Description
本發明係指一種動態調整混色光源白平衡的方法,尤指一種可在混色光源場景下,辨識場景光源及其對應色溫以進行動態白平衡補償的方法。The invention relates to a method for dynamically adjusting the white balance of a mixed color light source, in particular to a method for recognizing a scene light source and its corresponding color temperature in a mixed color light source scene for dynamic white balance compensation.
依據光源的色彩與特性,物體所呈現的色調也會隨之變化,例如白熾燈光偏黃,而陽光帶有偏藍的色調,因此在不同光源下,白色物體可能會呈現偏黃或是偏藍的色調。幸運的是,人類肉眼能依據「白色物體應呈白色」的概念,對眼前所見的影像進行色彩補償,因此不論身處在何種光源下,肉眼仍可將影像還原成理想顏色。Depending on the color and characteristics of the light source, the hue of the object will change accordingly. For example, the incandescent light is yellowish and the sunlight has a bluish hue, so the white object may appear yellowish or bluish under different light sources. Tone. Fortunately, the human eye can color compensate for the image seen in front of the eye according to the concept that the white object should be white. Therefore, the naked eye can still restore the image to the desired color regardless of the light source.
然而,攝影裝置則會在相片上如實顯現其捕捉的色彩,相較於肉眼所見的影像,攝影裝置捕捉的白色會根據環境光源的不同,在燈光下拍攝出偏黃色調的相片,或是在陽光下拍攝出偏藍色調的相片。白平衡(White Balance)功能即是針對拍攝環境中光源色彩的影響進行補償,以使相片中的白色物體呈現白色。However, the photographic device will faithfully display the captured color on the photo. Compared with the image seen by the naked eye, the white color captured by the photographic device will take a yellowish-colored photo under the light according to the ambient light source, or Photographs with a bluish tint in the sun. The White Balance function compensates for the effects of the color of the light source in the shooting environment so that the white objects in the photo appear white.
目前的攝影裝置大多具備自動白平衡(Auto White Balance,AWB)功能,意即攝影裝置可偵測環境光源或是拍攝場景,自動對捕捉的影像進行色彩補償,但在某些場景下的應用表現仍無法滿足所預期的色彩效果。舉例來說,若拍攝場景含有混色光源,例如室內燈光及室外陽光,此二種光源分別對應於不同顏色及色溫,其中關於標準光源(Standard Light Source)的部分規範可參見如下表格1。
一般而言,白熾燈光可為顏色偏黃且色溫較低的TL84光源或是A光源,而陽光可為顏色偏藍且色溫較高的D50光源或D65光源。由於肉眼對高亮度的顏色較敏感,因此目前的自動白平衡演算法會以高亮度的光源及其對應色溫來做色彩補償。在室外的影像亮度較高的情況下,自動白平衡演算法會根據偏藍的D50光源或D65光源,對全影像補償較多的紅色,如此卻導致室內的影像偏紅。In general, the incandescent light can be a TL84 light source or an A light source with a yellowish color and a lower color temperature, and the sunlight can be a D50 light source or a D65 light source with a blue color and a higher color temperature. Since the naked eye is sensitive to high-brightness colors, the current automatic white balance algorithm performs color compensation with a high-brightness light source and its corresponding color temperature. In the case of high outdoor image brightness, the automatic white balance algorithm will compensate more red for the whole image according to the bluish D50 light source or D65 light source, which will cause the indoor image to be reddish.
因此,在混色光源場景下,目前的自動白平衡演算法無法辨識場景光源而導致色彩補償不當,造成拍攝結果色偏。有鑑於此,如何在混色光源場景下,辨識場景光源及其對應色溫以進行白平衡補償,實為本領域的重要課題之一。Therefore, in the mixed color light source scene, the current automatic white balance algorithm cannot recognize the scene light source and cause improper color compensation, resulting in color shift of the shooting result. In view of this, how to identify the scene light source and its corresponding color temperature for white balance compensation in the mixed color light source scene is one of the important topics in the field.
因此,本發明的主要目的即在於提供一種可在混色光源場景下,辨識場景光源及其對應色溫以進行動態白平衡補償的方法。Therefore, the main object of the present invention is to provide a method for recognizing a scene light source and its corresponding color temperature for dynamic white balance compensation in a mixed color light source scene.
本發明透過分析影像的亮度分佈區間,判斷混色光源的對應色溫,因此可針對不同光源及對應色溫,分別對影像中的影像區塊進行白平衡補償,以將影像還原成理想顏色。此外,針對亮度差異較小的影像,在主要亮度區間的影像面積大到足以讓全影像在不會發生色偏的前提下,僅使用主要色溫進行白平衡補償。另一方面,針對亮度差異較小的影像,當主要亮度區間的影像面積不夠大時,則先使用動態混和色溫重複地進行白平衡補償,直到主要與次要亮度區間的影像面積實質上相等或接近相等時,最後再使用主要色溫對全影像進行白平衡補償,如此可避免傳統只使用高亮度光源之單一色溫進行白平衡補償。因此,本發明可解決在混和光源下,傳統白平衡功能僅使用單一色溫進行色彩補償所導致色偏的情況。The invention determines the corresponding color temperature of the mixed color light source by analyzing the brightness distribution interval of the image, so that the image blocks in the image can be white balance compensated for different light sources and corresponding color temperatures to restore the image to an ideal color. In addition, for images with small differences in brightness, the image area in the main brightness interval is large enough for the full image to be white balance compensated using only the main color temperature without color shift. On the other hand, for an image with a small difference in brightness, when the image area of the main brightness interval is not large enough, the white balance compensation is repeatedly performed using the dynamic mixed color temperature until the image area of the main and minor brightness intervals is substantially equal or When they are nearly equal, the white color balance is compensated for the whole image by using the main color temperature. This avoids the traditional white color compensation using only the single color temperature of the high-brightness light source. Therefore, the present invention can solve the problem that the conventional white balance function uses only a single color temperature to perform color compensation due to color compensation under a mixed light source.
第1圖為本發明實施例一流程10之流程圖。流程10可用於攝影裝置或具有拍攝功能之電子裝置,流程10可編譯為一程式碼而儲存於一記憶體中,以指示攝影裝置或具有拍攝功能之電子裝置的處理器或運算單元進行影像處理,以實現白平衡補償。流程10包含以下步驟。1 is a flow chart of a process 10 of an embodiment of the present invention. The process 10 can be used for a photographing device or an electronic device having a photographing function. The process 10 can be compiled into a code and stored in a memory to instruct a photographing device or a processor or an arithmetic unit of the electronic device having the photographing function to perform image processing. To achieve white balance compensation. Process 10 includes the following steps.
步驟100:開始。Step 100: Start.
步驟101:將一影像分割為複數個區塊B1~BN。Step 101: Divide an image into a plurality of blocks B1 B BN.
步驟102:根據複數個區塊B1~BN的亮度Y1~YN,設定一主要亮度界限HY以及一次要亮度界限LY。Step 102: Set a main brightness limit HY and a primary brightness limit LY according to the brightness Y1 YN of the plurality of blocks B1 B BN.
步驟103:判斷主要亮度界限HY與次要亮度界限LY間的一差值是否大於一臨界值TH1。若是,進行步驟104;若否,進行步驟105。Step 103: Determine whether a difference between the main brightness limit HY and the secondary brightness limit LY is greater than a threshold TH1. If yes, go to step 104; if no, go to step 105.
步驟104:當複數個區塊之一者BX的亮度YX大於等於主要亮度界限HY時,根據主要亮度界限HY對應之主要色溫CT_HY,對區塊BX進行白平衡補償;當區塊BX的亮度YX小於等於次要亮度界限LY時,根據次要亮度界限LY對應之次要色溫CT_LY,對區塊BX進行白平衡補償;以及當區塊BX的亮度YX小於主要亮度界限HY且大於次要亮度界限LY時,根據主要亮度界限對應之主要色溫CT_HY、次要亮度界限對應之次要色溫CT_LY及一權重W1,對區塊BX進行白平衡補償。Step 104: When the brightness YX of one of the plurality of blocks BX is greater than or equal to the main brightness limit HY, white balance compensation is performed on the block BX according to the main color temperature CT_HY corresponding to the main brightness limit HY; when the brightness of the block BX is YX When less than or equal to the secondary brightness limit LY, white balance compensation is performed on the block BX according to the secondary color temperature CT_LY corresponding to the secondary brightness limit LY; and when the brightness YX of the block BX is smaller than the main brightness limit HY and larger than the secondary brightness limit In LY, the white balance compensation is performed on the block BX according to the main color temperature CT_HY corresponding to the main brightness limit, the secondary color temperature CT_LY corresponding to the secondary brightness limit, and a weight W1.
步驟105:根據複數個區塊B1~BN的亮度Y1~YN,計算一主要亮度面積A_HY與影像之面積A_IMG間的一比例值R_HY,以及一次要亮度面積A_LY與影像之面積A_IMG間的一比例值R_LY。Step 105: Calculate a ratio R_HY between a main luminance area A_HY and an area of the image A_IMG according to the brightness Y1 YN of the plurality of blocks B1 B BN, and a ratio between the primary brightness area A_LY and the area of the image A_IMG The value is R_LY.
步驟106:判斷比例值R_HY是否大於一臨界值TH2。若是,進行步驟107;若否,進行步驟108。Step 106: Determine whether the ratio value R_HY is greater than a threshold TH2. If yes, go to step 107; if no, go to step 108.
步驟107:根據主要色溫CT_HY,對影像進行白平衡補償。Step 107: Perform white balance compensation on the image according to the main color temperature CT_HY.
步驟108:根據主要色溫CT_HY與一權重W2之乘積加上次要色溫CT_LY與一權重W3之乘積,對影像進行白平衡補償。Step 108: Perform white balance compensation on the image according to the product of the primary color temperature CT_HY and a weight W2 plus the product of the secondary color temperature CT_LY and a weight W3.
步驟109:減小權重W2以及增加權重W3。Step 109: Reduce the weight W2 and increase the weight W3.
步驟110:計算比例值R_HY及比例值R_LY,以判斷比例值R_HY是否等於比例值R_LY。若是,回到步驟107;若否,回到步驟108。Step 110: Calculate the proportional value R_HY and the proportional value R_LY to determine whether the proportional value R_HY is equal to the proportional value R_LY. If yes, go back to step 107; if no, go back to step 108.
步驟111:結束。Step 111: End.
根據流程10,攝影裝置的處理器或運算單元將一影像分割為複數個區塊B1~BN(步驟101);根據區塊B1~BN的亮度Y1~YN(例如,Y-level),設定主要亮度界限HY以及次要亮度界限LY(步驟102);接著,判斷主要亮度界限HY與次要亮度界限LY間的差值是否大於臨界值TH1(步驟103),以判斷影像中的混色光源分佈差異大小。具體而言,若影像中含有兩種光源,則大部分的區塊B1~BN的亮度Y1~YN分佈會集中在兩個亮度區間範圍,例如大於主要亮度界限HY的一主要亮度區間以及小於次要亮度界限LY的一次要亮度區間。因此,當主要亮度界限HY與次要亮度界限LY間的差值大於臨界值TH1時,則表示兩種光源的色溫差異大,使得主要亮度區間與次要亮度區間的分佈差異大。According to the process 10, the processor or the computing unit of the photographing apparatus divides an image into a plurality of blocks B1 to BN (step 101); and sets the main according to the brightness Y1 to YN (for example, Y-level) of the blocks B1 to BN. The brightness limit HY and the secondary brightness limit LY (step 102); next, it is determined whether the difference between the main brightness limit HY and the secondary brightness limit LY is greater than the threshold TH1 (step 103) to determine the difference in the color mixture distribution in the image. size. Specifically, if the image contains two kinds of light sources, the brightness Y1 ~ YN distribution of most of the blocks B1 BBN will be concentrated in two brightness interval ranges, for example, a main brightness interval greater than the main brightness limit HY and less than The brightness interval to be the brightness limit LY. Therefore, when the difference between the main brightness limit HY and the secondary brightness limit LY is greater than the threshold TH1, it means that the color temperature difference between the two light sources is large, so that the distribution difference between the main brightness interval and the secondary brightness interval is large.
因此,於步驟104,當區塊BX(X為1~N的整數)的亮度YX大於等於主要亮度界限HY時,表示區塊BX落在主要亮度區間內,因此根據主要亮度界限HY對應之主要色溫CT_HY,對區塊BX進行白平衡補償;當區塊BX的亮度YX小於等於次要亮度界限LY時,表示區塊BX落在次要亮度區間內,因此根據次要亮度界限LY對應之次要色溫CT_LY,對區塊BX進行白平衡補償;以及當區塊BX的亮度YX小於主要亮度界限HY且大於次要亮度界限LY時,表示區塊BX落在主要亮度區間及次要亮度區間之間的交界區間內,因此根據主要亮度界限對應之主要色溫CT_HY、次要亮度界限對應之次要色溫CT_LY及一權重W1,對區塊BX進行白平衡補償,以避免處於混和色溫間的影像太突兀。在一實施例中,當區塊BX的亮度YX小於主要亮度界限HY且大於次要亮度界限LY時,使用的混和色溫可表示為:CT_LY*W1+CT_HY*(1-W1),其中權重W1為大小0~1的任意數值,並可表示為:(YX-CT_LY)/(CT_HY-CT_LY)。Therefore, in step 104, when the luminance YX of the block BX (X is an integer from 1 to N) is greater than or equal to the main luminance limit HY, it indicates that the block BX falls within the main luminance interval, and therefore the main corresponding to the main luminance limit HY The color temperature CT_HY performs white balance compensation on the block BX; when the brightness YX of the block BX is less than or equal to the secondary brightness limit LY, it indicates that the block BX falls within the secondary brightness interval, so corresponding to the secondary brightness limit LY For the color temperature CT_LY, the white balance compensation is performed on the block BX; and when the brightness YX of the block BX is smaller than the main brightness limit HY and larger than the secondary brightness limit LY, it indicates that the block BX falls within the main brightness interval and the secondary brightness interval. In the boundary interval between the two, therefore, according to the main color temperature CT_HY corresponding to the main brightness limit, the secondary color temperature CT_LY corresponding to the secondary brightness limit, and a weight W1, the white balance compensation is performed on the block BX to avoid the image between the mixed color temperatures. unexpected. In an embodiment, when the brightness YX of the block BX is smaller than the main brightness limit HY and greater than the secondary brightness limit LY, the mixed color temperature used may be expressed as: CT_LY*W1+CT_HY*(1-W1), wherein the weight W1 is the size Any value from 0 to 1 can be expressed as: (YX-CT_LY) / (CT_HY-CT_LY).
另一方面,當主要亮度界限HY與次要亮度界限LY間的差值不大於臨界值TH1時,則表示兩種光源的色溫差異小,使得主要亮度區間與次要亮度區間的分佈差異小。在此情況下,則需進一步考慮主要亮度區間在全影像中所佔的面積比例R_HY是否大於臨界值TH2,以判斷屬於主要亮度區間的影像面積是否大到足以讓全影像在不會發生色偏的前提下,僅使用主要色溫CT_HY進行白平衡補償。因此,進一步根據B1~BN的亮度Y1~YN,計算主要亮度面積A_HY與影像之面積A_IMG間的比例值R_HY以及次要亮度面積A_LY與影像之面積A_IMG間的比例值R_LY(步驟105);判斷比例值R_HY是否大於臨界值TH2(步驟106);當比例值R_HY大於臨界值TH2時,根據主要色溫CT_HY,對區塊BX進行白平衡補償(步驟107)。比例值R_HY可表示為A_HY/A_IMG,而比例值R_LY可表示為A_LY/A_IMG。在一實施例中,判斷比例值R_LY是否小於另一臨界值,可判斷屬於次要亮度區間的影像面積是否小到足以忽略,讓全影像在不會發生色偏的前提下,僅使用主要色溫CT_HY進行白平衡補償。On the other hand, when the difference between the main brightness limit HY and the secondary brightness limit LY is not greater than the threshold TH1, it means that the color temperature difference between the two light sources is small, so that the distribution difference between the main brightness interval and the secondary brightness interval is small. In this case, it is necessary to further consider whether the area ratio R_HY occupied by the main brightness interval in the full image is greater than the threshold TH2, so as to determine whether the image area belonging to the main brightness interval is large enough to prevent color shift of the entire image. Under the premise, only the main color temperature CT_HY is used for white balance compensation. Therefore, according to the brightnesses Y1 to YN of B1 to BN, the ratio R_HY between the main luminance area A_HY and the area A_IMG of the image and the ratio R_LY between the minor luminance area A_LY and the area A_IMG of the image are calculated (step 105); Whether the scale value R_HY is greater than the threshold TH2 (step 106); when the scale value R_HY is greater than the threshold TH2, the white balance compensation is performed on the block BX according to the primary color temperature CT_HY (step 107). The scale value R_HY can be expressed as A_HY/A_IMG, and the scale value R_LY can be expressed as A_LY/A_IMG. In an embodiment, determining whether the ratio value R_LY is smaller than another threshold value, determining whether the image area belonging to the secondary brightness interval is small enough to be ignored, so that the entire image uses only the main color temperature without causing color shift. CT_HY performs white balance compensation.
此外,當主要亮度界限HY對應之面積比例值R_HY不大於臨界值TH2時,則判斷屬於主要亮度區間的影像面積不夠大,若僅使用主要色溫CT_HY對全影像進行白平衡補償,可能會發生色偏。在此情況下,需先使用動態混和色溫重複地對全影像進行白平衡補償,直到主要亮度界限HY對應之面積比例值R_HY實質上等於或接近次要亮度界限LY對應之面積比例值R_LY時,最後再使用主要色溫CT_HY對全影像進行白平衡補償。值得注意的是,動態混和色溫是由遞減的主要色溫CT_HY以及遞增的次要色溫CT_LY所合成,可逐漸削弱主要色溫CT_HY對全影像的白平衡補償,以及逐漸加強屬於次要色溫CT_LY對全影像的白平衡補償,如此可在後續以主要色溫CT_HY對全影像進行白平衡補償時,避免發生色偏情況。In addition, when the area ratio value R_HY corresponding to the main brightness limit HY is not greater than the threshold value TH2, it is determined that the image area belonging to the main brightness interval is not large enough, and if the white color balance compensation is performed on the entire image using only the main color temperature CT_HY, color may occur. Partial. In this case, it is necessary to repeatedly perform white balance compensation on the entire image using the dynamic mixed color temperature until the area ratio value R_HY corresponding to the main brightness limit HY is substantially equal to or close to the area ratio value R_LY corresponding to the secondary brightness limit LY. Finally, white balance compensation is performed on the entire image using the main color temperature CT_HY. It is worth noting that the dynamic mixed color temperature is synthesized by the decreasing primary color temperature CT_HY and the increasing secondary color temperature CT_LY, which can gradually weaken the white color balance of the main color temperature CT_HY for the whole image, and gradually strengthen the secondary image to the secondary color temperature CT_LY. The white balance compensation can avoid the occurrence of color shift when the white balance compensation is performed on the whole image with the main color temperature CT_HY.
因此,當比例值R_HY不大於臨界值TH2時,根據一動態混和色溫(其為主要亮度界限對應之主要色溫CT_HY與權重W2之乘積以及次要亮度界限對應之次要色溫CT_LY與權重W3之乘積),對影像進行白平衡補償(步驟108);減小權重W2以減小主要色溫CT_HY於動態混和色溫中的成分,以及增加權重W3以增加次要色溫CT_LY於動態混和色溫中的成分(步驟109);以及判斷比例值R_HY是否等於比例值R_LY(步驟110)。當比例值R_HY實質上等於比例值R_LY時,根據主要色溫CT_HY,對影像進行白平衡補償(回到步驟107);當比例值R_HY實質上不等於比例值R_LY時,使用動態混和色溫,對影像進行白平衡補償(回到步驟108)。在一實施例中,動態混和色溫可表示為:CT_HY*W2+CT_LY*W3,其中權重W2可等於比例值R_HY,權重W3可等於比例值R_LY或表示為(1-W2)。在一實施例中,於步驟109,每次可減小權重W2以及增加權重W3一單位比例值,例如5%。Therefore, when the scale value R_HY is not greater than the threshold TH2, the product of the dynamic color temperature (which is the product of the primary color temperature CT_HY and the weight W2 corresponding to the main brightness limit and the secondary color temperature CT_LY and the weight W3 corresponding to the secondary brightness limit) Performing white balance compensation on the image (step 108); reducing the weight W2 to reduce the component of the main color temperature CT_HY in the dynamic mixed color temperature, and increasing the weight W3 to increase the component of the secondary color temperature CT_LY in the dynamic mixed color temperature (steps) 109); and determining whether the scale value R_HY is equal to the ratio value R_LY (step 110). When the ratio value R_HY is substantially equal to the ratio value R_LY, white balance compensation is performed on the image according to the main color temperature CT_HY (return to step 107); when the scale value R_HY is substantially not equal to the scale value R_LY, the dynamic mixed color temperature is used to image White balance compensation is performed (back to step 108). In an embodiment, the dynamic blending color temperature may be expressed as: CT_HY*W2+CT_LY*W3, wherein the weight W2 may be equal to the proportional value R_HY, and the weight W3 may be equal to the proportional value R_LY or expressed as (1-W2). In an embodiment, at step 109, the weight W2 may be decreased and the weight W3 may be decreased by a unit ratio value, for example, 5%.
除此之外,於步驟101,當影像分割為區塊B1~BN後,傳統的自動白平衡演算法會將區塊B1~BN由RGB色彩空間座標轉換為YCbCr色彩空間座標表示,藉以找出亮度過高或是過低的影像畫素,並將之視為無效的影像畫素;接著再將區塊B1~BN轉換為HSV色彩空間座標表示,藉以找出飽和度過高的影像畫素,並將之視為無效的影像畫素。透過上述色彩空間座標轉換,篩選並統計出屬於中性色調的影像畫素以及去除不必要的影像畫素資訊後,判斷區塊B1~BN的主要亮度畫素是否屬於一特定色溫且次要亮度畫素是否屬於另一特定色溫,其中對應主要及次要亮度畫素之特定色溫可根據使用者設定或自動偵測。當區塊B1~BN的主要亮度畫素屬於該特定色溫且次要亮度畫素屬於該另一特定色溫時,則依照主要亮度畫素之該特定色溫,對全影像進行白平衡補償。反之,當區塊B1~BN的主要亮度畫素不屬於該特定色溫且次要亮度畫素不屬於該另一特定色溫時,則執行步驟102~110,以進行動態白平衡補償。In addition, in step 101, after the image is divided into blocks B1 B BN, the conventional automatic white balance algorithm converts the blocks B1 B BN into RGB color space coordinates to represent YCbCr color space coordinates, thereby finding out The image pixels whose brightness is too high or too low are regarded as invalid image pixels; then the blocks B1 to BN are converted into HSV color space coordinates to find the image pixels with too high saturation. And treat it as an invalid image pixel. Through the above color space coordinate conversion, screening and counting the image pixels belonging to the neutral color and removing the unnecessary image pixel information, determining whether the main brightness pixels of the blocks B1 B BN belong to a specific color temperature and the secondary brightness Whether the pixel belongs to another specific color temperature, wherein the specific color temperature corresponding to the primary and secondary luminance pixels can be set according to the user or automatically detected. When the main luminance pixels of the blocks B1 B BN belong to the specific color temperature and the secondary luminance pixels belong to the other specific color temperature, white balance compensation is performed on the entire image according to the specific color temperature of the main luminance pixels. On the other hand, when the main luminance pixels of the blocks B1 B BN do not belong to the specific color temperature and the secondary luminance pixels do not belong to the other specific color temperature, steps 102 to 110 are performed to perform dynamic white balance compensation.
簡言之,本發明透過分析影像的亮度分佈區間,判斷混色光源的對應色溫,因此可針對不同光源及對應色溫,分別對影像中的影像區塊進行白平衡補償,以將影像還原成理想顏色,其中位於主要亮度區間及次要亮度區間之間的交界區間內的影像區塊可根據加權之主要色溫及次要色溫進行白平衡補償,以避免處於混和色溫間的影像太突兀(步驟101~104)。此外,針對亮度差異較小的影像,在主要亮度區間的影像面積大到足以讓全影像在不會發生色偏的前提下,僅使用主要色溫進行白平衡補償(步驟105~107)。另一方面,當主要亮度區間的影像面積不夠大時,則先使用動態混和色溫重複地對全影像進行白平衡補償,直到主要與次要亮度區間的影像面積實質上相等或接近相等時,最後再使用主要色溫對全影像進行白平衡補償(步驟107~110),如此可避免傳統只使用高亮度光源之單一色溫進行白平衡補償。因此,透過流程10,本發明可解決在混和光源下,傳統白平衡功能僅使用單一色溫進行色彩補償所導致色偏的情況。In short, the present invention determines the corresponding color temperature of the mixed color light source by analyzing the brightness distribution interval of the image, so that the image blocks in the image can be white balance compensated for different light sources and corresponding color temperatures to restore the image to the desired color. The image block located in the boundary between the main brightness interval and the secondary brightness interval may perform white balance compensation according to the weighted primary color temperature and the secondary color temperature to prevent the image between the mixed color temperatures from being too abrupt (step 101~) 104). In addition, for images with small differences in brightness, the image area in the main brightness interval is large enough to allow white balance compensation using only the main color temperature without premature color shift (steps 105-107). On the other hand, when the image area of the main brightness interval is not large enough, the white balance compensation of the entire image is repeatedly performed using the dynamic mixed color temperature until the image areas of the main and minor brightness intervals are substantially equal or nearly equal, and finally Then use the main color temperature to perform white balance compensation on the whole image (steps 107-110), so that the white balance compensation can be avoided by using a single color temperature of the high-brightness light source. Therefore, through the process 10, the present invention can solve the problem that the conventional white balance function uses only a single color temperature to perform color compensation caused by color compensation under the mixed light source.
請注意,上述臨界值TH1、TH2,權重W1、W2、W3,調整權重W2及權重W3的單位比例值,以及其他相關條件參數可依據不同應用場景進行調整,而未有所限。Please note that the above-mentioned thresholds TH1, TH2, the weights W1, W2, W3, the adjustment weight W2, and the unit ratio value of the weight W3, and other related condition parameters can be adjusted according to different application scenarios, but are not limited.
第2圖繪示一原始影像IMG_RAW。第3圖繪示本發明實施例一補償影像IMG_WB。當攝影裝置的處理器或運算單元收到原始影像IMG_RAW後,將之分割為複數個區塊B1~BN(例如,以8*8分割為64個區塊,即區塊B1~B64),接著 分別計算每一區塊的亮度(Y-level,以8-bit影像畫素為例,其為0~255之數值),假設區塊B30~B32、B37~B40、B45~B48的亮度介於158至179(主要亮度界限HY假設為158),其餘區塊的亮度介於20至65(次要亮度界限LY假設為65)。由上述資訊可知,主要亮度面積A_HY(即,亮度介於158至179之區塊的總面積)佔原始影像IMG_RAW總面積的比例為11/64(約17.2%),次要亮度面積A_LY(即,亮度介於20至65之區塊的總面積)佔原始影像IMG_RAW總面積的比例為53/64(約82.8%)。對每一區塊BX進行色彩分析後(X表示1~64之整數),假設色溫為D50光源的區塊判定屬於主要亮度區間,而色溫為A光源的區塊判定屬於次要亮度區間。因此,透過上述分析,原始影像IMG_RAW中的每一區塊BX可針對不同色溫,動態地進行白平衡補償。Figure 2 shows an original image IMG_RAW. FIG. 3 illustrates a compensated image IMG_WB according to an embodiment of the present invention. After the processor or the arithmetic unit of the photographing device receives the original image IMG_RAW, it is divided into a plurality of blocks B1 B BN (for example, 64 blocks are divided into 8 blocks, that is, blocks B1 B B64), and then Calculate the brightness of each block separately (Y-level, taking 8-bit image pixels as an example, which is a value from 0 to 255), assuming that the brightness of blocks B30-B32, B37-B40, B45-B48 is between 158 to 179 (the main brightness limit HY is assumed to be 158), and the remaining blocks have a brightness between 20 and 65 (the secondary brightness limit LY is assumed to be 65). It can be seen from the above information that the main luminance area A_HY (that is, the total area of the block with the brightness between 158 and 179) accounts for 11/64 (about 17.2%) of the total area of the original image IMG_RAW, and the secondary brightness area A_LY (ie, The total area of the block with a brightness between 20 and 65) is 53/64 (about 82.8%) of the total area of the original image IMG_RAW. After color analysis is performed for each block BX (X represents an integer of 1 to 64), it is assumed that the block whose color temperature is the D50 light source is determined to belong to the main luminance interval, and the block whose color temperature is the A light source is determined to belong to the secondary luminance interval. Therefore, through the above analysis, each block BX in the original image IMG_RAW can dynamically perform white balance compensation for different color temperatures.
當主要亮度界限HY(例如,158)與次要亮度界限LY(例如,65)間的差值大於臨界值TH1時,則每一區塊BX以各自亮度所對應的色溫進行白平衡補償。舉例來說,亮度介於20至65的區塊BX可根據A光源所對應的色溫進行白平衡補償,亮度介於158至179的區塊BX可根據D50光源所對應的色溫進行白平衡補償,亮度介於159至178的區塊BX可根據D50光源對應的色溫、A光源對應的色溫及加權W1進行白平衡補償。When the difference between the main brightness limit HY (for example, 158) and the secondary brightness limit LY (for example, 65) is greater than the threshold TH1, each block BX performs white balance compensation with the color temperature corresponding to the respective brightness. For example, the block BX with brightness between 20 and 65 can perform white balance compensation according to the color temperature corresponding to the A light source, and the block BX with brightness between 158 and 179 can perform white balance compensation according to the color temperature corresponding to the D50 light source. The block BX having a brightness between 159 and 178 can perform white balance compensation according to the color temperature corresponding to the D50 light source, the color temperature corresponding to the A light source, and the weight W1.
另一方面,當主要亮度界限HY與次要亮度界限LY間的差值不大於臨界值TH1時,則進一步判斷主要亮度面積A_HY佔原始影像IMG_RAW總面積的比例值R_HY是否大於臨界值TH2(例如,80%)。當比例值R_HY大於臨界值TH2時,則根據D50光源所對應的色溫對原始影像IMG_RAW進行白平衡補償。反之,當比例值R_HY不大於臨界值TH2時,則根據遞減之D50光源所對應的色溫以及遞增之A光源所對應的色溫進行白平衡補償(例如,每次遞減及遞增5%),直到比例值R_HY實質上等於或接近比例值R_LY,最後再根據D50光源所對應的色溫進行白平衡補償。如此一來,透過上述動態白平衡補償,即可產生第3圖之補償影像IMG_WB。On the other hand, when the difference between the main brightness limit HY and the secondary brightness limit LY is not greater than the threshold TH1, it is further determined whether the ratio of the main brightness area A_HY to the total area of the original image IMG_RAW R_HY is greater than the threshold TH2 (eg , 80%). When the scale value R_HY is greater than the threshold TH2, the white balance compensation is performed on the original image IMG_RAW according to the color temperature corresponding to the D50 light source. Conversely, when the ratio value R_HY is not greater than the threshold value TH2, the white balance compensation is performed according to the color temperature corresponding to the decreasing D50 light source and the color temperature corresponding to the increasing A light source (for example, each decrement and increment by 5%) until the ratio The value R_HY is substantially equal to or close to the proportional value R_LY, and finally the white balance compensation is performed according to the color temperature corresponding to the D50 light source. In this way, the compensated image IMG_WB of FIG. 3 can be generated by the dynamic white balance compensation described above.
第4圖繪示原始影像IMG_RAW的色階分佈圖,第5圖繪示本發明實施例補償影像IMG_WB的色階分佈圖,其中紅色畫素R的色階分佈以斜線圖案表示,綠色畫素G的色階分佈以空白表示,且藍色畫素B的色階分佈以點圖案表示。4 is a chromatic level distribution diagram of the original image IMG_RAW, and FIG. 5 is a chromatic level distribution diagram of the compensation image IMG_WB according to an embodiment of the present invention, wherein the gradation distribution of the red pixel R is represented by a diagonal line pattern, and the green pixel G The gradation distribution is indicated by a space, and the gradation distribution of the blue pixel B is represented by a dot pattern.
於第4圖中,原始影像IMG_RAW在使用傳統白平衡演算法的情況下,紅色畫素R的色階分佈約佔全影像畫素的79.13%,綠色畫素G的色階分佈約佔全影像畫素的11.09%,藍色畫素B的色階分佈約佔全影像畫素的0.57%。紅色畫素R與綠色畫素G的比值R/G約為7.13,而藍色畫素B與綠色畫素G的比值B/G約為0.57。由此可見,在混和光源下,若僅使用偏藍色調的單一光源所對應的色溫進行白平衡補償會導致色偏,紅色與藍色畫素R、B的比例差異大,造成原始影像IMG_RAW偏紅。In Fig. 4, when the original image IMG_RAW uses the traditional white balance algorithm, the gradation distribution of the red pixel R accounts for about 79.13% of the total image pixels, and the gradation distribution of the green pixel G accounts for the full image. The 10.19% of the pixels and the gradation distribution of the blue pixel B account for about 0.57% of the total image pixels. The ratio R/G of the red pixel R to the green pixel G is about 7.13, and the ratio B/G of the blue pixel B to the green pixel G is about 0.57. It can be seen that under the mixed light source, if the white balance compensation is performed only by the color temperature corresponding to the single light source with the bluish tone, the color shift will be caused, and the ratio of the red and blue pixels R and B will be greatly different, resulting in the original image IMG_RAW. red.
於第5圖中,補償影像IMG_WB的紅色畫素R的色階分佈約佔全影像畫素的68.05%,綠色畫素G的色階分佈約佔全影像畫素的31.94%,藍色畫素B的色階分佈約佔全影像畫素的11.46%。紅色畫素R與綠色畫素G的比值R/G約為2.13,而藍色畫素B與綠色畫素G的比值B/G約為0.35。由此可見,在混和光源下,透過流程10之動態白平衡補償,可使補償影像IMG_WB的色階分佈較均勻,紅色與藍色畫素R、B的比例差異小,以將補償影像IMG_WB還原成理想顏色。In Fig. 5, the gradation distribution of the red pixel R of the compensated image IMG_WB accounts for about 68.05% of the total image pixel, and the gradation distribution of the green pixel G accounts for 31.94% of the total image pixel, the blue pixel The gradation distribution of B accounts for about 11.46% of the total image pixels. The ratio R/G of the red pixel R to the green pixel G is about 2.13, and the ratio B/G of the blue pixel B to the green pixel G is about 0.35. It can be seen that under the mixed light source, the dynamic white balance compensation of the flow 10 can make the gradation distribution of the compensated image IMG_WB relatively uniform, and the difference ratio of the red and blue pixels R and B is small to restore the compensated image IMG_WB. Into the ideal color.
綜上所述,本發明透過分析影像的亮度分佈區間,判斷混色光源的對應色溫,因此可針對不同光源及對應色溫,分別對影像中的影像區塊進行白平衡補償,以將影像還原成理想顏色。此外,針對亮度差異較小的影像,本發明根據主要亮度區間的影像面積佔全影像的面積比例,使用動態混和色溫對全影像進行白平衡補償,如此可避免傳統只使用高亮度光源之單一色溫進行白平衡補償。因此,透過上述方式,本發明可解決在混和光源下,傳統白平衡功能僅使用單一色溫進行色彩補償所導致色偏的情況。 以上所述僅為本發明之較佳實施例,凡依本發明申請專利範圍所做之均等變化與修飾,皆應屬本發明之涵蓋範圍。In summary, the present invention determines the corresponding color temperature of the mixed color light source by analyzing the brightness distribution interval of the image. Therefore, the white balance compensation can be performed on the image blocks in the image for different light sources and corresponding color temperatures to restore the image to an ideal image. colour. In addition, for an image with a small difference in brightness, the present invention uses the dynamic mixed color temperature to perform white balance compensation on the entire image according to the ratio of the image area of the main brightness interval to the total image area, thereby avoiding the traditional single color temperature using only the high-intensity light source. Perform white balance compensation. Therefore, in the above manner, the present invention can solve the problem that the conventional white balance function uses only a single color temperature for color compensation to cause color shift under a mixed light source. The above are only the preferred embodiments of the present invention, and all changes and modifications made to the scope of the present invention should be within the scope of the present invention.
10‧‧‧流程
100~110‧‧‧步驟
B1~BN、BX‧‧‧區塊
HY、LY、Y1~YN、YX‧‧‧亮度
TH1、TH2‧‧‧臨界值
A_HY、A_LY、A_IMG‧‧‧面積
R_HY、R_LY‧‧‧比例值
CT_HY、CT_LY‧‧‧色溫
W1、W2、W3‧‧‧權重
IMG_RAW‧‧‧原始影像
IMG_WB‧‧‧補償影像
R、G、B‧‧‧畫素10‧‧‧ Process
100~110‧‧‧Steps
Block B1~BN, BX‧‧‧
HY, LY, Y1 ~ YN, YX‧‧‧ brightness
TH1, TH2‧‧‧ threshold
A_HY, A_LY, A_IMG‧‧‧ area
R_HY, R_LY‧‧‧ ratio
CT_HY, CT_LY‧‧‧ color temperature
W1, W2, W3‧‧‧ weights
IMG_RAW‧‧‧ original image
IMG_WB‧‧‧Compensated image
R, G, B‧‧ ‧ pixels
第1圖為本發明實施例一流程之流程圖。 第2圖繪示一原始影像。 第3圖繪示本發明實施例一補償影像。 第4圖繪示第2圖之原始影像的色階分佈圖。 第5圖繪示本發明實施例第3圖之補償影像的色階分佈圖。FIG. 1 is a flow chart of a process of an embodiment of the present invention. Figure 2 depicts an original image. FIG. 3 illustrates a compensated image according to an embodiment of the present invention. Figure 4 is a diagram showing the gradation distribution of the original image of Figure 2. FIG. 5 is a diagram showing the gradation distribution of the compensated image in the third embodiment of the embodiment of the present invention.
10‧‧‧流程 10‧‧‧ Process
100~110‧‧‧步驟 100~110‧‧‧Steps
Claims (8)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW105112811A TW201738841A (en) | 2016-04-25 | 2016-04-25 | Method of dynamic adjustment to automatic white balance under hybrid light sources |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW105112811A TW201738841A (en) | 2016-04-25 | 2016-04-25 | Method of dynamic adjustment to automatic white balance under hybrid light sources |
Publications (1)
Publication Number | Publication Date |
---|---|
TW201738841A true TW201738841A (en) | 2017-11-01 |
Family
ID=61022467
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
TW105112811A TW201738841A (en) | 2016-04-25 | 2016-04-25 | Method of dynamic adjustment to automatic white balance under hybrid light sources |
Country Status (1)
Country | Link |
---|---|
TW (1) | TW201738841A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113099202A (en) * | 2021-02-24 | 2021-07-09 | 浙江大华技术股份有限公司 | Automatic white balance optimization method, equipment and computer readable storage medium |
CN114374830A (en) * | 2022-01-06 | 2022-04-19 | 杭州海康威视数字技术股份有限公司 | Image white balance method, electronic device and computer readable storage medium |
-
2016
- 2016-04-25 TW TW105112811A patent/TW201738841A/en unknown
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113099202A (en) * | 2021-02-24 | 2021-07-09 | 浙江大华技术股份有限公司 | Automatic white balance optimization method, equipment and computer readable storage medium |
CN114374830A (en) * | 2022-01-06 | 2022-04-19 | 杭州海康威视数字技术股份有限公司 | Image white balance method, electronic device and computer readable storage medium |
CN114374830B (en) * | 2022-01-06 | 2024-03-08 | 杭州海康威视数字技术股份有限公司 | Image white balance method, electronic device and computer readable storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
TWI660633B (en) | White balance calibration method based on skin color data and image processing apparatus thereof | |
US11277595B2 (en) | White balance method for image and terminal device | |
CN104796683B (en) | A kind of method and system of calibration image color | |
CN102611897B (en) | Method and system for carrying out vision perception high-fidelity transformation on color digital image | |
EP2426928B1 (en) | Image processing apparatus, image processing method and program | |
CN103108469B (en) | Method and device for controlling output light of illuminating device and illuminating system | |
WO2021218603A1 (en) | Image processing method and projection system | |
CN108234971A (en) | White balance parameter determines method, white balance adjustment method and device, storage medium, terminal | |
CN107135384A (en) | White balance adjusting method, device, image processing terminal and storage medium | |
CN111311500B (en) | A method and device for color restoration of an image | |
US10631016B2 (en) | Dynamic range compression device and image processing device | |
TWI736599B (en) | Method for detection of saturated pixels in an image | |
TW201738841A (en) | Method of dynamic adjustment to automatic white balance under hybrid light sources | |
WO2022120799A1 (en) | Image processing method and apparatus, electronic device, and storage medium | |
TW201515472A (en) | HVS-based radiometric compensation system | |
CN108462865A (en) | Method and equipment for determining light source of image and carrying out color vision adaptation on image | |
TWI544451B (en) | Image processing method | |
CN110809145B (en) | Image brightness transformation method, device and device based on Craik-O'Brien effect | |
CN108965685A (en) | A kind of image processing method and device | |
KR20110131612A (en) | Automatic white balance setting method by white detection considering sensor characteristics | |
WO2022032666A1 (en) | Image processing method and related apparatus | |
CN114339094B (en) | Image processing method, device, storage medium and terminal | |
CN108765502A (en) | A kind of color looks acquisition methods under complex environment | |
TW201417586A (en) | Method for regulating white balancing | |
CN110392245B (en) | White balance correction method based on skin color information and image processing device thereof |