Chromadapt
Adjust color balance of RGB image with chromatic adaptation
描述
调整色彩平衡sRGB imageB
= chromadapt(A
,illuminant
)A
根据现场照明。照明剂必须与输入图像相同的颜色空间。
调整色彩平衡B
= chromadapt(A
,illuminant
,Name,Value
)A
using name-value pairs to control additional options.
例子
Color Balance Image by Specifying Gray Pixel
Read and display an image with a strong yellow color cast.
A = imread('hallway.jpg');imshow(a)标题('Original 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');
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(“白色平衡图像”)
Color Balance Image in Linear RGB Color Space
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")
该图像在场景中具有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 theColorSpace
name-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")
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
A
—RGB图像
m-经过-n-by-3数字阵列
RGB图像, specified as anm-经过-n-by-3数字阵列.
Data Types:single
|double
|uint8
|UINT16
illuminant
—Scene illuminant
3元素数字向量
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
, whereName
is the argument name and价值
是相应的值。名称值参数必须在其他参数之后出现,但是对的顺序并不重要。
Before R2021a, use commas to separate each name and value, and encloseName
in quotes.
例子:I2 = chromadapt(I,uint8([22 97 118]),'ColorSpace','linear-rgb')
调整图像的色彩平衡,I
,在线性RGB颜色空间中。
ColorSpace
—色彩空间
'srgb'
(default) |'adobe-rgb-1998'
|'linear-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
Method
—色度适应方法
'bradford'
(default) |'vonkries'
|'simple'
用于扩展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
参考
[1] Lindbloom,布鲁斯。色度适应。http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html.
Version History
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
选择一个网站
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
您还可以从以下列表中选择一个网站:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
美洲
- AméricaLatina(Español)
- 加拿大(英语)
- 美国(英语)