20060203-All about pixel colors: Truecolor and indexed images

原文:http://blogs.mathworks.com/steve/2006/02/03/all-about-pixel-colors-part-2/

Let's start by exploring MATLAB's two basic pixel-color display models:

  • Matrix element values specify pixel colors directly
  • Matrix element values specify pixel colors indirectly, through the figure's colormap
Truecolor images

Here's an illustrative image with just three pixels: red, blue, and yellow.

plane_1 = [1 0 1];
plane_2 = [0 0 1];
plane_3 = [0 1 0];
rgb = cat(3, plane_1, plane_2, plane_3);
size(rgb)

image(rgb)
axis image
title('Truecolor image with one red, one blue, and one yellow pixel')
With truecolor images, changing the colormap has no effect on the image colors displayed.

colormap(hot)
title('Changing the figure colormap does not affect the pixel colors')

Indexed images

If the image CData is two-dimensional, then the CData values are treated as lookup indices into the figure's colormap.

s = load('clown')

image(s.X)
colormap(s.map)
title('Indexed image')
Unlike truecolor images, indexed images are affected by changes in the figure's colormap.

colormap(cool)
title('Indexed image displays incorrectly if you use the wrong colormap')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值