How do I index a numpy array of zeroes with a boolean datatype to True?

前端 未结 2 854
借酒劲吻你
借酒劲吻你 2021-01-20 17:09

So I\'m recreating a Matlab project they made last year, part of which involves creating mask that pull out the RGB bands. They did this by an array of logical zeroes.

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-20 17:51

    You can translate Matlab's

    GMask_Whole(1:2:end,2:2:end) = true;
    

    to python by

    green_mask_whole[::2,1::2] = True
    

    (assuming green_mask_whole is a numpy array)

提交回复
热议问题