两张图像的图像合成
我正在尝试解决用Java合成两个图像的问题。该程序将获取第一张图像的一部分并将其粘贴到第二张图像上。目标是使两个图像之间的边界不那么明显。边界的选择必须使得边界处的两个图像之间的差异很小。
我的任务:
编写一个方法来选择两个图像之间的边界。该方法将接收输入图像的重叠部分。必须首先对其进行转换,以便边界始终从左上角开始到右下角。
注意: 返回的图像不应该是连接的图像,但给出了使用了两个图像的哪些部分。
边界线的像素可以用常数(SEAM)
来标记。第一个图像的像素可以用整数0标记,第二个图像的像素可以用整数1标记。选择边界线后,可以使用floodfill
算法将多余的像素填充为0或1。
注意:图像可以表示为一个图表,其中每个像素与其左、右、上、下邻居相连。因此,使用洪水填充就像深度优先搜索一样。
必须使用最短路径算法来选择边界,以使其变小。
注意:除了数组(甚至ArrayList)之外,我不能使用任何java数据结构,
伙计们,我是这个领域的新手,正在尝试解决它。我必须采取什么步骤来解决这个问题?或指向教程的指针
I am trying to solve a problem of compositing two images in Java. The program will take a part of the first image and past it on the second image. The goal is to make the boundary between the two images less visible. The boundary must be chosen in such a way that the difference between the two images at the boundary is small.
My Tasks:
To write a method to choose the boundary between the two images. The method will receive the overlapping parts of the input images. This must first be transformed so that the boundary always starts from the left-top corner to the right-bottom corner.
NOTE:
The returned image should not be the joined image but gives which parts of the two images were used.
The pixels of the boundary line can be marked with a constant(SEAM)
. Pixels of the first image can be marked with integer 0, pixels of the second image with integer 1. After choosing the boundary line, the floodfill
algorithm can be used to fill the extra pixels with 0 or 1.
NOTE: The image can be represented as a graph whereby each pixel is connected with its left, right, top and bottom neighbor. So using the flood fill will be like depth-first search.
The shortest path algorithm must be used to choose the boundary in order to make it small.
NOTE: I can not use any java data structure except Arrays (not even ArrayList)
Guys, am new in this area and am trying to solve it. What steps must I follow to solve this problem? or a pointer to a tutorial
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会这样做:
选择检查边框的宽度。随你的意。
1. 找到最大可能的像素偏移。那是D。
2. 对于正方形 (+-D,+-D) 中所有可能的移位,找到边界的 k(相关商)。边界是在班次中间拍摄的。
3. k最大的移位是最好的。让它被视为理所当然。
4. 现在开始移动边框,以同样的方式通过“k”检查它。找到它的位置。完毕。
如果 D 很大并且过程很长,则分 2 个(或更多)阶段进行。在第一个阶段,计算 k 的步长很大,最后一个阶段的步长为 1。您也可以使用先前的过滤。
如果边界或相关图像的位置可以转动,则算法基本上不会改变 - 只是添加到它尝试在不同的稍微转动的位置和后来转动的边界之间尝试最佳 k。
I would do it so:
Choose the width of the border checked. At your will.
1. find the maximal possible shift in pixels. That is D.
2. For all possible shifts in the square (+-D,+-D) find the k (correlation quocient) for the border. The border is taken in the middle of the shift.
3. The shift that has the largest k is the best. Let it be taken for granted.
4. Now begin to move the border, checking it by "k" the same way. Find the place of it. Done.
If D is large and the process is long, do it in 2(or more) stages. On the first stages the step of counting k is large, the last stage has step of 1. You could also use previous filtering.
If the border or relative images' position could be turned, the algorithm doesn't change principally - only add to it trying for the best k among different slightly turned positions and later - turned border, too.