-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmslProcessUNIQUE.m
47 lines (40 loc) · 1.23 KB
/
mslProcessUNIQUE.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
function feature = mslProcessUNIQUE(img,W,b)
%%
% Author: Mohit Prabhushankar
% PI: Ghassan AlRegib
% Version: 1.0
% Published in: Signal Processing Letter October 2016
% Publication details:
%%
I = im2double(img);
%Parameter Initialisation
[m,n,~] = size(I);
epsilon = 0.1;
count = 1;
scale = 8;
%Convert m x n x 3 image into [(8x8x3) x count] patches
i = 1;
while (i < m - (scale - 2))
j = 1;
while (j< n-(scale-2)) %(j < 512)
patch_temp = I(i:i+(scale-1),j:j+(scale-1),:);
patches(:,count) = reshape(patch_temp,[],1);
count = count+1;
j = j+scale;
end
i = i+scale;
end
% Subtract mean patch (hence zeroing the mean of the patches)
meanPatch = mean(patches,2);
patches = bsxfun(@minus, patches, meanPatch);
% Apply ZCA whitening
sigma = patches * patches' / (count-1);
[u, s, ~] = svd(sigma);
ZCAWhite = u * diag(1 ./ sqrt(diag(s) + epsilon)) * u';
patches = ZCAWhite * patches;
%Process the patches using the different models and multiply
%resultant by the sharpness indices
feature = mslComputeUNIQUE(patches,W,b);
%Reshaping back to a single vector
feature = reshape(feature,[],1);
end