Is Octave slow?

January 7, 2010

Some interesting tips from this blog

MATLAB functions for computing relative luminance in W3C standard

August 11, 2009

I have written two MATLAB functions for computing relative luminance and contrast ratio using the Web Content Accessibility Guidelines (WCAG) 2.0.

Relative Luminance is the relative brightness of any point in a colorspace, normalized to 0 for darkest black and 1 for lightest white. For the sRGB colorspace, the relative luminance of a color is defined as

L = 0.2126 * R + 0.7152 * G + 0.0722 * B

where R, G and B are defined as:

if RsRGB <= 0.03928 then R = RsRGB/12.92 else R = ((RsRGB+0.055)/1.055) ^ 2.4

if GsRGB <= 0.03928 then G = GsRGB/12.92 else G = ((GsRGB+0.055)/1.055) ^ 2.4

if BsRGB <= 0.03928 then B = BsRGB/12.92 else B = ((BsRGB+0.055)/1.055) ^ 2.4

RsRGB, GsRGB, and BsRGB are defined as:

RsRGB = R8bit/255

GsRGB = G8bit/255

BsRGB = B8bit/255

while 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.

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

I have submitted the functions to matlab central. I think you will find there in few days. But I attach here the script

You can find the files at Matlab Central here.


function relativeluminance = relativeluminance(erre,gi,bi)

% By Alessandro Farini 11 August 2009

%compute RsRGB as a value between 0 and 1




%compute the value of RGB in sRGB space

if (rsErre>0.03928)





if (rsGi>0.03928)





if (rsBi>0.03928)





%compute the relative luminance

relativeluminance = 0.2126*erreFinal + 0.7152*giFinal + 0.0722*biFinal;


function contrastratiow3c = contrastratiow3c(erreMax,giMax,biMax,erreMin,giMin,biMin)

% By Alessandro Farini 11 August 2009

%computing the relative luminance for the lighter and darker colors




A Technical blog….

August 10, 2009

Probably the contents of this blog will be quite technical. My non-technical blog is I will use English language (in a terrible way) because in Italy there are very few people interested to this topic. Tommor I hope I will stsrt with the first post devoted to octave and matlab

Hello world!

August 10, 2009

Welcome to This is your first post. Edit or delete it and start blogging!


Get every new post delivered to your Inbox.