Source: https://www.philadelphia.edu.jo/academics/hhardan/uploads/Image_Processing-ch3_part_1.pdf