4

What is the 2D kernel, k, that when convoluted with a 2D signal, f, that is convoluted again with a gaussian 2D kernel, g, produces a result that is closest to the original signal, f'. Something like this, I think:

For

f' = f $\star$ k $\star$ g (where $\star$ denotes convolution)

Find k, such that |f - f'| is minimal.

1 Answers1

2

For concreteness, let us define the Gaussian kernel $g$ as $$g(x,y) = \frac{1}{2\pi \sigma_x \sigma_y} \exp\left[-\frac{x^2}{2 \sigma_x^2}- \frac{y^2}{2\sigma_y^2}\right].$$ Its Fourier transform is again a Gaussian $$\hat g(k_x,k_y) = \int\!dx\, dy\, e^{i kx x + i ky y}\, k(x,y)= \exp\left[-\frac{\sigma_x^2 k_x^2}{2}- \frac{\sigma_y^2 k_y^2}{2}\right]$$ is again a Gaussian.

Under Fourier transform the convolution becomes a product, i.e., $\widehat{k\star g} = \hat{k} \times \hat{g}$. The difference is given by $$\begin{align}\int\!dx\,dy\,|f(x,y)-f'(x,y)|^2 &=\int\frac{dk_x}{2\pi}\frac{dk_y}{2\pi}\,|\hat{f}(k_x,k_y)-\hat{f'}(k_x,k_y)|^2\\ &=\int\frac{dk_x}{2\pi}\frac{dk_y}{2\pi}\,|\hat{f}|^2|1-\hat{k} \hat{g}|^2 \end{align}.$$ In order to minimize the difference, $\hat{k} \hat{g}$ should be as close as possible to 1 (and of course $k$ still normalized).

Therefore, we have to minimize $$\int\frac{dk_x}{2\pi}\frac{dk_y}{2\pi}\,[|1-\hat{k} \hat{g}|^2+\lambda|\hat{k}|^2],$$ where $\lambda$ is a Lagrange multiplier to keep the norm of $\hat k$ at 1. We can variate this equation, and obtain $$\int\frac{dk_x}{2\pi}\frac{dk_y}{2\pi}\,[2 \hat{g}(1- \hat{k} \hat{g})+2 \lambda\hat{k}] \delta \hat k,$$ with the solution $$\hat{k} = \frac{\hat{g}}{\hat{g}^2+\lambda}= \frac{\exp\left[-\frac{\sigma_x^2 k_x^2}{2}- \frac{\sigma_y^2 k_y^2}{2}\right]}{\exp\left[-\sigma_x^2 k_x^2- \sigma_y^2 k_y^2\right]+\lambda}.$$ $\lambda$ is determined from the normalization condition.

Fabian
  • 23,360
  • 1
    You're assuming $k$ is Gaussian, which was not specified in the question. –  Mar 11 '11 at 05:21
  • Ok, my bad. I managed to read the question wrong. – Fabian Mar 11 '11 at 06:40
  • I will fix this. – Fabian Mar 11 '11 at 06:57
  • I understand neither the answer by @Fabian, nor the comment by @Rahul Narain :-) About the comment: There's no assumption here that $k$ is Gaussian; in fact it isn't, it has one Gaussian in the numerator and one in the denominator. And about the answer: It's interesting, but I also think it's wrong. How does normalization get into it? The original transform wasn't normalized, nor is it clear to me why it would make sense to normalize either of the transforms. I would have thought that both transforms should take the value $1$ at $k=0$ so as not to change the overall signal level. – joriki Mar 11 '11 at 07:18
  • I agree that the answer depends on what conditions you impose on $k$ (if you impose no conditions then $1/\hat{g}$ is a solution but it cannot be even Fourier transformed ;-)). I imposed the condition that $k$ is normalized simply because typically these devices which convolute keep the energy constant (the $L^2$ norm) and not the overall signal. But maybe the OP can help? – Fabian Mar 11 '11 at 08:45
  • @joriki: two small comments. 1) regarding Rahul Narain's comment -- I already changed my answer. 2) the answer is essentially $1/\hat{g}$ but cut off by $\lambda$ when $1/\hat{g}$ becomes large thus making it normalizable. – Fabian Mar 11 '11 at 08:48
  • @Fabian: You can't keep the energy constant by normalizing $k$. The only transforms that keep the energy of arbitrary signals constant are ones that have magnitude $1$ for all $k$. For instance, if you're blurring images and you have rapidly alternating white and black lines, these will get blurred, and the high-frequency energy will be drastically reduced (which is the whole idea :-). If you have a slowly varying image, you want it to remain essentially unchanged, which is why the transform should be $1$ at $k=0$. (I'm not saying that's a solution for the inversion; you're right, it isn't.) – joriki Mar 11 '11 at 09:02
  • I think we are talking about something different. Imagine you have an electrical circuit. At some device you send in the current $I(t)$ [$f$ in the original post]. The output will be some convolution of the incoming current and some kernel [$g$ in the original post] which depends on the electrical circuit. The energy is essentially given by $\int dt I^2(t)$. – Fabian Mar 11 '11 at 09:25
  • Woosh! I am way out of my league here. With my mostly forgotten math education I think I followed the neat derivation till before $$\int\frac{dk_x}{2\pi}\frac{dk_y}{2\pi},[|1-\hat{k} \hat{g}|^2+\lambda|\hat{k}|^2]$$ Then I got lost. The basic thought I originally had was if I can pre-process an image I know is going to be blurred and help the end result be a little bit closer to the original. I think my question reflects that idea correctly but I could be wrong. In any case, wow and thank you! I don't think I can provide much more meaningful insight... –  Mar 11 '11 at 16:34