python - 有什么方法可以加入多个矢量(jpg格式)图像而没有任何重叠?
问题描述
我有一个拼图,其中图像分为 32 个图块。这些瓷砖被洗牌。现在我想用 python 和 OpenCV 解决这个难题。问题是图像中没有重叠。
例子
好处是图像具有统一的像素,因为它是从矢量图像转换而来的。
我尝试的是根据给定图像每一侧的分数找到给定图像每一侧的每个图像。
分数是多少? 所以我拍了一张图片,一方面让我们说右找到图像的最后一列(右侧)和所有其他图像的第一列(左侧)之间的差异,并将该差异相加并调用该分数。
#rightScore[i] will store the index of image on right side of the image at index 'i'.
#right[i] will store the pixels of right side of image at index 'i'.
#similarly for other sides.
rightScore = np.zeros((36,))
topScore = np.zeros((36,))
bottomScore = np.zeros((36,))
leftScore = np.zeros((36,))
for i in range(36):
score = np.inf
for j in range(36):
if i==j:
continue
temp = np.sum(np.abs(np.ravel(right[i] - left[j])))
if score > temp:
rightScore[i] = j
score = temp
现在对于给定的图像,我使用所有其他图像生成分数,然后找到最低分数。具有最低分数的相应图像是将位于给定图像左侧的图像。我为所有方面做这件事。
此方法适用于某些图像,但不适用于所有图像。任何人都可以帮忙吗?
另外,我知道最终图像将有 12 行,每行 3 个图块(12 * 3)。
解决方案
推荐阅读
- regex - Notepad ++正则表达式如何替换第三次出现的斜线并绕过第一次和第二次?
- python - 如何在 PYsimpleGUI 中显示熊猫图
- python - 电报机器人如何在没有隐私模式的情况下接收附加到电报群聊中命令的照片?
- opengl - OpenGL中每一帧的像素强度总和
- java - 为 BorderPane 设置背景颜色在行中有效,但不在 CSS 文件中
- excel - Linking two different Excel tables and auto-populate one when populate another
- customization - Acumatica - 如何更改编辑按钮打开的页面(铅笔)
- facebook - FB 故事分享显示空白而不是图像,但提要通过 FB 分享显示图像
- python - 熊猫数据框中的数字已更改
- python - 芹菜任务和mysql