我想把这些灰度图像转换成彩色图像,这样我就可以观察到颜色的适应性。
另一件事是如何将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');发布于 2018-04-30 21:11:45
您不能从灰度图像制作彩色图像。灰度图像的信息量较少,无法从灰度图像中获取颜色。但是,您的图像似乎是清晰的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,以及什么是白电平。也请阅读什么是灰度图像与彩色图像。这将在未来对你有很大的帮助。
https://stackoverflow.com/questions/50100241
复制相似问题