matlab中的色度适应

时间:2018-04-30 12:09:00

标签: matlab image-processing

我想让这些灰色图像为彩色图像,这样我就可以观察到色彩适应

另外一件事是如何将Bradford变换应用于图像(所以将图像与Bradford矩阵相乘

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

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

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');

1 个答案:

答案 0 :(得分:2)

您无法从灰色图像制作彩色图像。灰度图像信息较少,无法从灰度图像中获取颜色。但是,您的图像看起来很清晰。您显示的代码显示灰度的原因是因为您只显示图像的一个通道(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是什么以及白色水平的作用。同时阅读灰度图像与彩色图像的对比。这对你将来有很大的帮助。