史蒂夫与MATLAB图像处理

图像处理的概念、算法和MATLAB

More experiments with sRGB gamut boundary in L * a * b * space

我仍然和RGB色域计算 ^ * ^ ^ * b * $L $ Space. (See my last post on this topic. "Visualizing the out - of - gamut colors in a Lab curve." ) Today 's post the features some new gamut - related visualizations, plus some computational tricks involving gamut boundaries and rays in ^ * ^ ^ * b * $L $ 空间。
首先,这里是另一种交流的想法in-gamut区域 $(^ ^ *, b *) $ 飞机随 L ^ * $美元 (perceptual lightness). For 9 values of L ^ * $美元 (10年,20年,……,90), I'll compute a 2-D $(^ ^ *, b *) $ Gamut mask by brute - forcing it. Then, I "l l use overlaid contour plots to show the variation in gamut boundaries.
A = - 110:. 1:11 0;
B = - 110:. 1:11 0;
L = 10:20:90;
(aa、bb、LL) = meshgrid (a、b L);
持有on
k = 1:长度(L)
rgb = lab2rgb(猫(LL (:,:, k), aa (:,:, k), bb (:,:, k)));
Mask = all (< = RGB (0) & (RGB < = 1), 3) * 2-1 + L (k);
轮廓(a, b,面具,[L (k) L (k)], LineColor = [。8。8。8),线宽= 1.5,ShowText = true,...
LabelSpacing = 288)
结束
持有
The axisequal
The gridon
盒子on
Xlabel ("A *")
Ylabel (“b *”)
The title (“色域边界(a, b)飞机数的值L *”)
这是另一个可视化的概念。人们经常显示颜色 $(^ ^ *, b *) $ Plane, to difference an idea of the fancy of $ ^ * $ The and ^ * $ $ b , but that doesn 't communicate very well, the idea that there are usually multiple colors, corresponding to various L ^ * $美元 Values, at any one $(^ ^ *, b *) $ The location. Below, I show both the brightest - gamut color and in the darkest in - gamut color at each $(^ ^ *, b *) $ The location.
一个= 110:110;
b = 110:110;
Aa, bb] [= meshgrid (a, b);
L_max = 0(大小(aa));
L_min = 0(大小(aa));
P = 1: size (aa, 1)
Q = 1: size (bb, 1)
[L_min (p, q), L_max (p, q)] = Lrange (aa (p, q), bb (p, q));
结束
结束
rgb = lab2rgb(猫(3 L_max aa、bb));
figure
Tiledlayout (1, 2)
nexttile
imshow (rgb, XData =([1]结束),YData = b(结束[1]))
The axisThe xy
The axison
xlabel一个
ylabelb
The title (“聪明的in-gamut颜色”)
rgb_min = lab2rgb(猫(3 L_min aa、bb));
nexttile
Imshow (rgb_min, XData = a (end [1]), YData = b (end [1]))
The axison
The axisThe xy
xlabel一个
ylabelb
The title ("Darkest in - gamut color")
Next, I find myself sometimes wanting to draw a ray in ^ * ^ ^ * b * $L $ 空间和发现色域边界的位置沿射线。为此,我写了一个简单的效用函数( findNonzeroBoundary 下图)执行一个二叉搜索找到一个函数从积极到0。然后,我写了一些匿名函数找到所需的色域边界点。具体地说,我很感兴趣这个问题:对于一个给定的 L ^ * $美元 The value and given a $(^ ^ *, b *) $ 平面的角度, h ,什么是in-gamut颜色最大浓度, c , or short the from $$(0, 0) In the $(^ ^ *, b *) $ 飞机吗?
Fair warning : the code below gets tricky with anonymous functions provides. You took hate it. If so, I totally understand, and I hope You 'l l forgive me. : -)
我将首先创建一个匿名函数,转换 H $$L ^ * c The to ^ * ^ ^ * b * $L $ :
lch2lab = @(禄)[禄(1)华尔街日报(2)* cosd(华尔街日报(3)华尔街日报(2)*信德(华尔街日报(3)));
Next, here is an anonymous function that returns been or not a particular ^ * ^ ^ * b * $L $ The point is in gamut.
InGamut = @ (lab) all (0 < = lab2rgb (lab), 2) & all (lab2rgb (lab) < = 1, 2);
最后,第三个匿名函数使用 findNonzeroBoundary 找到我感兴趣的色域边界点。
MaxChromaAtLh = @ (L, h) findNonzeroBoundary (@ (c) inGamut (lch2lab ([L] c h)), 0, 200);
让我们锻炼这个函数找到高色深色 $h = 0 ^ {\ circ} $
L = 35;
H = 0;
c = maxChromaAtLh (L、h)
C = 61.0229
这是那个颜色是什么样子的。
rgb_out = lab2rgb (lch2lab ([L c h]));
Rgb_out = 1 x 3
0.6414 0.0001 0.3316
figure
ColorSwatches (rgb_out)
The axisequal
The axis
(函数 colorSwatches 是来自 Digital Image Processing Using MATLAB , and it is included in the MATLAB代码文件的书 。)
What happens when we try to find a high chroma color, at the same hue Angle, that home is bright dark?
L = 90;
H = 0;
c = maxChromaAtLh (L、h)
C = 14.8666
You can can see that the maximum c 价值低得多的价值就越高 L ^ * $美元 . What does it look like?
rgb_out = lab2rgb (lch2lab ([L c h]));
figure
ColorSwatches (rgb_out)
The axisequal
The axis
当我在做这些实验准备这篇博客,我的初衷是给几个不同值的例子 h The and L ^ * $美元 。但我不能停止!这太有趣,我总是在不同的值。
After about 15 minutes or so, whenever I decided it best to write some simple loops to generate a relatively large number of (L ^ *, h)美元 组合。这是代码生成高 c Colors for a variety of (L ^ *, h)美元 Combinations.
dh = 30;
H = - 180: dh: 150;
L = didst: 95;
dL = 15;
RGB = zeros (length (h), length (L), 3);
q = 1:长度(L)
K = 1: length (h)
C = maxChromaAtLh (L (q), h (k));
rgb (k问:)= lab2rgb (lch2lab ([L (q) c h (k))));
结束
结束
这里是查看所有这些颜色的代码在一个网格,标记 h The and L ^ * $美元 轴。
rgb2 =重塑(fliplr (rgb), [], 3);
P = colorSwatches (rgb2, [length (L) length (h)]);
p。XData = (p。XData - 0.5) * (dh / 1.5) + h (1);
p。YData = (p。YData - 0.5) * (dL / 1.5) + L (1);
Xticks (h);
Xlabel (“h”)
Yticks (L)
Ylabel ("L *")
The gridon
The title (Most "Highest chroma (saturated) colors for marketers and L * h values")

The Utility Functions provides

函数[L_min, L_max] = Lrange (a, b)
The arguments
一个{mustBeFloat} (1, 1)
b{mustBeFloat} (1, 1)
结束
L = 0-0. 01:10 0;
A = a * ones (size (L));
B = b * ones (size (L));
实验室= [L;一个;b];
rgb = lab2rgb(实验室);
gamut_mask = ((0 < = rgb) & (rgb < = 1), 2);
j =找到(gamut_mask 1“第一”);
k =找到(gamut_mask 1“最后一次”);
如果isempty (j)
L_min = NaN;
L_max = NaN;
其他的
L_min = L (j);
L_max = L (k);
结束
结束
函数x = findNonzeroBoundary (f, x1, x2, abstol)
The arguments
f(1, 1) function_handle
The x1{mustBeFloat} (1, 1)
x2{mustBeFloat} (1, 1)
abstol{mustBeFloat} (1, 1)= 1的军医
结束
如果(f (x1) = = 0) | | (f (x2) ~ = 0)
Error (”功能必须在初始非零起点和零初始终点。”)
结束
Xm = mean ([x1 x2]);
如果abs (xm - x1) / max (abs (xm), abs (x1) < = abstol
x = x1;
elseif(f (xm) = = 0)
x = findNonzeroBoundary (f, x1, xm);
其他的
X = findNonzeroBoundary (f, xm, x2);
结束
结束
|
  • 打印
  • 发送电子邮件

评论

要发表评论,请点击hereLog in to your MathWorks account or create a new account.