convolve to differentiate black and white colors
You have to make all the values zero in the matrix except the middle row and thus, what you can start thinking is how to get such filter matrix which can give you this result. One of the many filter matrices you can think of, which satisfy your requirements is [0 1 0;0 0 0;0 -1 0].