codecamp

TensorFlow函数:tf.image.resize_images

tf.image.resize_images函数

tf.image.resize_images(
    images,
    size,
    method=ResizeMethod.BILINEAR,
    align_corners=False
)

定义在:tensorflow/python/ops/image_ops_impl.py.

请参阅指南:图像操作>调整大小

使用指定的method调整images为size.

调整大小的图像将失真,如果他们的原始纵横比与size不一样.为了避免扭曲,请参阅tf.image.resize_image_with_crop_or_pad.

method 可以是下列之一:

  • ResizeMethod.BILINEAR:双线性插值.
  • ResizeMethod.NEAREST_NEIGHBOR:最近的邻居插值.
  • ResizeMethod.BICUBIC:双三次插值.
  • ResizeMethod.AREA:区域插值.

如果method是ResizeMethod.NEAREST_NEIGHBOR,则返回值与images具有相同的类型.它也将与images具有相同的类型,如果images的大小可以静态地确定为与size相同,因为在这种情况下返回images.否则,返回值有类型float32.

参数:

  • images:形状为[batch, height, width, channels]的4-D张量或形状为[height, width, channels]的3-D张量.
  • size:2个元素(new_height, new_width)的1维int32张量,表示图像的新大小.
  • method:ResizeMethod,默认为ResizeMethod.BILINEAR.
  • align_corners:布尔型,如果为True,则输入和输出张量的4个拐角像素的中心对齐,并且保留角落像素处的值;默认为False.

可能引发的异常:

  • ValueError:如果images的形状与此函数的形状参数不兼容.
  • ValueError:如果size有无效的形状或类型.
  • ValueError:如果指定了不支持的调整大小方法.

返回:

如果images是四维,则返回一个形状为[batch, new_height, new_width, channels]的四维浮动张量;如果images是三维,则返回一个形状为[new_height, new_width, channels]的三维浮动张量.

TensorFlow函数:tf.image.resize_bilinear
TensorFlow函数:tf.image.resize_image_with_crop_or_pad
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }