# Inverse mapping (affine transformation) for singular transform matrix

I was reading DIP by Gonzalez et al, and came across the concept of getting output image pixel values by calculating nearest neighbour in input image by inverse mapping of output pixel coordinates $(x,y)$ to input coordinates $(v,w)$ and applying its value. Something like

$$(v,w) = T^{-1} (x,y)$$ where $T$ is the image transform matrix.

But what if the matrix T is singular. How will we define the nearest neighbour pixels then? For eg. for

$$T = \left [ \begin{array}{ccc} 1 &1 &0\\ 1 &1 &0\\ 0 &0 &1 \end{array} \right],$$ whose inverse doesn't exist.

(I am guessing that the transform matrix is changed by adding or subtracting some values)

Usually, when an inverse is required but the matrix you are taking the inverse of is not guaranteed to be invertible, then the (Moore-Penrose) pseudoinverse is used:

In R, if $T$ is

T
[,1] [,2] [,3]
[1,]    1    1    0
[2,]    1    1    0
[3,]    0    0    1


Then the pseudoinverse calculated using ginv is

ginv(T)
[,1] [,2] [,3]
[1,] 0.25 0.25    0
[2,] 0.25 0.25    0
[3,] 0.00 0.00    1


Clearly, this won't give the identity matrix when multiplying $T$, but it's as close as you can get with $T$ singular.

T*ginv(T)
[,1] [,2] [,3]
[1,] 0.25 0.25    0
[2,] 0.25 0.25    0
[3,] 0.00 0.00    1

• If the only option is to not do the mapping, yes. Sometimes other regularization constraints are placed on the mapping which forces $T$ to be non-singular.
– Peter K.
Oct 21, 2015 at 12:30
• There exist there different generalized inverses for different purposes, and the term generalized inverse is sometimes used (hence ginv) for pseudo inverses. The book Generalized Inverses: Theory and Applications provides an extensive background. Oct 21, 2015 at 13:03
• @LaurentDuval Do you mean where does it come from? library(MASS)
– Peter K.
Oct 21, 2015 at 13:05
• My mistake, the comment is now complete Oct 21, 2015 at 13:05