-
Notifications
You must be signed in to change notification settings - Fork 1
/
highboost.m
executable file
·50 lines (41 loc) · 1.48 KB
/
highboost.m
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function [imgHighpass, imgHighboost] = highboost(mat, c)
[h, w] = size(mat);
imgHighpass = mat;%zeros(h, w);
kernel_size = 3;
radius = (kernel_size-1)/2;
kernelArea = kernel_size*kernel_size;
kernelHighpass = [ 0 -1 0;
-1 4 -1;
0 -1 0];
kernelOriginalC = [ 0 0 0;
0 c 0;
0 0 0];
for i = 1 : h
for j = 1 : w
pixelValue = []; kerneli = 1;
for ki = i-radius : i+radius
kernelj = 1;
for kj = j-radius : j+radius
if ((ki < 1 || kj < 1) || (ki > h || kj > w))
pixelValue = [pixelValue, 0];
else
kval = double(kernelHighpass(kerneli,kernelj));
matval = double(mat(ki,kj));
pixelValue = [pixelValue, kval*matval];
end
kernelj = kernelj + 1;
end
kerneli = kerneli + 1;
end
imgHighpass(i,j) = round(abs(sum(pixelValue)/kernelArea));
end
end
imgHighpass = normalize(imgHighpass);
imgHighboost = imgHighpass;
for i = 1 : h
for j = 1 : w
imgHighboost(i,j) = c*mat(i,j)+imgHighpass(i,j);
end
end
imgHighboost = normalize(imgHighboost);
end