我只需要在tensorflow 1.8中使用等效于cv2.threshold和np.std的tensorflow函数


I need to convert the following line into its tensorflow equivalent in tf version 1.8
but I am not getting the appropriate functions equivalent to cv2.threshold and np.std in TF  1.8
ret,mask = cv2.threshold(mask,tf.reduce_mean(mask)+1.2*np.std(mask),255,cv2.THRESH_BINARY)

线路的输出应为二进制掩码

您可以这样做:

thr = tf.math.reduce_mean(mask) + 1.2 * tf.math.reduce_std(mask)
mask = tf.cast(mask > thr, tf.uint8) * 255

最新更新