C# 算法从一些图像生成图像 (2048x2048)
我想做的是创建一个图像(在我的例子中为2048x2048) 该算法应该以这种方式工作:
-用户从文件夹中选择一些图像并告诉我的程序“生成图像”
-程序检查是否可以将所有图像放入单个图像中(大小问题),否则返回错误消息
-程序找到将所有图像放入图像中的正确方法,然后提示用户选择保存路径(显然旧图像不应该调整大小/剪切)
问题显然是最后一步,我实际上不知道该怎么做它,程序还应该检查另一件事,如果图像文件名是 myimage_1 并且有一个“myimage_2”,那么这些图像应该彼此靠近(通常对于 3,4 等相同)
有人可以帮助我吗?
What I would like to do is create an image (2048x2048 in my case)
The algorithm should work in this way:
-User select some images from a folder and tells my program "generate image"
-The program check if can put all images inside a single image (size problem), otherwise returns an error message
-The program find the correct way to put all images inside the image and then prompt the user to choose a savepath (obviusly old images shouldn't be resized/cut)
The problem is obviusly the last step, I don't have actually idea how to do it, also there is another thing the program should check, if an image filename is myimage_1 and there is a "myimage_2" those images should be put near eachother (obiusly same for 3,4 and so on)
Can someone help me with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说,这看起来像是一个多维背包问题。
更多信息请参见此处。
当然可能有简单的解决方案,因为我不是该领域的专家,而且我的算法课程远远落后于我!无论如何,它可能会帮助启动线程:)
您也许还可以通过采用简单的贪婪算法来解决这个问题,但它当然不会给出最佳解决方案,并且肯定会导致第二步出现一些误报。
it looks like a multi-dimensional knapsack problem to me.
More info here.
There may be of course simple solutions as I'm no expert on the domain and my algorithms classes are far behind me! It will perhaps help anyway to launch the thread :)
You could perhaps also solve this by adapting an easy greedy algorithm but it will of course not give the optimal solution and will then surely lead to some false negatives for your 2nd step.