Source: https://www.creatis.insa-lyon.fr/~grenier/wp-content/uploads/teaching/TheoInfo/ExamenTI_TC_5GE_2007_Correction.pdf