heightmap_interpolation.inpainting.fd_pde_inpainter module

class heightmap_interpolation.inpainting.fd_pde_inpainter.FDPDEInpainter(**kwargs)

Bases: ABC

fast_norm(vector)
get_config()
get_decimal_places(number)
inpaint(image, mask)
inpaint_grid(image, mask)
inpaint_grid_sparse(image, mask)

Solve the inpainting PDE as a sparse linear system.

Works for any linear step_fun (CCST, Sobolev, TV linearised, …). For non-linear PDEs (AMLE) the result will be approximate; use Picard iteration (repeated calls with an updated image) to reach convergence.

Uses a matrix-free LinearOperator so step_fun is never changed. The system built is: A_uu @ x = -step_fun(f_zero)[unknowns] where f_zero has the unknown pixels set to zero and known pixels at their original values.

inpaint_multigrid(image, mask)

Multigrid solver for inpainting problems.

Parameters:
  • img – input image to be inpainted

  • mask – logical mask of the same size as the input image. True == known pixels, False == unknown pixels to be inpainted

Returns:

inpainted image

print_end()
print_msg(msg)
print_start(msg)
set_term_criteria(f)
abstract step_fun(f, mask)
supports_direct_solver = True

Abstract base class for Finite-Differences Partial Differential Equation (FDPDE) Inpainters

Common interphase for PDE-based inpainting methods. Solves the problem using finite differences in a gradient-descent manner.

dt

Gradient descent step size.

Type:

float

term_check_iters

Check the relative change between iterations of the optimizer every this number of iterations.

Type:

int

term_thres

Stop the optimization when the energy descent between iterations is less than

Type:

float

max_iters

Maximum number of iterations for the optimizer.

Type:

int

relaxation

Over-relaxation parameter. It is still under testing, use with care.

Type:

float

mgs_levels

Number of levels of detail to use in the Mult-Grid Solver (MGS). Setting it to 1 deactivates the MGS.

Type:

int

mgs_min_res

minimum resolution (width or height) allowed for a level in the MGS. If the level of detail in the pyramid gets to a value lower than this, the pyramid construction will stop.

Type:

int

print_progress

Print information about the progress of the optimization on screen.

Type:

bool

print_progress_iters

If print_progress==True, the information will be printed every this number of iterations.

Type:

int

init_with

initializer for the unknown data before applying the optimization.

Type:

str

convolver_type

the convolver used for all the convolutions required by the solver.

Type:

str

debug_dir

a debug directory where the intermediate steps will be rendered. Useful to create a video of the evolution of the solver.

Type:

str

use_direct_solver

if True, solve as a sparse linear system instead of time-stepping (only valid for linear PDEs).

Type:

bool

direct_solver

sparse solver to use when use_direct_solver=True. Either ‘cg’ (conjugate gradient, for SPD systems) or ‘minres’ (for symmetric indefinite). Default: ‘cg’.

Type:

str

term_check(f, fnew, buf=None)