我是 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/