《MATLAB图像处理实例详解》:CH_3
一、图像类型转换:
①RGB图像转换为灰度图像:
I=imread("E:\Matlab_exercise\图片素材\lian.jpg");#读取图片
X=rgb2gray(I);#RGB图像转换为灰度图像
figure;#显示图像
subplot(121);imshow(I);
subplot(122);imshow(X);
②RGB图像转换为索引图像:
RGB=imread("E:\Matlab_exercise\图片素材\lian2.jpg");#读取图片
[X1,map1]=rgb2ind(RGB,64);#均匀量化法
[X2,map2]=rgb2ind(RGB,0.2);#最小方差量化法