Title: | Total Variation Regularization |
---|---|
Description: | Provides tools for denoising noisy signal and images via Total Variation Regularization. Reducing the total variation of the given signal is known to remove spurious detail while preserving essential structural details. For the seminal work on the topic, see Rudin et al (1992) <doi:10.1016/0167-2789(92)90242-F>. |
Authors: | Kisung You [aut, cre] |
Maintainer: | Kisung You <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.2 |
Built: | 2024-11-22 06:49:25 UTC |
Source: | CRAN |
tvR provides tools for denoising noisy signal and images via Total Variation Regularization. Reducing the total variation of the given signal is known to remove spurious detail while preserving essential structural details. For now, we provide tools for denoising only on 1-dimensional signals or 2-dimensional images, where the latter be represented as 2d or 3d array.
Given a 1-dimensional signal f
, it solves an optimization of the form,
where is fidelity term and
is total variation regularization term.
The naming convention of a parameter
method
is <problem type>
+ <name of algorithm>
.
For more details, see the section below.
denoise1(signal, lambda = 1, niter = 100, method = c("TVL2.IC", "TVL2.MM"))
denoise1(signal, lambda = 1, niter = 100, method = c("TVL2.IC", "TVL2.MM"))
signal |
vector of noisy signal. |
lambda |
regularization parameter (positive real number). |
niter |
total number of iterations. |
method |
indicating problem and algorithm combination. |
a vector of same length as input signal.
The cost function for TV-L2 problem is
where for a given 1-dimensional vector, .
Algorithms (in conjunction with model type) for this problems are
"TVL2.IC"
Iterative Clipping algorithm.
"TVL2.MM"
Majorization-Minorization algorithm.
The codes are translated from MATLAB scripts by Ivan Selesnick.
Rudin LI, Osher S, Fatemi E (1992). “Nonlinear total variation based noise removal algorithms.” Physica D: Nonlinear Phenomena, 60(1-4), 259–268. ISSN 01672789.
Selesnick IW, Parekh A, Bayram I (2015). “Convex 1-D Total Variation Denoising with Non-convex Regularization.” IEEE Signal Processing Letters, 22(2), 141–144. ISSN 1070-9908, 1558-2361.
## generate a stepped signal x = rep(sample(1:5,10,replace=TRUE), each=50) ## add some additive white noise xnoised = x + rnorm(length(x), sd=0.25) ## apply denoising process xproc1 = denoise1(xnoised, method = "TVL2.IC") xproc2 = denoise1(xnoised, method = "TVL2.MM") ## plot noisy and denoised signals plot(xnoised, pch=19, cex=0.1, main="Noisy signal") lines(xproc1, col="blue", lwd=2) lines(xproc2, col="red", lwd=2) legend("bottomleft",legend=c("Noisy","TVL2.IC","TVL2.MM"), col=c("black","blue","red"),#' lty = c("solid", "solid", "solid"), lwd = c(0, 2, 2), pch = c(19, NA, NA), pt.cex = c(1, NA, NA), inset = 0.05)
## generate a stepped signal x = rep(sample(1:5,10,replace=TRUE), each=50) ## add some additive white noise xnoised = x + rnorm(length(x), sd=0.25) ## apply denoising process xproc1 = denoise1(xnoised, method = "TVL2.IC") xproc2 = denoise1(xnoised, method = "TVL2.MM") ## plot noisy and denoised signals plot(xnoised, pch=19, cex=0.1, main="Noisy signal") lines(xproc1, col="blue", lwd=2) lines(xproc2, col="red", lwd=2) legend("bottomleft",legend=c("Noisy","TVL2.IC","TVL2.MM"), col=c("black","blue","red"),#' lty = c("solid", "solid", "solid"), lwd = c(0, 2, 2), pch = c(19, NA, NA), pt.cex = c(1, NA, NA), inset = 0.05)
Given an image f
, it solves an optimization of the form,
where is fidelity term and
is total variation regularization term.
The naming convention of a parameter
method
is <problem type>
+ <name of algorithm>
.
For more details, see the section below.
denoise2( data, lambda = 1, niter = 100, method = c("TVL1.PrimalDual", "TVL2.PrimalDual", "TVL2.FiniteDifference"), normalize = FALSE )
denoise2( data, lambda = 1, niter = 100, method = c("TVL1.PrimalDual", "TVL2.PrimalDual", "TVL2.FiniteDifference"), normalize = FALSE )
data |
standard 2d or 3d array. |
lambda |
regularization parameter (positive real number). |
niter |
total number of iterations. |
method |
indicating problem and algorithm combination. |
normalize |
a logical; |
denoised array as same size of data
.
An input data
can be either (1) 2-dimensional matrix representaing grayscale image, or (2) 3-dimensional array
for color image.
The cost function for TV-L2 problem is
where for a given 2-dimensional array,
Algorithms (in conjunction with model type) for this problems are
"TVL1.PrimalDual"
Primal-Dual algorithm.
The cost function for TV-L2 problem is
and algorithms (in conjunction with model type) for this problems are
"TVL2.PrimalDual"
Primal-Dual algorithm.
"TVL2.FiniteDifference"
Finite Difference scheme with fixed point iteration.
Rudin LI, Osher S, Fatemi E (1992). “Nonlinear total variation based noise removal algorithms.” Physica D: Nonlinear Phenomena, 60(1-4), 259–268. ISSN 01672789.
Chambolle A, Pock T (2011). “A First-Order Primal-Dual Algorithm for Convex Problems with Applications to Imaging.” Journal of Mathematical Imaging and Vision, 40(1), 120–145. ISSN 0924-9907, 1573-7683.
## Not run: ## Load grey-scale 'lena' data data(lena128) ## Add white noise sinfo <- dim(lena128) # get the size information xnoised <- lena128 + array(rnorm(128*128, sd=10), sinfo) ## apply denoising models xproc1 <- denoise2(xnoised, lambda=10, method="TVL2.FiniteDifference") xproc2 <- denoise2(xnoised, lambda=10, method="TVL1.PrimalDual") ## compare gcol = gray(0:256/256) opar <- par(no.readonly=TRUE) par(mfrow=c(2,2), pty="s") image(lena128, main="original", col=gcol) image(xnoised, main="noised", col=gcol) image(xproc1, main="TVL2.FiniteDifference", col=gcol) image(xproc2, main="TVL1.PrimalDual", col=gcol) par(opar) ## End(Not run)
## Not run: ## Load grey-scale 'lena' data data(lena128) ## Add white noise sinfo <- dim(lena128) # get the size information xnoised <- lena128 + array(rnorm(128*128, sd=10), sinfo) ## apply denoising models xproc1 <- denoise2(xnoised, lambda=10, method="TVL2.FiniteDifference") xproc2 <- denoise2(xnoised, lambda=10, method="TVL1.PrimalDual") ## compare gcol = gray(0:256/256) opar <- par(no.readonly=TRUE) par(mfrow=c(2,2), pty="s") image(lena128, main="original", col=gcol) image(xnoised, main="noised", col=gcol) image(xproc1, main="TVL2.FiniteDifference", col=gcol) image(xproc2, main="TVL1.PrimalDual", col=gcol) par(opar) ## End(Not run)
Lena is probably one of the most well-known example in image processing and computer vision. Due to CRAN instability, history of this image can be found by googling the story of Lena.
data(lena128)
data(lena128)
matrix of size
USC SIPI Image Database.
Gonzalez, Rafael C. and Woods, Richard E. (2017) Digital Image Processing (4th ed.). ISBN 0133356728.
data(lena128) image(lena128, col=gray((0:100)/100), axes=FALSE, main="lena128")
data(lena128) image(lena128, col=gray((0:100)/100), axes=FALSE, main="lena128")