from
functions for computing relative luminance in W3C standard
by Alessandro Farini
two functions computing relative luminance and contrast ratio using the WCAG 2.0
|
| contrastratiow3c(erreMax,giMax,biMax,erreMin,giMin,biMin) |
function contrastratiow3c = contrastratiow3c(erreMax,giMax,biMax,erreMin,giMin,biMin)
% the funciont compute the contrast ratio using using the Web
% Content Accessibility Guidelines (WCAG) 2.0.
% Contrast Ratio= (L1 + 0.05) / (L2 + 0.05), where
% L1 is the relative luminance of the lighter of the colors, and
% L2 is the relative luminance of the darker of the colors.
% Note Contrast ratios can range from 1 to 21 (commonly written 1:1 to 21:1).
% the input is the rgb value (from 0 to 255) of the ligheter and the darker
% colors.
% The WCAG guidelines indicate that contrast ratio should be at least 4.5:1
% It uses the function 'relativeluminance'
% By Alessandro Farini 11 August 2009
%computing the relative luminance for the lighter and darker colors
elle1=relativeluminance(erreMax,giMax,biMax);
elle2=relativeluminance(erreMin,giMin,biMin);
contrastratiow3c=(elle1+0.05)/(elle2+0.05);
|
|
Contact us at files@mathworks.com