gpt4 book ai didi

python - 在tensorflow中将所有0值图像像素转换为255

转载 作者:太空宇宙 更新时间:2023-11-03 23:10:32 25 4
gpt4 key购买 nike

我是 tensorflow 的新手,

我需要将 3d 图像张量上的所有 0 值像素转换为 255

我可以这样写简历

img[np.where((img == [0, 0, 0]).all(axis=2))] = [255, 255, 255]

但是,我需要帮助来了解如何在 tensorflow 中执行此操作。因为我需要在 tensorflow 图中执行此操作

最佳答案

你可以这样做:

img = tf.cast(tf.equal(img, tf.zeros_like(img)), tf.int32)*255 + img

关于python - 在tensorflow中将所有0值图像像素转换为255,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51009991/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com