Source: https://zhankunluo.com/course/ece_image_proc_i/ECE637_Zhankun_Luo_lab2.pdf