【发布时间】:2022-06-15 18:29:56
【问题描述】:
完成“patch process.m”函数,实现双边过滤。
在“lenna med.png”上使用 7 × 7 内核执行双边过滤,其中 σk = 2,σi = 0.05。给定以下所需的输出
请找到以下补丁过程的功能:
function y = patch_process(patch, gaussian, sigma)
% Obtain the input pixel size
[m, n] = size(patch);
% Obtain the center pixel indices
hm = floor(m/2);
hn = floor(n/2);
% Obtain the central pixel intensity
center_intensity = patch(hm+1, hn+1);
% Define the intensity weights for the bilateral filter
int_weights =
% Calculate the filter weights as the multiplication of the Gaussian kernel
% and the intensity kernel
weights =
% Normalize the filter weights
weights = weights / sum(weights(:));
% Conducting linearing filtering
% (1) Location-wise multiplication
patch_weights = patch .* weights;
% (2) Summation to obtain the output pixel value for the patch
y = sum(patch_weights(:));
这是主要代码:
clear all;
I = imread('lenna_med.png');
I = im2double(I);
% Define the Gaussian kernel
gaussian =
% Conducitng bilateral filtering
BI =
% Conducting gaussian filtering
GI =
subplot(1,3,1);
imshow(I);
subplot(1,3,2);
imshow(GI);
subplot(1,3,3);
imshow(BI);
【问题讨论】:
-
您的问题是什么?您发布了您应该做的练习。你不会指望我们为你做这件事,是吗?请在此处阅读:meta.stackoverflow.com/q/334822/7328782
-
您应该将其从作业形式转换为问题形式。同样重要的是要更清楚地表明您实际上已经尝试了解决方案。
标签: matlab image-processing filter