implemented Bernsen local threshold algorithm