彩色图像处理MATLAB函数简介.ppt

上传人:牧羊曲112 文档编号:6387182 上传时间:2023-10-26 格式:PPT 页数:29 大小:251.32KB
返回 下载 相关 举报
彩色图像处理MATLAB函数简介.ppt_第1页
第1页 / 共29页
彩色图像处理MATLAB函数简介.ppt_第2页
第2页 / 共29页
彩色图像处理MATLAB函数简介.ppt_第3页
第3页 / 共29页
彩色图像处理MATLAB函数简介.ppt_第4页
第4页 / 共29页
彩色图像处理MATLAB函数简介.ppt_第5页
第5页 / 共29页
点击查看更多>>
资源描述

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

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.lab2uint8-Convert Lab color values

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

3、oint-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.,1 函数简介,dither-Convert image using dithering.gray2ind-Convert intensity image to indexed image.grayslice-Creat

4、e indexed image from intensity image by thresholding.graythresh-Compute global image threshold using Otsus method.im2bw-Convert image to binary image by thresholding.im2double-Convert image array to double precision.,1 函数简介,ind2gray-Convert indexed image to intensity image.ind2rgb-Convert indexed im

5、age to RGB image(MATLAB Toolbox).mat2gray-Convert matrix to intensity image.rgb2gray-Convert RGB image or colormap to grayscale.rgb2ind-Convert RGB image to indexed image.,2 颜色空间转换矩阵的创建与应用,makecform Create a color transformation structure SyntaxC=makecform(type)creates the color transformation struc

6、ture C that defines the color space conversion specified by type.To perform the transformation,pass the color transformation structure as an argument to the applycform function.,type 参数,type 参数,颜色空间,应用,rgb=imread(peppers.png);cform=makecform(srgb2lab);lab=applycform(rgb,cform);,3 颜色空间转换函数举例,rgb2hsv

7、Convert RGB colormap to HSV colormap cmap=rgb2hsv(M)Descriptionconverts an RGB colormap 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 c

8、olumns of the output matrix cmap represent hue,saturation,and value,respectively.,3 颜色空间转换函数举例,hsv2rgb Convert HSV colormap to RGB colormap M=hsv2rgb(H)Descriptionconverts 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 th

9、e colormap.The columns of H represent hue,saturation,and value,respectively.M is an m-by-3 matrix.Its columns are intensities of red,green,and blue,respectively.,编程应用,fc=imread(peppers.png);%提取RGB分量fr=fc(:,:,1);fg=fc(:,:,2);fb=fc(:,:,3);figure(1)imshow(f)title(rgb image),编程应用,figure(2)imshow(fr)titl

10、e(red component)figure(3)imshow(fg)title(green component)figure(4)imshow(fb)title(blue component),编程应用,%将RGB转换成HSVhc=rgb2hsv(fc);%提取HSV分量h=hc(:,:,1);s=hc(:,:,2);v=hc(:,:,3);figure(5)imshow(hsv2rgb(hc)title(hsv image),编程应用,%显示HSV分量图像figure(6)imshow(h)title(hue component)figure(7)imshow(s)title(satura

11、tion component)figure(8)imshow(v)title(value component),编程应用,%产生均值滤波器w=fspecial(average,5);%对RGB图像滤波rgb_filtered=imfilter(fc,w,replicate);figure(9)imshow(rgb_filtered)title(filtered RGB image),编程应用,%仅对HSV图像的v分量滤波v_filtered=imfilter(v,w,replicate);h=cat(3,h,s,v_filtered);f_filtered=hsv2rgb(h);f_filte

12、red=min(f_filtered,1);figure(10)imshow(f_filtered)title(filtered hsv image),编程应用,%对h,s,v同时滤波h_filtered=imfilter(h,w,replicate);s_filtered=imfilter(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)

13、imshow(f_filtered),4 颜色空间转换函数的编写,function hsi=rgb2hsi(rgb)%将RGB图像转换成HSI图像rgb=im2double(rgb);r=rgb(:,:,1);g=rgb(:,:,2);b=rgb(:,:,3);,4 颜色空间转换函数的编写,%将RGB转换HSInum=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

14、(den=0)=eps;S=1-3.*num./den;I=(r+g+b)/3;hsi=cat(3,H,S,I);,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);,4 颜色空间转换函数的编写,%分区转换%RB区间(0-120)idx=find(0=H

15、),4 颜色空间转换函数的编写,%GB区间(120-240)idx=find(2*pi/3=H),4 颜色空间转换函数的编写,%BR区间(240-360)idx=find(4*pi/3=H),5灰度条与彩条产生函数,function graybar(h,w,l,map)%h,w,为一个小条带图像的高度和宽度%l为条带的灰度级或颜色数,map为调色板c=;if nargin=0 h=64;w=8;l=16;elseif nargin=4 error(wrong number of inputs.)end,5灰度条与彩条产生函数,X=ones(h,w);l=256/l;for k=0:l:256

16、Y=k*X;c=cat(2,c,Y);endif isempty(map)map=0:1/256:1*ones(1,3);endfigureimshow(c,map),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);,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);,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号