forked from robodhruv/vector-valued-regularization
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyBilateralFiltering.m
More file actions
32 lines (27 loc) · 822 Bytes
/
myBilateralFiltering.m
File metadata and controls
32 lines (27 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function [im_new] = myBilateralFiltering(img, std)
% This function implements the Bilinear filter on "img" with the 3D gaussian
% passed with the argument "std".
img = max (0,img);
imgs = img/max(max(img)) * 100;
img_trunc = ceil(imgs);
img_trunc = img_trunc + (img_trunc==0);
space = zeros([size(img, 1), size(img, 2), max(max(img_trunc))]);
void_space = zeros(size(space));
m = max(max(img_trunc));
for i = 1:size(img, 1)
for j = 1:size(img, 2)
space(i, j, img_trunc(i, j)) = img(i, j);
void_space(i, j, img_trunc(i, j)) = 1;
end
end
% Simplest way, for now
B = imgaussfilt3(space, std);
B1 = imgaussfilt3(void_space, std);
B = B ./ B1;
im_new = zeros(size(img));
% disp(size(B));
for i = 1:size(img, 1)
for j = 1:size(img, 2)
im_new(i, j) = B(i, j, img_trunc(i, j));
end
end