-
Notifications
You must be signed in to change notification settings - Fork 1
/
scale_image.m
43 lines (36 loc) · 921 Bytes
/
scale_image.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
function y = scale_image(y)
%% what does this function do
%{
details of this function
%}
%% inputs:
%{
%}
%% outputs:
%{
%}
%% author:
%{
Pengcheng Zhou
Columbia University, 2018
%}
%% code
gamma = 0.05;
ind_nnz = (y>0);
y_nnz = y(ind_nnz);
y_thr = max(y)/5;
ind_lower = (y_nnz<y_thr);
ind_upper = (y_nnz>=y_thr);
%% convert data in the lower part to follow exponential distribution
y_lower = y_nnz(ind_lower);
[~, idx] = sort(y_lower);
y_lower(idx) = expinv(linspace(0.0001, 0.9999, length(y_lower)));
y_nnz(ind_lower) = (y_lower-min(y_lower))/range(y_lower)*gamma;
%% convert data in the upper part to follow normal distribution
y_upper = y_nnz(ind_upper);
[~, idx] = sort(y_upper);
y_upper(idx) = norminv(linspace(0.0001, 0.9999, length(y_upper)));
y_nnz(ind_upper) = (y_upper -min(y_upper))/range(y_upper) * (1-gamma)+gamma;
%%
y(ind_nnz) = y_nnz;