python - 使用 image_slicer.py 将切片加入完整图像

我正在使用来自 PyPiimage_slicer。 我已将图像切割成大小相等的子图像。子图像不保存在 ram 中,而是存储在 HD 中。

现在我需要将子图像设置回完整图像。我的问题是我不明白它是如何处理的。

code of join implementaion

 def join(tiles):
  """
  @param ``tiles`` - Tuple of ``Image`` instances.
  @return ``Image`` instance.
  """
    im = Image.new('RGB', get_combined_size(tiles), None)
    columns, rows = calc_columns_rows(len(tiles))
  for tile in tiles:         
    Im.paste(tile.image, tile.coords)
    return im

所以 join 函数需要“tiles”类型的对象,但是如果我们看一下原始的 code我们看到生成和保存图 block 的函数 slice 只保存 png 文件,它不包含连接所需的任何元信息,例如坐标或位置。

所以我的问题是,如何才能正确连接由 slice 函数生成的切片?

提前致谢

最佳答案

slice 返回一个图 block 元组,然后您可以将其与 join

一起使用

如果您已经将图 block 存储在目录中,请使用

加载它们
tiles = image_slicer.open_images_in(img_dir)

该函数根据文件名计算出坐标,虽然不理想但可以工作。

https://stackoverflow.com/questions/57957371/

相关文章:

keras - 在不运行模型的情况下计算 Keras 中的损失

c# - Bot 在 MS TEAMS channel 中尝试发送自适应卡时抛出 "Operatio

c# - 在 ASP.NET Core 中通过代码优先在 SQL 中使用 FileStream

c++ - 使用 ioctl 在 C++ 中以编程方式添加路由

javascript - 要求 Prop 不起作用。 "Invalid call at.."

reactjs - 尝试在 react-testing-library 中呈现组件时出错 - 得到一

java - Hibernate.unproxy 有任何副作用吗?

azure-functions - Azure 函数无法在 Azure 门户中下载 PowerShe

python - "You should never modify something you ar

sass - 找不到要导入的样式表