Matlab数字图像处理 |
您所在的位置:网站首页 › 图像是m的函数 › Matlab数字图像处理 |
文章目录
一、真彩色图像转化为灰度图像二、真彩色图像转化为索引图像三、灰度图像转换为索引图像四、索引图像转换成灰度图像五、索引图像转RGB图像六、灰度图转二值图七、数字矩阵转灰度图
完整目录
![]() Matlab函数:rgb2gray >> I = imread('huoying1.jpg'); >> gray_I = rgb2gray(I); >> figure; >> subplot(121);imshow(I); >> subplot(122);imshow(gray_I);运行结果: 需要使用到的函数:rgb2ind 由于RGB图像一个像素占用三个字节, 分别存储R、G、B分量的值,而索引图像一个像素占用一个字节。在将灰度图像转换为索引图像时, 是从3个字节映射到一个字节的关系。 通常有以下三种算法: 均匀量化法最小化方差量化法均匀量化法 RGB = imread('huoying1.jpg'); [X1, map1] = rgb2ind(RGB, 64); %最小方差量化法 [X2, map2] = rgb2ind(RGB, 0.2); %均匀量化法 map3 = colorcube(128); X3 = rgb2ind(RGB, map3); %逆颜色图量化法 figure; subplot(131);imshow(X1, map1); subplot(132);imshow(X2, map2); subplot(133);imshow(X3, map3);结果展示: Matlab函数:gray2ind I = imread('火影1.jpg'); gray = gray2ind(I); [X, map] = gray2ind(gray, 8); subplot(121);imshow(gray); subplot(122):imshow(X, map);运行结果: Matlab函数:ind2gray 由于我确实没找到合适的索引图像,所以只能自己转化了 I = imread('火影1.jpg'); [X, map] = rgb2ind(I, 64); gray = ind2gray(X, map); figure; subplot(121) imshow(X, map); subplot(122) imshow(gray);结果展示: Matlab函数:ind2rgb I = imread('火影1.jpg'); [X, map] = rgb2ind(I, 64); rgb = ind2rgb(X, map); figure; subplot(121) imshow(X, map); subplot(122) imshow(rgb);结果展示: Matlab函数:im2gray I = imread('火影1.jpg'); gray = rgb2gray(I); bw1 = im2bw(gray, 0.4); bw2 = im2bw(gray, 0.6); figure; subplot(131) imshow(gray); subplot(132) imshow(bw1); subplot(133) imshow(bw2);结果展示: Matlab函数:mat2gray I = magic(256); Img = mat2gray(I); subplot(121) imshow(I); subplot(122) imshow(Img);结果展示: Matlab数字图像处理——图像处理工具箱Image Processing Toolbox Matlab数字图像处理——图像类型的转换 Matlab数字图像处理——图像文件的读取 Matlab数字图像处理——图像文件的显示 Matlab数字图像处理——视频文件的读写 Matlab数字图像处理——图像的像素运算(灰度变换) Matlab数字图像处理——图像的空间变换 Matlab数字图像处理——图像的平移、邻域操作、区域选取 Matlab数字图像处理——图像增强 Matlab数字图像处理——图像复原 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |