The gray_thresh_img function and morphological functions