简体   繁体   English

将多张图像合二为一的算法

[英]Algorithm to combine multiple images into one

I'm looking for an algorithm that will merge multiple images into one image.我正在寻找一种将多个图像合并为一个图像的算法。 The type of solution I'm looking for would not skew aspect ratios and would cause minimal overlap, but would lay images into a frame of a given size.我正在寻找的解决方案类型不会扭曲纵横比并且会导致最小的重叠,但会将图像放入给定大小的框架中。

Example, say I have 6 images of carpentry tools and I want my algorithm to lay them all out in one frame 300px by 300px.例如,假设我有 6 张木工工具的图像,我希望我的算法将它们全部放在 300 像素 x 300 像素的一帧中。 Images can be scaled if aspect ratios are maintained, and you want all images to be visible with minimal overlap.如果保持纵横比,可以缩放图像,并且您希望所有图像都可见且重叠最少。 No rotations either.也没有轮换。

The problem you are solving is np hard like bin packing but you can use heuristic algorithms to achieve that in reasonable time.您正在解决的问题与装箱一样困难,但您可以使用启发式算法在合理的时间内实现这一目标。 I would suggest Genetic algorithms for this case using fitness function which is proportional to empty space and inversely proportional to square error in sizes of the images.我建议在这种情况下使用适应度函数的遗传算法,该函数与空白空间成正比,与图像大小的平方误差成反比。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM