首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Tensorflow image.central_crop (Mis)行为

Tensorflow image.central_crop (Mis)行为
EN

Stack Overflow用户
提问于 2016-12-28 06:39:59
回答 0查看 317关注 0票数 0

tf.image.central_crop函数的Tensorflow文档中:

代码语言:javascript
复制
Remove the outer parts of an image but retain the central region of
the image along each dimension. If we specify central_fraction = 0.5,
this function returns the region marked with "X" in the below diagram.

 --------
|        |
|  XXXX  |
|  XXXX  |
|        |   where "X" is the central 50% of the image.
 --------

考虑以下代码:

代码语言:javascript
复制
In [2]: import tensorflow as tf
In [3]: image_raw = tf.placeholder(tf.string)
In [4]: image = tf.image.decode_jpeg(image_raw, channels=3)
In [5]: crop = tf.image.central_crop(image, central_fraction=0.5)
In [6]: init_op = tf.global_variables_initializer()
In [7]: sess = tf.Session()
In [8]: sess.run(init_op)
In [9]: image_np, crop_np = sess.run([image, crop],
   ...:     feed_dict={image_raw: open("/tmp/test.jpg", 'rb').read()})
In [10]: image_np.shape
Out[10]: (456, 450, 3)

原图大小为456x450

代码语言:javascript
复制
In [11]: crop_np.shape
Out[11]: (228, 226, 3)

裁剪尺寸为228x226

它给出了面积比率:

代码语言:javascript
复制
In [12]: 228*226 / (456*450.)
Out[12]: 0.2511111111111111

而不是我预想的0.5。有人能帮我澄清一下吗?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41353079

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档