normalize gray image before threshold