matlab 图像转换,几个简单的图像转换MATLAB代码

1、将索引图像为RGB图像

[X,map]=imread(‘spine.tif‘);

figure;

subplot(121);imshow(X,hot(64));

rgb=ind2rgb(X,map);

subplot(122);imshow(rgb);

2、将矩阵转换为灰度图像

>> I=[1 2 3;4 5 6;0 1 0];

>> X=mat2gray(I);

>> figure;

>> imshow(X)

3、RGB图像转换为索引图像

>> r=imread(‘football.jpg‘);

>> [x1,map]=rgb2ind(r,64);

>> [x2,map]=rgb2ind(r,0.2);

>> map3=colorcube(128);

>> x3=rgb2ind(r,map3);

>> figure;

>> subplot(141),imshow(r);

>> subplot(142),imshow(x1,map);

>> subplot(143),imshow(x2,map);

>> subplot(144),imshow(x3);

4、索引图像转换为灰度图像

>> [X,map]=imread(‘forest.tif‘);

>> I=ind2gray(X,map);

>> figure;imshow(X,map);

>> figure;imshow(I);

原文:http://www.cnblogs.com/anjing9580/p/3960568.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值