swap pixel values directly instead of using opencv