-
-
Save MohitLamba94/7d40393f2fc1a478c84a6c5a4faaafdb 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 hidden or 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 | |
% | |
im = double(im); | |
R = im(:,:,1); | |
G = im(:,:,2); | |
B = im(:,:,3); | |
% rg = R - G | |
rg = abs(R - G); | |
rg = rg(:); | |
% yb = 1/2(R + G) - B | |
yb = abs( (0.5*(R + G)) - B ); | |
yb = yb(:); | |
% 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