重现步骤
我把两张图片做对比(difference函数处理),然后把得到的image进行二值化处理得到新的image图像,想问一下怎么把最后得到的做成透明图层,然后和图片融合显示出来?
def read_img(img_path):
img_data = image.Image(img_path)
img_data_rgb888=img_data.to_rgb888()
img_data_gray=img_data.to_grayscale()
img_hwc=img_data_rgb888.to_numpy_ref()
shape=img_hwc.shape
img_tmp = img_hwc.reshape((shape[0] * shape[1], shape[2]))
img_tmp_trans = img_tmp.transpose()
img_res=img_tmp_trans.copy()
img_return=img_res.reshape((shape[2],shape[0],shape[1]))
return img_return,img_data_rgb888,img_data_gray
img_path="/data/default.jpg"
test_path="/data/test.jpg"
img,img_data_rgb888,img_data_gray=read_img(img_path)
test,test_data_rgb888,test_data_gray=read_img(test_path)
加载图片
diff_img = test_data_gray.difference(img_data_gray)
clock = time.clock()
二值化(只用灰度阈值,其他分量设为0即可)
diff_img = diff_img.binary([(20, 255)],invert=False)
#Display.show_image(diff_img)
#融合图像
test_data_rgb888.draw_image(diff_img,0,0, alpha=256)
显示结果
Display.show_image(test_data_rgb888)
期待结果和实际结果
在现实图像中显示出图像除去对应的区域的图片
软硬件版本信息
错误日志
尝试解决过程
补充材料