TensorFlow-谷歌深度学习库 图片处理模块
Module: tf.image
这篇文章主要介绍TensorFlow处理图片这一块,这个模块和之前说过的文件I/O处理一样也是主要从python导过来的。
通过官方文档,我们了解到这个模块主要有一下这些个函数。
Functions
adjust_brightness(...)
: Adjust the brightness of RGB or Grayscale images.
adjust_contrast(...)
: Adjust contrast of RGB or grayscale images.
adjust_gamma(...)
: Performs Gamma Correction on the input image.
adjust_hue(...)
: Adjust hue of an RGB image.
adjust_saturation(...)
: Adjust saturation of an RGB image.
central_crop(...)
: Crop the central region of the image.
convert_image_dtype(...)
: Convertimage
todtype
, scaling its values if needed.
crop_and_resize(...)
: Extracts crops from the input image tensor and bilinearly resizes them (possibly
crop_to_bounding_box(...)
: Crops an image to a specified bounding box.
decode_and_crop_jpeg(...)
: Decode and Crop a JPEG-encoded image to a uint8 tensor.
decode_bmp(...)
: Decode the first frame of a BMP-encoded image to a uint8 tensor.
decode_gif(...)
: Decode the first frame of a GIF-encoded image to a uint8 tensor.
decode_image(...)
: Convenience function fordecode_bmp
,decode_gif
,decode_jpeg
,
decode_jpeg(...)
: Decode a JPEG-encoded image to a uint8 tensor.
decode_png(...)
: Decode a PNG-encoded image to a uint8 or uint16 tensor.
draw_bounding_boxes(...)
: Draw bounding boxes on a batch of images.
encode_jpeg(...)
: JPEG-encode an image.
encode_png(...)
: PNG-encode an image.
extract_glimpse(...)
: Extracts a glimpse from the input tensor.
extract_jpeg_shape(...)
: Extract the shape information of a JPEG-encoded image.
flip_left_right(...)
: Flip an image horizontally (left to right).
flip_up_down(...)
: Flip an image vertically (upside down).
grayscale_to_rgb(...)
: Converts one or more images from Grayscale to RGB.
hsv_to_rgb(...)
: Convert one or more images from HSV to RGB.
image_gradients(...)
: Returns image gradients (dy, dx) for each color channel.
is_jpeg(...)
: Convenience function to check if the 'contents' encodes a JPEG image.
non_max_suppression(...)
: Greedily selects a subset of bounding boxes in descending order of score.
pad_to_bounding_box(...)
: Padimage
with zeros to the specifiedheight
andwidth
.
per_image_standardization(...)
: Linearly scalesimage
to have zero mean and unit norm.
psnr(...)
: Returns the Peak Signal-to-Noise Ratio between a and b.
random_brightness(...)
: Adjust the brightness of images by a random factor.
random_contrast(...)
: Adjust the contrast of an image by a random factor.
random_flip_left_right(...)
: Randomly flip an image horizontally (left to right).
random_flip_up_down(...)
: Randomly flips an image vertically (upside down).
random_hue(...)
: Adjust the hue of an RGB image by a random factor.
random_saturation(...)
: Adjust the saturation of an RGB image by a random factor.
resize_area(...)
: Resizeimages
tosize
using area interpolation.
resize_bicubic(...)
: Resizeimages
tosize
using bicubic interpolation.
resize_bilinear(...)
: Resizeimages
tosize
using bilinear interpolation.
resize_image_with_crop_or_pad(...)
: Crops and/or pads an image to a target width and height.
resize_images(...)
: Resizeimages
tosize
using the specifiedmethod
.
resize_nearest_neighbor(...)
: Resizeimages
tosize
using nearest neighbor interpolation.
rgb_to_grayscale(...)
: Converts one or more images from RGB to Grayscale.
rgb_to_hsv(...)
: Converts one or more images from RGB to HSV.
rgb_to_yiq(...)
: Converts one or more images from RGB to YIQ.
rgb_to_yuv(...)
: Converts one or more images from RGB to YUV.
rot90(...)
: Rotate image(s) counter-clockwise by 90 degrees.
sample_distorted_bounding_box(...)
: Generate a single randomly distorted bounding box for an image.
sobel_edges(...)
: Returns a tensor holding Sobel edge maps.
ssim(...)
: Computes SSIM index between img1 and img2.
ssim_multiscale(...)
: Computes the MS-SSIM between img1 and img2.
total_variation(...)
: Calculate and return the total variation for one or more images.
transpose_image(...)
: Transpose image(s) by swapping the height and width dimension.
yiq_to_rgb(...)
: Converts one or more images from YIQ to RGB.
yuv_to_rgb(...)
: Converts one or more images from YUV to RGB.
接下来,我们从中挑一些常用的详细了解一下。
decode_jpeg函数:
tf.image.decode_jpeg(
contents,
channels=0,
ratio=1,
fancy_upscaling=True,
try_recover_truncated=False,
acceptable_fraction=1,
dct_method='',
name=None
)
相应的,tensorflow也提供解码其他图片格式如png,gif,bmp等等。
这个函数将一个jpeg格式的图片解析为一个unit8的tensor。
参数列表中的channel表示转换后想要的颜色通道的个数。接收0(使用原jpeg通道个数),1(grayscale),3(rgb)
参数列表中的ratio表示降级(downscale)图片。 接收值有1,2,4,8.
未完待续ing。。。
TensorFlow-谷歌深度学习库 图片处理模块的更多相关文章
- Keras:基于Theano和TensorFlow的深度学习库
catalogue . 引言 . 一些基本概念 . Sequential模型 . 泛型模型 . 常用层 . 卷积层 . 池化层 . 递归层Recurrent . 嵌入层 Embedding 1. 引言 ...
- TensorFlow-谷歌深度学习库 手把手教你如何使用谷歌深度学习云平台
自己的电脑跑cnn, rnn太慢? 还在为自己电脑没有好的gpu而苦恼? 程序一跑一俩天连睡觉也要开着电脑训练? 如果你有这些烦恼何不考虑考虑使用谷歌的云平台呢?注册之后即送300美元噢-下面我就来介 ...
- windows下Anaconda3配置TensorFlow深度学习库
Anaconda3(python3.6)安装tensorflow Anaconda3中安装tensorflow3是非常简单的,仅需通过 pip install tensorflow 测试代码: imp ...
- 人工智能不过尔尔,基于Python3深度学习库Keras/TensorFlow打造属于自己的聊天机器人(ChatRobot)
原文转载自「刘悦的技术博客」https://v3u.cn/a_id_178 聊天机器人(ChatRobot)的概念我们并不陌生,也许你曾经在百无聊赖之下和Siri打情骂俏过,亦或是闲暇之余与小爱同学谈 ...
- 30个深度学习库:按Python、C++、Java、JavaScript、R等10种语言分类
30个深度学习库:按Python.C++.Java.JavaScript.R等10种语言分类 包括 Python.C++.Java.JavaScript.R.Haskell等在内的一系列编程语言的深度 ...
- Python机器学习库和深度学习库总结
我们在Github上的贡献者和提交者之中检查了用Python语言进行机器学习的开源项目,并挑选出最受欢迎和最活跃的项目. 1. Scikit-learn(重点推荐) www.github.com/sc ...
- TensorFlow和深度学习入门教程(TensorFlow and deep learning without a PhD)【转】
本文转载自:https://blog.csdn.net/xummgg/article/details/69214366 前言 上月导师在组会上交我们用tensorflow写深度学习和卷积神经网络,并把 ...
- TensorFlow和深度学习新手教程(TensorFlow and deep learning without a PhD)
前言 上月导师在组会上交我们用tensorflow写深度学习和卷积神经网络.并把其PPT的參考学习资料给了我们, 这是codelabs上的教程:<TensorFlow and deep lear ...
- 基于TensorFlow的深度学习系列教程 2——常量Constant
前面介绍过了Tensorflow的基本概念,比如如何使用tensorboard查看计算图.本篇则着重介绍和整理下Constant相关的内容. 基于TensorFlow的深度学习系列教程 1--Hell ...
随机推荐
- (NO.00001)iOS游戏SpeedBoy Lite成形记(一)
这是本猫第一个原创iOS游戏,留此为证!看编号貌似要写9万多个,千锤百炼还是太少吧!? ;) 这是一个赛跑游戏,几位选手从起点跑到终点看谁用的时间最少.现在需要实现的功能是: 1.8位选手从起点移动至 ...
- Android免Root无侵入AOP框架Dexposed
Dexposed框架是阿里巴巴无线事业部近期开源的一款在Android平台下的免Root无侵入运行期AOP框架,该框架基于AOP思想,支持经典的AOP使用场景,可应用于日志记录,性能统计,安全控制,事 ...
- 【面试笔试算法】Problem 9: 腾讯2016年研发实习笔试题:最长回文子串
(一)题目 问题:求给定字符串s的回文(palindrome)子串中,长度最大的回文子串的长度. 回文(palindrome)是指从左往右读和从右往左读字符串,看到的字符串都是一样的.比如" ...
- 使用Multiplayer Networking做一个简单的多人游戏例子-2/3(Unity3D开发之二十六)
猴子原创,欢迎转载.转载请注明: 转载自Cocos2Der-CSDN,谢谢! 原文地址: http://blog.csdn.net/cocos2der/article/details/51007512 ...
- Android Hal 分析
本文是基于android4.0.3.对应其他低版本的代码,可能有所差异,但基本大同小异. Android的HAL是为了保护一些硬件提供商的知识产权而提出的,是为了避开linux的GPL束缚.思路是把控 ...
- workbench的schema讲解一:(维度dimension设置的基本内容)
维度名字尽量用英文:因为,saiku读取schema配置文件时,用中文会出现不可预知的错误.比如,引用维度用中文,就容易出现不可预估的错误.如果要显示中文:每个对象的caption字段里键入中文,则可 ...
- UTL_HTTP Call a Web Service and Pass Parameters as Part of the URL
SET DEFINE OFF SET SERVEROUTPUT ON DECLARE req UTL_HTTP.REQ; resp UTL_HTTP.RESP; value VARCHAR2(3276 ...
- 一键安装 redmine on windows 和发邮件设置
一键安装 redmine on windows 和发邮件设置 1)使用http://bitnami.org/stack/redmine一键安装redmine (windows). 2)修改下面的文件: ...
- 【11】-java递归和非递归二叉树前序中序后序遍历
二叉树的遍历 对于二叉树来讲最主要.最基本的运算是遍历. 遍历二叉树 是指以一定的次序访问二叉树中的每个结点.所谓 访问结点 是指对结点进行各种操作的简称.例如,查询结点数据域的内容,或输出它的值,或 ...
- Unity的资源管理
本篇文章翻译自Unity的官方文档,原文地址:https://docs.unity3d.com/Manual/BehindtheScenes.html Unity自动导入资源的同时为你管理这些资源产生 ...