在tf.image.central_crop函数的Tensorflow文档中:
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.
--------考虑以下代码:
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
In [11]: crop_np.shape
Out[11]: (228, 226, 3)裁剪尺寸为228x226
它给出了面积比率:
In [12]: 228*226 / (456*450.)
Out[12]: 0.2511111111111111而不是我预想的0.5。有人能帮我澄清一下吗?
https://stackoverflow.com/questions/41353079
复制相似问题