主要内容

Chromadapt

Adjust color balance of RGB image with chromatic adaptation

描述

example

B= chromadapt(A,illuminant)调整色彩平衡sRGB imageA根据现场照明。照明剂必须与输入图像相同的颜色空间。

example

B= chromadapt(A,illuminant,Name,Value)调整色彩平衡Ausing name-value pairs to control additional options.

例子

全部收缩

Read and display an image with a strong yellow color cast.

A = imread('hallway.jpg');imshow(a)标题('Original Image')

图包含一个轴对象。The axes object with title Original Image contains an object of type image.

Pick a pixel in the image that should look white or gray, such as a point on a pillar. Do not pick a saturated pixel, such as a point on the ceiling light. Display the selected point in green.

x = 2800;y = 1000;gray_val = impixel(a,x,y);drawpoint('位置',[x y],'颜色','g');

图包含一个轴对象。带有标题原始图像的轴对象包含2个类型图像的对象,images.roi.point。

Use the selected color as reference for the scene illumination, and correct the white balance of the image.

b = chromadapt(a,gray_val);

Display the corrected image. The pillars now appear white as expected, and the rest of the image has no yellow tint.

imshow(B) title(“白色平衡图像”)

图包含一个轴对象。The axes object with title White-Balanced Image contains an object of type image.

Open an image file containing minimally processed linear RGB intensities.

A = imread(“ foosballraw.tiff”);

The image data is the raw sensor data after correcting the black level and scaling to 16 bits per pixel. Interpolate the intensities to reconstruct color. The color filter array pattern is RGGB.

a = demosaic(a,"rggb");

显示图像。由于图像是在线性RGB颜色空间中的,因此请应用伽马校正,以便在屏幕上正确显示图像。

a_srgb = lin2rgb(a);imshow(a_srgb)标题("Original Image")

图包含一个轴对象。The axes object with title Original Image contains an object of type image.

该图像在场景中具有ColorChecker®图表。要获取环境光的颜色,请在图表的中性斑块之一中显示像素的RGB值。红色通道的强度低于其他两个通道的强度,这表明光是蓝绿色。

x = 1510; y = 1250; light_color = [A(y,x,1) A(y,x,2) A(y,x,3)]
light_color =1x3 uint16 row vector7361 14968 10258

Balance the color channels of the image. Use theColorSpacename-value argument to specify that the image and the illuminant are expressed in linear RGB.

b = chromadapt(a,light_color,"ColorSpace","linear-rgb");

用伽玛校正显示颜色平衡的图像。

B_sRGB = lin2rgb(B); imshow(B_sRGB) title("Color-Balanced Image")

图包含一个轴对象。The axes object with title Color-Balanced Image contains an object of type image.

Confirm that the gray patch has been color balanced. The three color channels in the color-balanced gray patch have similar intensities, as expected.

Patch_color = [B(Y,X,1)B(Y,X,2)B(Y,X,3)]
Patch_color =1x3 uint16 row vector13010 13010 13010

Input Arguments

全部收缩

RGB图像, specified as anm-经过-n-by-3数字阵列.

Data Types:single|double|uint8|UINT16

Scene illuminant, specified as a 3-element numeric vector. The illuminant must be in the same color space as the input image,A.

Data Types:single|double|uint8|UINT16

Name-Value Arguments

将可选的参数对Name1=Value1,...,NameN=ValueN, whereNameis the argument name and价值是相应的值。名称值参数必须在其他参数之后出现,但是对的顺序并不重要。

Before R2021a, use commas to separate each name and value, and encloseNamein quotes.

例子:I2 = chromadapt(I,uint8([22 97 118]),'ColorSpace','linear-rgb')调整图像的色彩平衡,I,在线性RGB颜色空间中。

输入图像的颜色空间和照明剂,指定为逗号分隔对'色彩空间''srgb','adobe-rgb-1998', or'linear-rgb'. Use the'linear-rgb'option to adjust the color balance of an RGB image whose intensities are linear.

Data Types:char|string

用于扩展RGB值的色度适应方法A, specified as the comma-separated pair consisting of'Method'还有一个:

  • 'bradford'- 使用布拉德福德锥响应模型的规模

  • 'vonkries'—Scale using the von Kries cone response model

  • 'simple'—Scale using the illuminant

Data Types:char|string

Output Arguments

全部收缩

Color-balanced RGB image, returned as anm-经过-n-by-3数字阵列of the same data type asA.

参考

[1] Lindbloom,布鲁斯。色度适应。http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html.

Version History

Introduced in R2017b