Exemplar-Based Inpainting - how to compute the normal to the contour and the isophate

十年热恋 提交于 2019-12-12 10:20:48

问题


I am using the Exemplar-Based algorithm by Criminisi. In section 3 of his paper it describes the algorithm. The target region that needs to be inpainted is denoted as Ω (omega). The border or the contour of Ω where it meets the rest of the image (denoted as Φ(phi)), is δΩ (delta omega).

Now on page four of the paper, it states that np(n subscript p) is the normal to the contour of δΩ. and ▽Ip (also includes orthogonal superscript) is the isophote at point p, which is the gradient turned 90 degrees.

My multivariable calculus is rusty, but how do we go about computing np and ▽Ip with python libraries? Also isn't np different for each point p on δΩ?


回答1:


There are different ways of computing those variables, all depending in your numeric description of that boundary. n_p is the normal direction of the contour.

Generally, if your contour is described with an analytic equation, or if you can write an analytic equation that approximates the contour (e.g. a spline curve that fits 5 points (2 in each side of the point you want), you can derive that spline, compute the tangent line in the point you want using

Then, get a unit vector among that line and get the orthonormal vector to that one. All this is very easy to do (ask if you don't understand).

Then you have the isophone. It looks like its a vector orthonormal of the gradient with its modulus. Computing the directional gradient on an image is very very commonly used technique in image processing. You can get the X and Y derivatives of the image easily (hint: numpy.gradient, or SO python gradient). Then, the total gradient of the image is described as:

So just create a vector with the x and y gradients (taken from numpy.gradient). Then get the orthogonal vector to that one.

NOTE: How to get an orthogonal vector in 2D

[v2x v2y] = [v1y, -v1x]


来源:https://stackoverflow.com/questions/31331874/exemplar-based-inpainting-how-to-compute-the-normal-to-the-contour-and-the-iso

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