matlab 彩色图像处理,彩色图像处理MATLAB函数简介

《彩色图像处理MATLAB函数简介》由会员分享,可在线阅读,更多相关《彩色图像处理MATLAB函数简介(29页珍藏版)》请在人人文库网上搜索。

1、彩色图像处理函数简介,1,1,函数简介,?,applycform -,Apply device-independent color space,?,transformation.,?,hsv2rgb -,Convert HSV values to RGB color space,?,(MATLAB Toolbox).,?,iccread -,Read ICC color profile.,?,lab2double -,Convert Lab color values to double.,?,lab2uint16 -,Convert Lab color values to uint16.,?,。

2、lab2uint8 -,Convert Lab color values to uint8.,?,makecform -,Create device-independent color,?,space transform structure.,?,ntsc2rgb -,Convert NTSC values to RGB color space.,2,1,函数简介,?,rgb2hsv -,Convert RGB values to HSV color space,?,(MATLAB Toolbox).,?,rgb2ntsc -,Convert RGB values to NTSC color 。

3、space.,?,rgb2ycbcr -,Convert RGB values to YCBCR color,?,space.,?,whitepoint -,Returns XYZ values of standard,?,illuminants.,?,xyz2double -,Convert XYZ color values to double.,?,xyz2uint16 -,Convert XYZ color values to uint16.,?,ycbcr2rgb -,Convert YCBCR values to RGB color,?,space.,3,1,函数简介,?,dithe。

4、r -,Convert image using dithering.,?,gray2ind -,Convert intensity image to indexed image.,?,grayslice -,Create indexed image from intensity image,?,by thresholding.,?,graythresh -,Compute global image threshold using,?,Otsus method.,?,im2bw -,Convert image to binary image by,?,thresholding.,?,im2dou。

5、ble -,Convert image array to double precision.,?,4,1,函数简介,?,ind2gray -,Convert indexed image to intensity image.,?,ind2rgb -,Convert indexed image to RGB image,?,(MATLAB Toolbox).,?,mat2gray -,Convert matrix to intensity image.,?,rgb2gray -,Convert RGB image or colormap to,?,grayscale.,?,rgb2ind -,C。

6、onvert RGB image to indexed image.,5,2,颜色空间转换矩阵的创建与应用,?,makecform,?,Create a color transformation structure,?,Syntax,?,C = makecform(type),creates the color transformation structure C that,defines the color space conversion specified by type.,To perform the transformation, pass the color,transformat。

7、ion structure as an argument to the,applycform function.,6,type,参数,7,type,参数,8,颜色空间,9,应用,?,rgb = imread(peppers.png);,?,cform = makecform(srgb2lab);,?,lab = applycform(rgb,cform);,10,3,颜色空间转换函数举例,?,rgb2hsv,?,Convert RGB colormap to HSV colormap,?,cmap = rgb2hsv(M),?,Description,?,converts an RGB col。

8、ormap M to an HSV,colormap cmap. Both colormaps are m-by-3,matrices. The elements of both colormaps are in,the range 0 to 1. The columns of the input matrix,M represent intensities of red, green, and blue,respectively. The columns of the output matrix,cmap represent hue, saturation, and value,respec。

9、tively.,11,3,颜色空间转换函数举例,?,hsv2rgb,?,Convert HSV colormap to RGB colormap,?,M = hsv2rgb(H),?,Description,?,converts a hue-saturation-value (HSV),colormap to a red-green-blue (RGB) colormap.,H is an m-by-3 matrix, where m is the number,of colors in the colormap. The columns of H,represent hue, saturat。

10、ion, and value,respectively. M is an m-by-3 matrix. Its,columns are intensities of red, green, and blue,respectively.,12,编程应用,?,fc=imread(peppers.png);,?,%,提取,RGB,分量,?,fr=fc(:,:,1);,?,fg=fc(:,:,2);,?,fb=fc(:,:,3);,?,figure(1),?,imshow(f),?,title(rgb image),13,编程应用,?,figure(2),?,imshow(fr),?,title(re。

11、d component),?,figure(3),?,imshow(fg),?,title(green component),?,figure(4),?,imshow(fb),?,title(blue component),14,编程应用,?,%,将,RGB,转换成,HSV,?,hc=rgb2hsv(fc);,?,%,提取,HSV,分量,?,h=hc(:,:,1);,?,s=hc(:,:,2);,?,v=hc(:,:,3);,?,figure(5),?,imshow(hsv2rgb(hc),?,title(hsv image),15,编程应用,?,%,显示,HSV,分量图像,?,figure(。

12、6),?,imshow(h),?,title(hue component),?,figure(7),?,imshow(s),?,title(saturation component),?,figure(8),?,imshow(v),?,title(value component),16,编程应用,?,%,产生均值滤波器,?,w=fspecial(average,5);,?,%,对,RGB,图像滤波,?,rgb_filtered=imfilter(fc,w,replicate);,?,figure(9),?,imshow(rgb_filtered),?,title(filtered RGB im。

13、age),17,编程应用,?,%,仅对,HSV,图像的,v,分量滤波,?,v_filtered=imfilter(v,w,replicate);,?,h=cat(3,h,s,v_filtered);,?,f_filtered=hsv2rgb(h);,?,f_filtered=min(f_filtered,1);,?,figure(10),?,imshow(f_filtered),?,title(filtered hsv image),18,编程应用,?,%,对,h,s,v,同时滤波,?,h_filtered=imfilter(h,w,replicate);,?,s_filtered=imfil。

14、ter(s,w,replicate);,?,v_filtered=imfilter(v,w,replicate);,?,h=cat(3,h_filtered,s_filtered,v_filtered);,?,f_filtered=hsv2rgb(h);,?,f_filtered=min(f_filtered,1);,?,figure(11),?,imshow(f_filtered),19,4,颜色空间转换函数的编写,?,function hsi=rgb2hsi(rgb),?,%,将,RGB,图像转换成,HSI,图像,?,rgb=im2double(rgb);,?,r=rgb(:,:,1);,。

15、?,g=rgb(:,:,2);,?,b=rgb(:,:,3);,20,4,颜色空间转换函数的编写,?,%,将,RGB,转换,HSI,?,num=0.5*(r-g)+(r-b);,?,den=sqrt(r-g).2+(r-b).*(g-b);,?,theta=acos(num./(den+eps);,?,H=theta;,?,h(bg)=2*pi-H(bg);,?,H=H/(2*pi);,?,num=min(min(r,g),b);,?,den=r+g+b;,?,den(den=0)=eps;,?,S=1-3.*num./den;,?,I=(r+g+b)/3;,?,hsi=cat(3,H,S,I。

16、);,21,4,颜色空间转换函数的编写,?,function rgb=hsi2rgb(hsi),?,%,将,HSI,图像转换成,RGB,图像,?,H=hsi(:,:,1)*2*pi;,?,S=hsi(:,:,2);,?,I=hsi(:,:,3);,?,%,初始化,?,R=zeros(size(hsi,1),size(hsi,2);,?,G=zeros(size(hsi,1),size(hsi,2);,?,B=zeros(size(hsi,1),size(hsi,2);,22,4,颜色空间转换函数的编写,?,%,分区转换,?,%RB,区间(,0-120,),?,idx=find(0=H),?,B。

17、(idx)=I(idx).*(1-S(idx);,?,R(idx)=I(idx).*(1+S(idx).*cos(H(idx)./,cos(pi/3-H(idx);,?,G(idx)=3*I(idx)-(R(idx)+B(idx);,23,4,颜色空间转换函数的编写,?,%GB,区间(,120-240,),?,idx=find(2*pi/3=H),?,R(idx)=I(idx).*(1-S(idx);,?,G(idx)=I(idx).*(1+S(idx).*cos(H(idx)-,2*pi/3)./cos(pi-H(idx);,?,B(idx)=3*I(idx)-(R(idx)+G(idx);。

18、,24,4,颜色空间转换函数的编写,?,%BR,区间(,240-360,),?,idx=find(4*pi/3=H),?,G(idx)=I(idx).*(1-S(idx);,?,R(idx)=I(idx).*(1+S(idx).*cos(H(idx)-,4*pi/3)./cos(5*pi/3-H(idx);,?,G(idx)=3*I(idx)-(G(idx)+B(idx);,?,%,组合成,RGB,图像,?,rgb=cat(3,R,G,B);,?,rgb=max(min(rgb,1),0);,25,5,灰度条与彩条产生函数,?,function graybar(h,w,l,map),?,%h,。

19、w,为一个小条带图像的高度和宽度,?,%l,为条带的灰度级或颜色数,,map,为调色板,?,c=;,?,if nargin=0,?,h=64; w=8;l=16;,?,elseif nargin=4,?,error(wrong number of inputs.),?,end,26,5,灰度条与彩条产生函数,?,X=ones(h,w);,?,l=256/l;,?,for k=0:l:256,?,Y=k*X;,?,c=cat(2,c,Y);,?,end,?,if isempty(map),?,map=0:1/256:1*ones(1,3);,?,end,?,figure,?,imshow(c,m。

20、ap),27,6,彩色,索引,灰度图像的转换,?,x,map=gray2ind(gray_image,n);,?,gray_image=ind2gray(x,map);,?,x,map=rgb2ind(rgb_image,?,n,dither_option);,?,rgb_image=ind2rgb(x,map);,?,gray_image=rgb2gray(rgb_image);,?,28,6,彩色,索引,灰度图像的转换,?,f=imread(peppers.png);,x1,map1=rgb2ind(f,8,nodither);,?,figure(1),imshow(f),?,x2,map2=rgb2ind(f,8,dither);,?,figure(2),imshow(x1,map1),?,figure(3),imshow(x2,map2),?,g=rgb2gray(f);,?,g1=dither(g);,?,figure(4),imshow(g);,?,figure(5),imshow(g1);,29。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值