200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > MATLAB(完备)之图像.tif到真彩色图像 索引色图像 灰度图像 真彩色图像RGB YIQ

MATLAB(完备)之图像.tif到真彩色图像 索引色图像 灰度图像 真彩色图像RGB YIQ

时间:2023-08-25 08:50:53

相关推荐

MATLAB(完备)之图像.tif到真彩色图像 索引色图像 灰度图像  真彩色图像RGB YIQ

I=imread(‘flower.tif’);%读入图片

whos I

imfinfo(‘flower.tif’)

imshow(I);title(‘原始tif图像’)

%%真彩图像、转索图像、灰度图像、二值图像的相互转换

imwrite(I,‘flower.jpg’,‘quality’,10)%tif转化rgb

I1=imread(‘flower.jpg’);

figure;imshow(I1);title(‘真彩色图像’)

[X,map] = rgb2ind(I1,32);%真彩转索引

figure;imshow(X,map),colorbar,title(‘索引图像’)

rgb=ind2rgb(X,map);%索引转rgb

figure;imshow(rgb);title(‘rgb图像’)

G=rgb2gray(I1);

figure;imshow(G);title(‘rgb转灰度图像’)

G1=ind2gray(X,map);%索引转灰度

figure;imshow(G1);title(‘索引转灰度图像’)

G3=im2bw(I1);%图像转二值图像

figure;imshow(G3);title(‘二值图像’)

%%RGB/YIQ/HSV/YCbCr之间的转换

image = imread(‘lena.jpg’);

figure;subplot(331);imshow(image);title(‘原始图像’)

%RGB&YIQ

YIQ=rgb2ntsc(image);

subplot(332);imshow(YIQ);title(‘YIQ图像’)

rgb=ntsc2rgb(YIQ);

subplot(333);imshow(rgb);title(‘rgb图像’)

%RGB&HSV

HSV=rgb2hsv(image);

subplot(334);imshow(image);title(‘原始图像’)

subplot(335);imshow(HSV);title(‘HSV图像’)

RGB1=hsv2rgb(HSV);

subplot(336);imshow(RGB1);title(‘RGB图像’)

%RGB&YCbCr

yc=rgb2ycbcr(image);

subplot(337);imshow(image);title(‘原始图像’)

subplot(338);imshow(yc);title(‘ycbcr图像’)

rgb2=ycbcr2rgb(yc);

subplot(339);imshow(rgb2);title(‘RGB图像’)

MATLAB(完备)之图像.tif到真彩色图像 索引色图像 灰度图像 真彩色图像RGB YIQ图像 HSV图像 YCbCr图像转换代码

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。