tv | R Documentation |
The total variation of a vector, matrix, or list of matrices. Uses L1 norm of discrete gradients for vectors and L2 norm of discrete gradients for matrices.
tv(value, ...)
value |
An Expression, vector, or matrix. |
... |
(Optional) Expression objects or numeric constants that extend the third dimension of value. |
An Expression representing the total variation of the input.
rows <- 10 cols <- 10 Uorig <- matrix(sample(0:255, size = rows * cols, replace = TRUE), nrow = rows, ncol = cols) # Known is 1 if the pixel is known, 0 if the pixel was corrupted Known <- matrix(0, nrow = rows, ncol = cols) for(i in 1:rows) { for(j in 1:cols) { if(stats::runif(1) > 0.7) Known[i,j] <- 1 } } Ucorr <- Known %*% Uorig # Recover the original image using total variation in-painting U <- Variable(rows, cols) obj <- Minimize(tv(U)) constraints <- list(Known * U == Known * Ucorr) prob <- Problem(obj, constraints) result <- solve(prob, solver = "SCS") result$getValue(U)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.