change binary matrix to 3 values one