首页 > 解决方案 > matlab中的色度适应

问题描述

我想将这些灰色图像制作成彩色图像,以便观察色彩适应

另一件事是如何将布拉德福德变换应用于图像(以便将图像与布拉德福德矩阵相乘

 Mbfd = [.8950 .2664 -.1614;
       -.7502 1.7135 .0367;
       .0389 -.0685 1.0296])

我知道我必须将输入图像与布拉德福德矩阵相乘,但我不知道该怎么做。

I=imread('snimka.jpeg');
figure(1), imshow(I);
srgb2lab_byA = makecform('srgb2lab', 'AdaptedWhitePoint',whitepoint('a')); 
srgb2lab_byD50 = makecform('srgb2lab', 'AdaptedWhitePoint',whitepoint('d50'));
srgb2lab_byD55 = makecform('srgb2lab', 'AdaptedWhitePoint',whitepoint('d55'));
srgb2lab_byD65 = makecform('srgb2lab', 'AdaptedWhitePoint',whitepoint('d65'));
lab_A = applycform(I,srgb2lab_byA); 
lab_D50 = applycform(I,srgb2lab_byD50); 
lab_D55 = applycform(I,srgb2lab_byD55); 
lab_D65 = applycform(I,srgb2lab_byD65); 

% figure;
figure();
subplot(2,2,1), imshow(lab_A(:,:,1)); title('sRGB to Lab by adapting to illuminant A'); 
subplot(2,2,2), imhist(lab_A(:,:,1)); title('Histogram of the red channel');
subplot(2,2,3), imhist(lab_A(:,:,2)); title('Histogram of the green channel');
subplot(2,2,4), imhist(lab_A(:,:,3)); title('Histogram of the blue channel');
figure();
subplot(2,2,1), imshow(lab_D50(:,:,1)); title('sRGB to Lab by adapting to illuminant D50');
subplot(2,2,2), imhist(lab_D50(:,:,1)); title('Histogram of the red channel');
subplot(2,2,3), imhist(lab_D50(:,:,2)); title('Histogram of the green channel');
subplot(2,2,4), imhist(lab_D50(:,:,3)); title('Histogram of the blue channel');
% luminance_diff=abs(lab_A(:,:,1)-lab_D50(:,:,1));
figure();
subplot(2,2,1), imshow(lab_D55(:,:,1)); title('sRGB to Lab by adapting to illuminant D55');
subplot(2,2,2), imhist(lab_D55(:,:,1)); title('Histogram of the red channel');
subplot(2,2,3), imhist(lab_D55(:,:,2)); title('Histogram of the green channel');
subplot(2,2,4), imhist(lab_D55(:,:,3)); title('Histogram of the blue channel');
figure();
subplot(2,2,1), imshow(lab_D65(:,:,1)); title('sRGB to Lab by adapting to illuminant D65');
subplot(2,2,2), imhist(lab_D65(:,:,1)); title('Histogram of the red channel');
subplot(2,2,3), imhist(lab_D65(:,:,2)); title('Histogram of the green channel');
subplot(2,2,4), imhist(lab_D65(:,:,3)); title('Histogram of the blue channel');

标签: matlabimage-processing

解决方案


您不能从灰色图像中制作彩色图像。灰度图像的信息较少,无法从灰度图像中获取颜色。但是,您的图像看起来显然是 RGB。您显示的代码显示灰度的原因是因为您只显示图像的一个通道(R、G、B)。imshow(I)将向您显示图像。

要显示操作的结果,您需要再次将它们转换为 rgb。假设您想看到白电平发生了变化:

torgb= makecform('lab2srgb'); 
Irgb=applycform(lab_D55,torgb);
imshow(Irgb);

要将您提到的矩阵应用于图像,请对其进行过滤:

Mbfd = [.8950 .2664 -.1614; -.7502 1.7135 .0367; .0389 -.0685 1.0296]);
out=imfilter(I, Mbfd);

总体而言,您的问题暗示缺乏理解。我建议您阅读 RGB 和 Lab 是什么以及白电平的作用。阅读灰度图像与彩色图像的区别。这将对您将来有很大帮助。


推荐阅读