一、索引图像
RGB图转索引图
索引图转RGB图
clear all;close all;clc
X=imread('lena1024.bmp');
[imgind, map] = rgb2ind(X, 256); % 转换为256色的索引图像
Y= ind2rgb(imgind,map);
figure(1);
subplot(121),imshow(X),xlabel('(a) 原图');
subplot(122),imshow(imgind),xlabel('(b) 仅索引图');
title('图1.1 RGB图转索引图','position',[-150,1400],'FontSize',15);
figure(2);
subplot(121),imshow(imgind,map),xlabel('(a) 带色索引图');
subplot(122),imshow(Y),xlabel('(b) 恢复图');
title('图1.2 索引图转RGB图','position',[-150,1400],'FontSize',15);