tfg.image.matting.build_matrices

Generates the closed form matting Laplacian.

Generates the closed form matting Laplacian as proposed by Levin et al. in "A Closed Form Solution to Natural Image Matting". This function also return the pseudo-inverse matrix allowing to retrieve the matting linear coefficient.

image A tensor of shape [B, H, W, C].
size An int representing the size of the patches used to enforce smoothness.
eps A small number of type float to regularize the problem.
name A name for this op. Defaults to "matting_build_matrices".

A tensor of shape [B, H - pad, W - pad, size^2, size^2] containing the matting Laplacian matrices. A tensor of shape [B, H - pad, W - pad, C + 1, size^2] containing the pseudo-inverse matrices which can be used to retrieve the matting linear coefficients. The padding pad is equal to size - 1.

ValueError If image is not of rank 4.