Jake Fund
Jake Fund

Reputation: 395

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

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 δΩ?

Upvotes: 1

Views: 2550

Answers (1)

Ander Biguri
Ander Biguri

Reputation: 35525

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

enter image description here

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:

enter image description here

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]

Upvotes: 2

Related Questions