-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvEnhance.m
67 lines (51 loc) · 1.99 KB
/
svEnhance.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
%{
Image Detail Enhancement using Sub-Window Variace Filter
MATLAB reference implementation of our filter in my article titled:
Multi-scale Image Decomposition Using a Local Statistical Edge Model
https://ieeexplore.ieee.org/document/9483837
copyright(c) 2021 Kin-Ming Wong (Mike Wong)
Example use:
[A, result] = svf(double(imread('cat.png'))/255.0, 3, 0.025);
imshow(result);
If you have used this reference code in your research or work; please
consider citing my paper.
@INPROCEEDINGS{9483837,
author={Wong, Kin-Ming},
booktitle={2021 IEEE 7th International Conference on Virtual Reality (ICVR)},
title={Multi-scale Image Decomposition Using a Local Statistical Edge Model},
year={2021},
volume={},
number={},
pages={10-18},
doi={10.1109/ICVR51878.2021.9483837}}
%}
% Parameters
% inName = Name of your PNG image sans extension
% radius = filter radius (in pixels)
% epsilon = epsilon (threshold variance value of a clear edge to preserve)
% mAmp = Medium details enhancement factor
% fAmp = Fine details enhancement factor
%
% Outputs:
% The enhanced image
%
function svEnhance( inName, radius, epsilon, mAmp, fAmp )
inFILE = sprintf( '%s.png' ,inName);
inImage = double(imread(inFILE))/255.0;
[~, base0] = svf( inImage, radius, epsilon );
detailF = inImage - base0;
[~, base1] = svf( base0, radius * 4, epsilon * 2 );
detailM = base0 - base1;
figure;
imshow(inImage);
figure;
result = base1 + mAmp * detailM + fAmp * detailF;
imshow(result);
detail = detailM + detailF;
% out_DETAIL = sprintf( '%s_DETAIL.png' ,inName);
% imwrite(detail + 0.5, out_DETAIL);
% out_BASE = sprintf( '%s_BASE.png' ,inName);
% imwrite(base1, out_BASE);
out_RESULT = sprintf( '%s_RESULT.png' ,inName);
imwrite(result, out_RESULT);
end