grayImg = imread('path_to_your_gray_image.jpg'); 创建一个空的RGB图像矩阵,其尺寸与灰度图像相匹配: RGB图像是一个三维矩阵,其中每个像素由红(R)、绿(G)、蓝(B)三个颜色通道组成。为了将灰度图像转换为RGB图像,你需要创建一个与灰度图像尺寸相同的三维矩阵,并将每个颜色通道初始化为零。 matlab [row...
%Youcanusetheattachedtestimages.Usethefollowingcombinations: %gray2rgb('test1_destination.jpg','test1_source.jpg') %gray2rgb('nature_desitnation.jpg','nature_source.jpg') % %Thiscodewasoriginallyinspiredbythecodegray2rgbbyJenyRajanand %ChandrashekarP.S.Thecodewasoptimizedandrewrittentomoreclosely ...
(2,2,1) imshow(imag1);title('原始图像'); %显示原始图像 subplot(2,2,2) imshow(gray1);title('RGB to 灰度图像'); %显示转换后的灰度图像 subplot(2,2,3) imshow(bw1);title('RGB to 二值图像'); %显示转换后的二值图像 subplot(2,2,4) imshow(X);title('RGB to 索引图像'); %显示...
在这里存档一下grayscale to rgb部分的代码。。 function res =grs2rgb(img, map)%%Convert grayscale images to RGBusingspecified colormap.% IMGisthe grayscale image. Must be specifiedasa name of the image%including the directory, or the matrix.% MAPisthe M-by-3matrix of colors.% % RES = ...
function[Image]=gray2rgb(Image) %Gives a grayscale image an extra dimension %in order to use color within it [m n]=size(Image); rgb=zeros(m,n,3); rgb(:,:,1)=Image; rgb(:,:,2)=rgb(:,:,1); rgb(:,:,3)=rgb(:,:,1); ...
How to convert grayscale to rgb ?. Learn more about colormap, image processing, grayscale to rgb Image Processing Toolbox
1 % Filename:RGBtoGrayImage 2 i = imread('D:\\1.jpg');%读RGB图像 3 j = rgb2gray(i); %RGB图像转灰度图像 4 imshow(j); 5 imwrite(j, 'D:\\1.bmp') %另存时选bmp格式回到顶部 二、读取图像序列使用matlab读取图像序列,并显示
imdata = imread('ngc6543a.jpg');%imdata为rgb数据 imwrite(imdata,'myPic.bmp');%写图片 imshow('myPic.bmp')%显示你写的图片 这样就可以啦 你如果有数据,直接用imwrite写图片就可以了,不用我的第一步读图片数据
what's the value of r? One? Or three? I guess your Image is already an RGB image, only that R, G and B are always equal (and therefore you have gray) ... Titus 댓글 수: 2 Image Analyst2012년 8월 25일 MATLAB Online에서 열기 ...
>> subplot(122);imshow(gray_I); 1. 2. 3. 4. 5. 运行结果: 二、真彩色图像转化为索引图像 需要使用到的函数:rgb2ind由于RGB图像一个像素占用三个字节, 分别存储R、G、B分量的值,而索引图像一个像素占用一个字节。在将灰度图像转换为索引图像时, 是从3个字节映射到一个字节的关系。 通常有以下三种算...