快速双边滤波源码「建议收藏」

%FastBilateralFilterUsingRaisedCosines%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%inImg:grayscaleimage%sigma1:widthofspatialGaussian%sigma2:widthofrangeGaussian%[-w,w]^…

大家好,又见面了,我是你们的朋友全栈君。

快速双边滤波源码「建议收藏」

% Fast Bilateral Filter Using Raised Cosines

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  inImg        :  grayscale image
%  sigma1      : width of spatial Gaussian
%  sigma2      : width of range Gaussian
%  [-w, w]^2  : domain of spatial Gaussian
%  tol             : truncation error
%
%  Author:    Kunal N. Chaudhury.
%  Date:        March 1, 2012.
%  Modified:  June 21, 2014.
%
%  References:
%  [1] K.N. Chaudhury, D. Sage, and M. Unser, “Fast O(1) bilateral
%  filtering using trigonometric range kernels,” IEEE Trans. Image Proc.,
%  vol. 20, no. 11, 2011.
%
% [2] K.N. Chaudhury, “Acceleration of the shiftable O(1) algorithm for
% bilateral filtering and non-local means,”  IEEE Transactions on Image Proc., 
% vol. 22, no. 4, 2013.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% load test image
clc, clear all, close all force;
Img    =  double( imread(‘./images/ckb.jpg’) );
[m, n] = size(Img);

% create noisy image (additive Gaussian noise)
sigma  =  20;
inImg  =  Img + sigma * randn(m, n);

% filter parameters
sigma1 = 4;
sigma2 = 30;
tol        = 0.01;

% Set window for spatial Gaussian
w  = 6*sigma1;
if (mod(w,2) == 0)
    w  = w+1;
end

% call bilateral filter
tic;
[outImg, param] =  shiftableBF(inImg, sigma1, sigma2, w, tol);
toc;

% plot results
T  = param.T;
N  = param.N;
M  = param.M;
gamma  =  1 / (sqrt(N) * sigma2);
twoN   =  2^N;

warning(‘off’); %#ok<WNOFF>

s  = linspace(-T, T, 200);
g  = exp( -s.^2 / (2 * sigma2 *sigma2) );
gApprox  = cos(gamma * s).^N;
if M ==  0
    gTrunc = gApprox;
else
    gTrunc = zeros( 1, length(s) );
    for k = M : N – M
        gTrunc = gTrunc + (nchoosek(N, k) / twoN) * …
            cos( (2*k – N) * gamma * s  );
    end
end

figure(‘Units’,’normalized’,’Position’,[0 0.5 1 0.5]);
plot(s, g, ‘b’);
hold on,
plot(s, gApprox, ‘m’),
hold on,
plot(s, gTrunc, ‘r’);
axis(‘tight’), grid(‘on’),
legend(‘Gassian’,’Raised cosine’,’Truncated raised cosine’,’FontSize’, 10);
title(‘Comparison of the range kernels’, ‘FontSize’, 10),

peak  = 255;
PSNR0 = 10 * log10(m * n * peak^2 / sum(sum( (inImg – Img).^2)) );
PSNR1 = 10 * log10(m * n * peak^2 / sum(sum((outImg – Img).^2)) );

figure(‘Units’,’normalized’,’Position’,[0 0.5 1 0.5]);
colormap gray,
subplot(1,3,1), imshow(uint8(Img)),
title(‘Original’, ‘FontSize’, 10), axis(‘image’, ‘off’);
subplot(1,3,2), imshow(uint8(inImg)),
title([ ‘Noisy, ‘, num2str(PSNR0, ‘%.2f’), ‘dB’] , ‘FontSize’, 10),
axis(‘image’, ‘off’);
subplot(1,3,3), imshow(uint8(outImg)),
title([ ‘Filtered, ‘, num2str(PSNR1, ‘%.2f’), ‘dB’] , ‘FontSize’, 10),
axis(‘image’, ‘off’);

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/127397.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • jquery中的$()是什么_js简单特效

    jquery中的$()是什么_js简单特效在设计前端页面时,会用到很多效果,我们可以采用CSS样式或JavaScript来实现,在这里给大家介绍JS动画

    2022年10月16日
  • Spring StoredProcedure Cursor 使用

    Spring StoredProcedure Cursor 使用JavaCodeimportjava.sql.ResultSet;importjava.sql.SQLException;importjava.text.DateFormat;importjava.text.SimpleDateFormat;importjava.util.HashMap;importjava.util.List;importjava.util.

    2022年7月26日
  • 数字图像处理标准图像Lena的故事「建议收藏」

    数字图像处理标准图像Lena的故事「建议收藏」熟悉图像处理或者压缩的工程师、研究人员和学生经常在他们的实验或者项目任务里使用“Lenna”或者“Lena”的图像。Lenna图像已经成为被广泛使用的测试图像。今天,Lenna图像的使用被认为是数字图像历史上最重要的事件之一。然而,很少有人看过原始的图像并知道完整的关于Lenna的故事。这里3sBeta将综合收集的材料对此做一个详细的梳理。。。1.Lena图像的来源在数

    2022年6月19日
  • 考哪些证书国家有补贴_提交书证申请书范本

    考哪些证书国家有补贴_提交书证申请书范本当下的互联网应用如果是外网访问,一般都是https方式访问,需申请https证书目录Whyhttps?Whatishttps?Howtocreatehttps?Whyhttps?http明文传输不安全,因此需要进行加密处理,加密后端http就是httpsWhatishttps?https涉及很多概念,对称非对称加密、CA、数字签名、证书等等。有兴趣查看这里漫画解说https这里简要总结:A(客户端浏览器)——通过https://www.

    2022年10月1日
  • 排名前三的python 开源 IDE

    Python无处不在,似乎它支持从主要网站到桌面实用程序到企业软件的所有功能。Python已经被用来编写流行的软件项目,如dnf/yum,OpenStack,OpenShot,Blender,Calibre,甚至是原始的BitTorrent客户端。它也恰好是我最喜欢的编程语言之一。就个人而言,Python多年来一直是我从大学课程到小脚本的一切课程,帮助我自动执行重复的任务。它是少数…

    2022年4月8日
  • windows nginx使用

    windows nginx使用

    2020年11月9日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号