【问题标题】:Matplotlib is working but the images are super smallMatplotlib 正在运行,但图像非常小
【发布时间】:2019-06-05 02:26:18
【问题描述】:

我认为我有一个绘图工作,但是当我转到 plt.show() 时,它只会打印出微小的图像。我真的看不出它是什么。原始图像大小为 160X60。如何将图像放大以便我可以看到它们是什么? score 是一个数字,resultID 是图像的名称 感谢您的帮助

这是我正在使用的代码。

n_retrieval = len(result)
fig = plt.figure(figsize=(2*n_retrieval, 4))
fig.suptitle("Image Retrieval (k={})".format(n_retrieval), fontsize=25)

# Plot the Query image
ax = plt.subplot(2, n_retrieval, 0 +1)
q_img = mpimg.imread(queries + "0002_c1s1_000451_03.jpg")
plt.imshow(q_img)
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
for axis in ['top', 'bottom', 'left', 'right']:
    ax.spines[axis].set_linewidth(4)  # increase border thickness
    ax.spines[axis].set_color('black')  # set to black
ax.set_title("query",  fontsize=14)  # set subplot titl

for i, (score, resultID) in enumerate(results):
    result_path = resultID.split('\\')[1]
    image_path = dataset+ result_path
    img = mpimg.imread(image_path)
    ax = plt.subplot(2, n_retrieval, n_retrieval + i + 1)
    plt.imshow(img)
    ax.get_xaxis().set_visible(False)
    ax.get_yaxis().set_visible(False)
    for axis in ['top', 'bottom', 'left', 'right']:
        ax.spines[axis].set_linewidth(1)  # set border thickness
        ax.spines[axis].set_color('black')  # set to black
    ax.set_title("Rank #%d" % (i+1), fontsize=14)  # set subplot title

plt.show()

【问题讨论】:

    标签: python matplotlib computer-vision


    【解决方案1】:

    在 figsize 中使用大数字。

    fig = plt.figure(figsize=(18, 10))
    

    【讨论】:

    • 这也是一个选项。谢谢,但我认为最后一个问题是木星调整了图像大小以适应显示器。
    • 是的...您可以使用nbextensions configuration 启用全屏以查看更大的图片。
    【解决方案2】:

    没关系。出于某种原因,如果你双击木星中的图像,它会放大它。它太奇怪了。

    【讨论】:

      猜你喜欢
      • 2021-07-11
      • 2019-06-15
      • 1970-01-01
      • 1970-01-01
      • 2012-03-07
      • 2017-02-03
      • 1970-01-01
      • 2016-11-27
      • 1970-01-01
      相关资源
      最近更新 更多