我想修改一个由两个连续布尔数组选择的数组的子集。在我的用例中,我有一个图像
im
,而我正从一个感兴趣的区域
roi
使用某种条件。对于roi中的像素,我正在进行一些计算,并导出一个子区域
target
. 我现在想对
目标
在原始图像中。在代码中:
x, y = np.meshgrid(np.arange(800), np.arange(600))
im = (x + y) / 6 # a test image to work with
# use some arbitrary conditions to illustrate this
roi = (im > 64) & (im < 128)
target = (im[roi] & 0xf) > 0x7