0
我有一个PyQt4应用程序,我使用matplotlib表示一个16位灰度图像。我代表的形象非常大。由于内存限制,我很遗憾没能代表更大的图像,所以我切片他们以这样的方式拉伸坐标轴以适应压缩图像
ImageDataArray[::ratio, ::ratio]
当显示的地块中,轴取决于比例压缩。因此,图像的坐标对于知道感兴趣的信息位于何处非常重要,我希望再次按比例因子拉伸坐标轴。
如何管理这个,所以即使使用matplotlib工具栏中的缩放功能,也会显示正确的坐标?
在此先感谢。
代码:
from numpy import fromfile, uint16, shape
import matplotlib.pyplot as plt
data = fromfile('D:\\ImageData.raw', dtype=uint16)
data.resize((ysize,xsize))
xmin = 0
ymin = 0
xmax = shape(data)[1]
ymax = shape(data)[0]
ratio = max(max(shape(data)[0], shape(data)[1])/2000, 1)
data_slice = data[ymin:ymax:ratio, xmin:xmax:ratio]
fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.imshow(data_slice, cmap='gray', interpolation='nearest')
plt.show()
程度关键字参数你有没有得到这个整理出来? – tacaswell