数字图象处理MATLAB常用操作(转)

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. diagram = imread('C:\Users\Administrator\Desktop\Compressed\fiter\lena256.jpg')  
  2. %diagram = rgb2gray(diagram);%------------------------------将图片转换为灰度图  
  3. %diagram = logical(diagram)%  
  4. figure,imshow(diagram),title('Original picture');%----------显示原图  
  5. %figure,imshow(diagram(100,:)),title('Original picture');%--显示100行水平扫描线  
  6. %plot(diagram(255,:))  
  7. size(diagram)  
  8. whos diagram  
  9. % imfinfo lena256.jpg %---------------------------------------显示图片信息  
  10. diagram(256,256)  
  11. diagram(1:10,1:10)  
  12.   
  13. % diagram = imadjust(diagram,[0,1],[1,0]) %-----------------图像反转 亮度  
  14. % figure,imshow(diagram)  
  15. % diagram = intrans(diagram,'stretch',mean2(im2double(diagram)),0.9);  


[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. %%======================直方图============================%%  
  2. % h = imhist(diagram)  
  3. % h1 = h(1:1:256)  
  4. % horz = 1:1:256;  
  5. %bar(horz,h1)  
  6. %axis([0 255 0 1500])  


[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. %%======================图像复原===========================%%  
  2. %g = imnoise(diagram,'gaussian') %-------------------------添加高斯噪声  
  3. %figure,imshow(g)  
  4.   
  5. [M,N]=size(diagram)  
  6. R = imnoise2('salt & pepper',M,N,0.01,0) %-----------------椒盐噪声  
  7. c = find(R == 0);  
  8. gp = diagram  
  9. gp(c) = 255   %--------------------------------------------椒盐噪声  
  10. %figure,imshow(gp);title('salt noise ')  
  11. %g2 = imnoise(diagram,'poisson') %-------------------------珀松  
  12. %figure,imshow(g2);title('pospng noise ')  
  13. % fp = spfilt(gp,'chmean',3,3,-1)  
  14. % figure,imshow(fp)  


[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. %%=========================分离RGB========================%%  
  2. rgb_se = diagram  
  3. % rgb_se = im2double(rgb_se)  
  4. fr = rgb_se(:,:,1)  
  5. fg = rgb_se(:,:,2)  
  6. fb = rgb_se(:,:,3)  
  7.   
  8. R = rgb_se(:,:,1)  
  9. G = rgb_se(:,:,2)  
  10. B = rgb_se(:,:,3)  
  11. Y  = 16+(0.256789*R+0.504129*G+0.097906*B)  
  12. Cb = 128+(-0.148223*R-0.290992*G+0.439215*B)  
  13. Cr = 128+(0.439215*R-0.367789*G-0.071426*B)  
  14. % figure,imshow(Y);title('Y ')  
  15. % ycbcr = cat(3,Y,Cb,Cr)  
  16. % figure,imshow(ycbcr);title('Ycbcr ')  
  17. % figure,imshow(fr)   %--------------------------------------此时的不是红色,只是红色分量  
  18. % figure,imshow(fg)  
  19. % figure,imshow(fb)  
  20. % rgb_image = cat(3,fr,fg,fb) %------------------------------合并RGB分量  
  21. % figure,imshow(rgb_image)  


[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. %==========================提出R G B分量===================%%  
  2. a = diagram  
  3. [r,c,d]=size(a);  
  4.   
  5. red=a;%提取红色分量  
  6. red(:,:,1)=a(:,:,1);  
  7. red(:,:,2)=zeros(r,c);%--------------------------------------将其他两组分量置位0  
  8. red(:,:,3)=zeros(r,c);  
  9. % red=unit8(red);  
  10. % red=uint8(red);  
  11. %subplot(131),imshow(red);title('red separation')  
  12. %提取绿色分量  
  13. green=zeros(r,c);  
  14. green(:,:,2)=a(:,:,2);  
  15. green(:,:,1)=zeros(r,c);  
  16. green(:,:,3)=zeros(r,c);  
  17. green=uint8(green);  
  18. %subplot(132),imshow(green);title('green separation')  
  19. %提取蓝色分量  
  20. blue=zeros(r,c);  
  21. blue(:,:,1)=zeros(r,c);  
  22. blue(:,:,2)=zeros(r,c);  
  23. blue(:,:,3)=a(:,:,3);  
  24. blue=uint8(blue);  
  25. %subplot(133),imshow(blue);title('blue separation')  


[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. %%===========================颜色空间转换=====================%%  
  2. rgb_image = diagram  
  3. rgb_image = im2double(rgb_image)  
  4. yiq_image = rgb2ntsc(rgb_image)  %---------------------------RGB  to NTSC  
  5. %figure,imshow(yiq_image);title('RGB to NTSC ')  
  6. ycbcr_image = rgb2ycbcr(rgb_image)%--------------------------RGB  to Ycbcr  
  7. % figure,imshow(ycbcr_image);title('RGB to Ycbcr ')  
  8. size(ycbcr_image)  
  9. %Here pick off the 256x256 luminance part of the ycbcr image  
  10. Y = ycbcr_image(:,:,1)  
  11. %figure, imshow(Y); title('Y part of Image');  
  12. size(Y)  
  13.   
  14. %Here pick off the 256x256 Cb part of the ycbcr image  
  15. CB = ycbcr_image(:,:,2)  
  16. %figure, imshow(CB); title('Cb part of Image');  
  17. size(CB)  
  18.   
  19. %Here pick off the 256x256 Cr part of the ycbcr image  
  20. CR = ycbcr_image(:,:,3)  
  21. %figure, imshow(CR); title('Cr part of Image');  
  22. size(CR)  
  23.   
  24.   
  25.   
  26.   
  27.   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值