使用rgb2ind函数减少一幅RGB图像中的色彩

%使用rgb2ind函数减少一幅RGB图像中的色彩
f=imread('0602.tif')
subplot(3,2,1),imshow(f),title('原图')

[X1,map1]=rgb2ind(f,8,'nodither');%8为颜色的数目,nodither为不执行抖动处理
subplot(3,2,2),imshow(X1,map1),title('无抖动处理的颜色数减少到8的图像')
 
[X2,map2]=rgb2ind(f,8,'dither');%8为颜色的数目,nodither为执行抖动处理
subplot(3,2,3),imshow(X2,map2),title('有抖动处理的颜色数减少到8的图像')

g=rgb2gray(f);%用rgb2gray得到f的灰度级图像
g1=dither(g);%抖动处理灰度图像
subplot(3,2,4),imshow(g),title('用rgb2gray得到的灰度级图像')
subplot(3,2,5),imshow(g1),title('经抖动处理后的灰度图像')

猜你喜欢

转载自blog.csdn.net/YangYaYan/article/details/89598695
今日推荐