Image compositing of two Images

断了今生、忘了曾经 提交于 2019-12-25 02:08:46

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/8462577/image-compositing-of-two-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!