matlab彩色图像锐化

锐化的目的是突出图像的细节。本文使用Laplacian算子进行锐化处理,其他锐化算子的处理类似。

锐化过程如下:

  • 读取RGB彩色图像
  • 分别提取R、G、B通道的分量
  • 设置锐化模板
  • 对图像三个分量分别锐化滤波
  • 将滤波后的三分量组合
  • % 彩色图像锐化
    
    
    clc;
    clear all;
    close all;
    
    rgb1= imread('football.jpg');
    rgb=im2double(rgb1);
    rgb_R=rgb(:,:,1);
    rgb_G= rgb(:,:,2);
    rgb_B= rgb(:,:,3);
    lapMatrix=[1 1 1;
                1 -8 1;
                1 1 1];
            %模1 1*8
    Matrix2=[1 0 1;
        0 -4 0;
        1 0 1];
    %模21*4
    
    %模1*8 3个不同的第三参数的锐化滤波
    %replicate
    
    f_R=imfilter(rgb_R,lapMatrix,'replicate');
    f_G=imfilter(rgb_G,lapMatrix,'replicate');
    f_B=imfilter(rgb_B,lapMatrix,'replicate');
    
    %symmetric
    f_R2=imfilter(rgb_R,lapMatrix,'symmetric');
    f_G2=imfilter(rgb_G,lapMatrix,'symmetric');
    f_B2=imfilter(rgb_B,lapMatrix,'symmetric');
    
    %circular
    f_R3=imfilter(rgb_R,lapMatrix,'circular');
    f_G3=imfilter(rgb_G,lapMatrix,'circular');
    f_B3=imfilter(rgb_B,lapMatrix,'circular');
    
    %模1*4 3个不同的第三参数的锐化滤波
    %replicate
    f2_R=imfilter(rgb_R,Matrix2,'replicate');
    f2_G=imfilter(rgb_G,Matrix2,'replicate');
    f2_B=imfilter(rgb_B,Matrix2,'replicate');
    
    %symmetric
    f2_R2=imfilter(rgb_R,Matrix2,'symmetric');
    f2_G2=imfilter(rgb_G,Matrix2,'symmetric');
    f2_B2=imfilter(rgb_B,Matrix2,'symmetric');
    
    %circular
    f2_R3=imfilter(rgb_R,Matrix2,'circular');
    f2_G3=imfilter(rgb_G,Matrix2,'circular');
    f2_B3=imfilter(rgb_B,Matrix2,'circular');
    
    %模1 锐化后的3分量
    rgb_tmp=cat(3,f_R,f_G,f_B);
    rgb_tmp2=cat(3,f_R2,f_G2,f_B2);
    rgb_tmp3=cat(3,f_R3,f_G3,f_B3);
    
    %模2 锐化后的3分量
    rgb2_tmp=cat(3,f2_R,f2_G,f2_B);
    rgb2_tmp2=cat(3,f2_R2,f2_G2,f2_B2);
    rgb2_tmp3=cat(3,f2_R3,f2_G3,f2_B3);
    
    %模1 3种参数的处理结果与原图相减
    rgb_sharped =imsubtract(rgb,rgb_tmp);
    rgb_sharped2=imsubtract(rgb,rgb_tmp2);
    rgb_sharped3=imsubtract(rgb,rgb_tmp3);
    
    %模2 3种参数的处理结果与原图相减
    rgb2_sharped =imsubtract(rgb,rgb2_tmp);
    rgb2_sharped2=imsubtract(rgb,rgb2_tmp2);
    rgb2_sharped3=imsubtract(rgb,rgb2_tmp3);
    
    figure;
    subplot(341);imshow(rgb);title('原图');
    subplot(342);imshow(rgb_R);title('R');
    subplot(343);imshow(rgb_G);title('G');
    subplot(344);imshow(rgb_B);title('B');
    
    subplot(345);imshow(rgb_tmp);title('cat_r_g_b ');
    subplot(346);imshow(rgb_tmp2);title('cat_r_g_b2');
    subplot(347);imshow(rgb_tmp3);title('cat_r_g_b3');
    
    subplot(348);imshow(rgb_sharped);title('1*8 replicate');
    subplot(349);imshow(rgb_sharped2);title('1*8 symmetric');
    subplot(3,4,10);imshow(rgb_sharped3);title('1*8 3 circular');
    
    rgb_diff=imsubtract(rgb_sharped,rgb_sharped2);%replicate sub symmetric
    
    subplot(3,4,11);imshow(rgb_diff);title('replicateSubSymmetric');
    
    figure;
    subplot(341);imshow(rgb);title('原图');
    subplot(342);imshow(rgb_R);title('R');
    subplot(343);imshow(rgb_G);title('G');
    subplot(344);imshow(rgb_B);title('B');
    
    subplot(345);imshow(rgb2_tmp);title('cat_r_g_b ');
    subplot(346);imshow(rgb2_tmp2);title('cat_r_g_b2');
    subplot(347);imshow(rgb2_tmp3);title('cat_r_g_b3');
    
    subplot(348);imshow(rgb2_sharped);title('1*4 replicate');
    subplot(349);imshow(rgb2_sharped2);title('1*4 symmetric');
    subplot(3,4,10);imshow(rgb2_sharped3);title('1*4 3 circular');
    
    rgb2_diff=imsubtract(rgb2_sharped,rgb2_sharped2);%replicate sub symmetric
    
    subplot(3,4,11);imshow(rgb2_diff);title('replicateSubSymmetric2');
    
    rgb3_diff=imsubtract(rgb2_sharped2,rgb_sharped2);%1*8Sub1*4
    figure;
    imshow(rgb3_diff);title('1*8Sub1*4');
    


    这里写图片描述
    图1

    这里写图片描述
    图2


    这里写图片描述
    图3

  • 14
    点赞
  • 60
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jerryzhou;

您的鼓励,将是我的动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值