cv2.addWeighted()
有tensorflow 类似功能吗?我需要这个函数对我的tf.dataset
对象进行图像处理.
如果没有,我如何使用OpenCV方法和TensorFlow来获得相同的结果?
下面是我的代码供参考.
import tensorflow as tf
from tensorflow.image import ResizeMethod
import pathlib
import os
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import cv2
from PIL import Image
np.set_printoptions(precision=4)
filepaths = df['filepath'].values
labels = df[[0,2,4]].values
ds_train = tf.data.Dataset.from_tensor_slices((filepaths, labels))
def read_image(image_file, labels):
img = tf.io.read_file(image_file)
img = tf.image.decode_png(img, channels=3, dtype=tf.uint8)
img = tf.image.resize(img, [512, 512], preserve_aspect_ratio=False)
img2 = ...
# Need something equivalent to cv2.addWeighted() to use on img and img2
return img, labels
ds_train = ds_train.map(read_image).batch(32, drop_remainder = True)
如果这个问题已经得到回答,我提前道歉.我到处搜索,找不到复制的方法.