-
Notifications
You must be signed in to change notification settings - Fork 7
/
CEIQ.m
31 lines (27 loc) · 1.23 KB
/
CEIQ.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
%==========================================================================
% J. Yan, J. Li, X. Fu, "No-Reference Quality Assessment of Contrast-Distorted Images using Contrast Enhancement"
%
% Please try your own contrast distorted images with different levels.
% Larger predicted score means better contrast quality.
% This model was trained by all the images in CCID2104 database using
% LIBSVM.
%==========================================================================
function [predicted_score] = CEIQ(Img)
load model.mat;
feat = [];
gImg = rgb2gray(Img);
enhancedImg = histeq(gImg);
[fmean, fmap] = ssim(gImg, enhancedImg);
f1 = fmean; %image similarity, f1
h1 = imhist(gImg, 128);
h2 = imhist(enhancedImg, 128);
h1 = h1 / (size(gImg, 1) * size(gImg, 2));
h2 = h2 / (size(gImg, 1) * size(gImg, 2));
goodones = h1 > 0 & h2 > 0;
f2 = - sum(h1(goodones) .* log2(h1(goodones))); % f2, Eq. (3)
f3 = - sum(h2(goodones) .* log2(h2(goodones))); %f3, Eq. (3)
f4 = - sum(h1(goodones) .* log2(h2(goodones))); %f4, Eq. (4)
f5 = - sum(h2(goodones) .* log2(h1(goodones))); %f5, Eq. (5)
feat = [feat f1 f2 f3 f4 f5];
[predicted_score accuracy decision_values] = svmpredict(1, feat, model);
end