close all;clear all;clc;
RGB = imread('football.jpg'); %读取图像
[X1,map1]=rgb2ind(RGB,64); %将RGB图像转换成索引图像,颜色种数N是64种
[X2,map2]=rgb2ind(RGB,0.2); %将RGB图像转换成索引图像,颜色种数N是216种
map3= colorcube(128); %创建一个指定颜色数目的RGB颜色映射表
X3=rgb2ind(RGB,map3);
figure;
subplot(131),imshow(X1,map1); %显示用最小方差法转换后索引图像
subplot(132),imshow(X2,map2); %显示用均匀量化法转换后索引图像
subplot(133),imshow(X3,map3); %显示用颜色近似法转换后索引图像