Gradient transpose along $x$ or $y$ direction in images

466 Views Asked by At

Gradient in images $$ \nabla I=\nabla_x I+\nabla _y I$$ can be approximated to forward or backward difference ($[1 -1], [-1 1] $etc.) and also calculated from sobel or prewitt operators but I came across a question in which I have to find $$\nabla_x^T I+\nabla_x^T I $$ I research and found that $\nabla ^T $ is the divergence but I am confused what will be the definition of $\nabla_x^T$ or $\nabla_y^T$.

1

There are 1 best solutions below

0
On

The first equation should state that \begin{equation} \nabla I = \begin{bmatrix} \partial_x I \\ \partial_y I \end{bmatrix}. \end{equation} Here $\partial_x$ and $\partial_y$ denote partial derivative operators. Then \begin{equation} \nabla^T I = \partial_x^T I + \partial_y^T I. \end{equation} We could also write these equations using block operator notation, like this: \begin{equation} \nabla = \begin{bmatrix} \partial_x \\ \partial_y \end{bmatrix}, \qquad \nabla^T = \begin{bmatrix} \partial_x^T & \partial_y^T \end{bmatrix}. \end{equation}

You are working with images, but it's enlightening to think about taking the discrete gradient of a one-dimensional signal. In that case, you can easily write down the matrix that represents the discrete gradient operator, and you can form its transpose explicitly.

Informally: \begin{align} \partial_x^T &= - \partial_x,\\ \partial_y^T &= -\partial_y,\\ \nabla^T &= \begin{bmatrix} -\partial_x & -\partial_y \end{bmatrix} = -\text{div}. \end{align} But note that in the discrete case, if $\partial_x$ uses forward differences, then $\partial_x^T$ uses backwards differences, and you must be careful to handle the boundary correctly.

Here is a snippet of Matlab code that will compute $\nabla I$ and $\nabla^T I$ for you:

applyD1 = @(u) [u(2:end,:) - u(1:end-1,:) ; zeros(1,size(u,2))];
applyD2 = @(u) [u(:,2:end) - u(:,1:end-1), zeros(size(u,1),1)];

applyD1Trans = @(u) [-u(1,:) ; u(1:end-2,:) - u(2:end-1,:); u(end-1,:)];
applyD2Trans = @(u) [-u(:,1) , u(:,1:end-2) - u(:,2:end-1), u(:,end-1)];

You can try this code out and check that the relationship that @dohmatob mentioned is satisfied, with randomly generated $a$ and $b$.