[indcat,map]=rgb2ind(I,0.7);
>> subplot(1,2,1);
>> subimage(I);
>> subplot(1,2,2);
>> subimage(indcat,map);
效果:
(4)、索引图像转 RGB
代码:
I1=ind2rgb(indcat,map);
>>subplot(1,2,1);
>>subimage(indcat,map);
>>subplot(1,2,2);
>>subimage(I1);
效果:
(5)、索引转灰度图像
代码:
i2gcat=ind2gray(indcat,map);
>>subplot(1,2,1);
>>subimage(indcat,map);
>>subplot(1,2,2);
>>subimage(i2gcat);