Is there a TensorFlow equivalent for cv2.addWeighted()? I need this function for image processing on my tf.dataset object.
If there isn't, how can I use the OpenCV method with TensorFlow to get the same result?
Here is my code below for reference.
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)
I apologize in advance if this question has already been answered. I searched everywhere and could not find a way to replicate this.