2018-06-10深度学习之输入图像处理

2018-06-10  本文已影响0人  AI_Finance

import numpyas np

from matplotlibimport figure

from matplotlib.backends.backend_aggimport FigureCanvasAggas FigureCanvas

import skimage

from skimageimport transform

x = np.linspace(-1, 1, 50)

y1 =2 * x +1

# figure 1

fig = figure.Figure()

canvas = FigureCanvas(fig)

ax = fig.add_subplot(1, 1, 1)

ax.plot(x, y1)

ncols, nrows = fig.canvas.get_width_height()

ax.set_axis_off()

fig.canvas.draw()

observation = np.fromstring(fig.canvas.tostring_argb(), dtype=np.uint8, sep='').reshape(nrows, ncols, 4)

observation = skimage.transform.resize(observation, (64, 64))

# observation = np.delete(observation, np.s_[1:4], axis=2)

# observation = np.reshape(observation, (64, 64, 1))

上一篇下一篇

猜你喜欢

热点阅读