-
-
Save seyyah/27d845b71561e528e3b9a7509b61caa5 to your computer and use it in GitHub Desktop.
Algorithm to measure images colourfulness, adapted from "Measuring colourfulness in natural images" (Hasler and Susstrunk, 2003) http://infoscience.epfl.ch/record/33994/files/HaslerS03.pdf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function C = getColourfulness( im ) | |
% | |
% C = getColourfulness( im ) | |
% | |
% MATLAB algorithm implementation of the | |
% "Measuring colourfulness in natural images" | |
% (Hasler and Susstrunk, 2003) | |
% | |
% Input: | |
% im - image in RGB | |
% | |
% Output: | |
% C - colourfulness | |
% | |
i = 1; | |
[W, H, RGB] = size(im); | |
for x=1:W | |
for y=1:H | |
% rg = R - G | |
rg(i) = abs(double(im(x,y,1)) - double(im(x,y,2))); | |
% yb = 1/2(R + G) - B | |
yb(i) = abs(.5 * (double(im(x,y,1)) + double(im(x,y,2))) - double(im(x,y,3))); | |
i = i+1; | |
end | |
end | |
% standard deviation and the mean value of the pixel | |
% cloud along direction, respectively | |
stdRG = std(rg); | |
meanRG = mean(rg); | |
stdYB = std(yb); | |
meanYB = mean(yb); | |
stdRGYB = sqrt((stdRG)^2 + (stdYB)^2); | |
meanRGYB = sqrt((meanRG)^2 + (meanYB)^2); | |
C = stdRGYB + 0.3*meanRGYB; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment