How to make a checkerboard in numpy?

后端 未结 24 1339
小鲜肉
小鲜肉 2020-11-30 07:52

I\'m using numpy to initialize a pixel array to a gray checkerboard (the classic representation for \"no pixels\", or transparent). It seems like there ought to be a whizzy

24条回答
  •  我在风中等你
    2020-11-30 08:09

    import numpy as np
    b = np.array([[0,1],[1,0]])

    Replace n with a even numberand you will get the answer. Easy right?

    np.tile(b,(n, n))

提交回复
热议问题