將一幅或多幅圖像從 YUV 轉換為 RGB。
用法
tf.image.yuv_to_rgb(
images
)
參數
-
images
二維或更高等級。要轉換的圖像數據。最後一個維度必須是大小 3。
返回
-
images
與images
形狀相同的張量。
輸出與 images
張量形狀相同的張量,包含像素的 RGB 值。僅當圖像中的 Y 值在 [0,1] 中,U 和 V 值在 [-0.5,0.5] 中時,輸出才被明確定義。
根據上麵的說明,如果 YUV 圖像的像素值不在要求的範圍內,則需要縮放它們。下麵給出的示例說明了在將圖像輸入 yuv_to_rgb
之前對每個圖像通道的預處理。
yuv_images = tf.random.uniform(shape=[100, 64, 64, 3], maxval=255)
last_dimension_axis = len(yuv_images.shape) - 1
yuv_tensor_images = tf.truediv(
tf.subtract(
yuv_images,
tf.reduce_min(yuv_images)
),
tf.subtract(
tf.reduce_max(yuv_images),
tf.reduce_min(yuv_images)
)
)
y, u, v = tf.split(yuv_tensor_images, 3, axis=last_dimension_axis)
target_uv_min, target_uv_max = -0.5, 0.5
u = u * (target_uv_max - target_uv_min) + target_uv_min
v = v * (target_uv_max - target_uv_min) + target_uv_min
preprocessed_yuv_images = tf.concat([y, u, v], axis=last_dimension_axis)
rgb_tensor_images = tf.image.yuv_to_rgb(preprocessed_yuv_images)
相關用法
- Python tf.image.random_brightness用法及代碼示例
- Python tf.image.pad_to_bounding_box用法及代碼示例
- Python tf.image.adjust_hue用法及代碼示例
- Python tf.image.random_contrast用法及代碼示例
- Python tf.image.rot90用法及代碼示例
- Python tf.image.random_hue用法及代碼示例
- Python tf.image.flip_left_right用法及代碼示例
- Python tf.image.convert_image_dtype用法及代碼示例
- Python tf.image.stateless_random_flip_up_down用法及代碼示例
- Python tf.image.random_saturation用法及代碼示例
- Python tf.image.extract_glimpse用法及代碼示例
- Python tf.image.flip_up_down用法及代碼示例
- Python tf.image.crop_to_bounding_box用法及代碼示例
- Python tf.image.stateless_random_jpeg_quality用法及代碼示例
- Python tf.image.crop_and_resize用法及代碼示例
- Python tf.image.psnr用法及代碼示例
- Python tf.image.stateless_random_hue用法及代碼示例
- Python tf.image.rgb_to_yiq用法及代碼示例
- Python tf.image.stateless_random_crop用法及代碼示例
- Python tf.image.resize_with_crop_or_pad用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.image.yuv_to_rgb。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。