norm {PET}R Documentation

L1 and L2 norm

Description

Computes the L1 or L2 norm between two vectors or matrices.

Usage

norm(orgImage, testImage, mode = "L2")

Arguments

orgImage

A vector or a matrix.

testImage

A vector or a matrix of same size as orgImage.

mode

Defaults to mode="L2" to compute a L2 norm between orgImage and testImage. Alternative choice is "L1".

Details

If X and Y are vectors of length n or (n1,n2)-matrices with n=n1*n2 then the L1-norm and the L2-norm will be compute as follow:

L1 = 1/n*(∑_{i=1}^{n} |X_i-Y_i|)

L2 = (1/n*(∑_{i=1}^{n} (X_i-Y_i)^2))^0.5

Value

Returns the L1 or L2 norm.

Author(s)

Joern Schulz, jschulz78@web.de.

Examples

P <- phantom(n=101)
P.pois <- markPoisson(P)$Data
cat("The L1 is:",norm(P, P.pois, mode="L1"),"\n")
rm(P,P.pois)

[Package PET version 0.5.1 Index]