Inverting a Filter
Message-ID:
Subject:
Inverting a Filter.
Date:Mon, 13 Oct 2008 16:22:12 +0100
Hello Probably a very simple question but it has me a little confused at the moment. If I convolve an Image A with a small NxN filter F to give image B then does there exist a inverse filter F' such that F' convolved with B gives A? If so then what is the size of F' and how can F' be found if only A and B are known? Thanks for any help. Jeff
Message-ID:<96bf6$48f39e25$23413@news.teranews.com>
Subject:
Re: Inverting a Filter.
Date:Mon, 13 Oct 2008 20:14:44 +0100
4N wrote: > "Jeff"ha scritto nel messaggio > news:EIJIk.236$dN6.127@newsfe18.ams2... >> Hello >> >> Probably a very simple question but it has me a little confused at the >> moment. >> >> If I convolve an Image A with a small NxN filter F to give image B then >> does there exist a inverse filter F' such that F' convolved with B gives >> A? >> If so then what is the size of F' and how can F' be found if only A and B >> are known? In general no. Although some important special cases have solutions. You probably want to look for descriptions of "Blind deconvolution" to see how it is done in practice. It is rare to know both the target image and the blurred image. In general it is a nasty illposed problem with an answer that is not necesarily unique. > > To explain it the simple way you should use FFTs. > In the frequency domain the convolution is done by multiplying every pixel > of the transformed filter mask (F) by the corresponding pixel in the > transformed image A (both image FFT(F) and FFT(A) have the same dimensions), > so to invert the effect (deconvolution) you divide the transformed result > FFT(B) by the transformed filter F... There is the very nasty possiblity that FFT(F) contains very small values or worse still zeroes which makes its inverse ill defined and numerically ill conditioned. The net result in practice is that high frequency noise is hugely amplified. You can add any amount of the components with zero amplitude in the blurring function and still get the same final image. Some kind of regularisation rule is typically used to resolve these problems. Simple 1-D example with 2 point box kernal {1,1} you can add an arbitrary amount of the alternating component 1 -1 1 -1 ... to the source image and it will cancel out when you convolve it. You can always compute the transpose of F, as Ft and then compute Ft.F. The range of eigenvalues of that matrix determines how much information is preserved in a round trip. Ideally you would like them all to be the same value and for some transforms it is the case. Regards, Martin Brown ** Posted from http://www.teranews.com **
Message-ID:
Subject:
Re: Inverting a Filter.
Date:Mon, 13 Oct 2008 22:19:21 +0100
"Martin Brown" <|||newspam|||@nezumi.demon.co.uk> wrote in message news:96bf6$48f39e25$23413@news.teranews.com... > 4N wrote: >> "Jeff"ha scritto nel messaggio >> news:EIJIk.236$dN6.127@newsfe18.ams2... >>> Hello >>> >>> Probably a very simple question but it has me a little confused at the >>> moment. >>> >>> If I convolve an Image A with a small NxN filter F to give image B then >>> does there exist a inverse filter F' such that F' convolved with B gives >>> A? >>> If so then what is the size of F' and how can F' be found if only A and >>> B are known? > > In general no. Although some important special cases have solutions. You > probably want to look for descriptions of "Blind deconvolution" to see how > it is done in practice. It is rare to know both the target image and the > blurred image. In general it is a nasty illposed problem with an answer > that is not necesarily unique. Thanks. So if I understand you correctly, there will exist combinations of A, A' and F for which no inverse exists? What if A is a large image with lots of well defined detail - some sort of test-card for example. Would it still be possible for a Filter F (whose dimensions are << A ) to exist which could not be determined if A and A' were known? If so, then what would an example of some a filter look like >> >> To explain it the simple way you should use FFTs. >> In the frequency domain the convolution is done by multiplying every >> pixel of the transformed filter mask (F) by the corresponding pixel in >> the transformed image A (both image FFT(F) and FFT(A) have the same >> dimensions), so to invert the effect (deconvolution) you divide the >> transformed result FFT(B) by the transformed filter F... > > There is the very nasty possiblity that FFT(F) contains very small values > or worse still zeroes which makes its inverse ill defined and numerically > ill conditioned. The net result in practice is that high frequency noise > is hugely amplified. You can add any amount of the components with zero > amplitude in the blurring function and still get the same final image. > Some kind of regularisation rule is typically used to resolve these > problems. Ok, I see what you mean, I can see how noise and/or discretisation errors could make the problem ill conditioned. But if A is very rich in detail and A >> F then would this still be the case? Thanks a lot Jeff
Message-ID:
Subject:
Re: Inverting a Filter.
Date:Tue, 14 Oct 2008 09:52:26 +0100
Jeff wrote: > "Martin Brown" <|||newspam|||@nezumi.demon.co.uk> wrote in message > news:96bf6$48f39e25$23413@news.teranews.com... >> 4N wrote: >>> "Jeff"ha scritto nel messaggio >>> news:EIJIk.236$dN6.127@newsfe18.ams2... >>>> Hello >>>> >>>> Probably a very simple question but it has me a little confused at the >>>> moment. >>>> >>>> If I convolve an Image A with a small NxN filter F to give image B then >>>> does there exist a inverse filter F' such that F' convolved with B gives >>>> A? >>>> If so then what is the size of F' and how can F' be found if only A and >>>> B are known? >> In general no. Although some important special cases have solutions. You >> probably want to look for descriptions of "Blind deconvolution" to see how >> it is done in practice. It is rare to know both the target image and the >> blurred image. In general it is a nasty illposed problem with an answer >> that is not necesarily unique. > > Thanks. > > So if I understand you correctly, there will exist combinations of A, A' and > F for which no inverse exists? Yes. The rare cases are when a decent inverse filter does exist. > What if A is a large image with lots of well defined detail - some sort of > test-card for example. > Would it still be possible for a Filter F (whose dimensions are << A ) to > exist which could not be determined if A and A' were known? > If so, then what would an example of some a filter look like A matrix with every row and column multually orthogonal ought to do it. You can probably get a decent estimate of F = IFT( FT(A')/((FT(A)+eps)) Provided that FT(A) contains no small values. Look up Weiner filters and constrained least squares eps(u^4+v^4) is a popular old kludge. > > could make the problem ill conditioned. But if A is very rich in detail and > A >> F then would this still be the case? You are still in trouble if F has a FT that contains any zeroes (or small values). Without some kind of regularisation you are sunk. Positivity of the image or psf, minimum delsq, maximum entropy and a host of other functions have been used to make the solution unique. Regards, Martin Brown ** Posted from http://www.teranews.com **
Message-ID:
Subject:
Re: Inverting a Filter.
Date:Tue, 14 Oct 2008 16:19:34 +0100
Hi Jeff, This is more of an empirical, as opposed to theoretical, answer to your question. SeDDaRA is a blind deconvolution technique that uses a reference image, having similar spatial frequency content as the scene, to extract a blur function (PSF) from a blurred image. Using a pseudo-inverse filter (approximation of a Wiener filter), the image is then deconvolved. The closer the reference image is to the scene, the better the estimate of the PSF. In your case, you possess an ideal reference image, and would like to get the PSF. Here's how to proceed: 1) Download and Install Tria from http://www.quarktet.com/Tria.html. Its free to try and inexpensive compared to other blind decon programs. You should spend some time using the walk-throughs in the help file to better understand the process. 2) Create a reference image using your non-blurred image. 3) Run the SeDDaRA function on your blurred image, choosing your reference image, and selecting the 'Show PSF' option. After about a minute with a 1k by 1k image size, both the PSF and a processed image will pop up. Given noise and digital truncation, this will produce the best estimate of your blur function. Best Regards, Jim C
Message-ID:
Subject:
Re: Inverting a Filter.
Date:Mon, 13 Oct 2008 22:12:50 +0100
"4N"wrote in message news:48f381c6$0$40314$4fafbaef@reader5.news.tin.it... > > "Jeff" ha scritto nel messaggio > news:EIJIk.236$dN6.127@newsfe18.ams2... >> Hello >> >> Probably a very simple question but it has me a little confused at the >> moment. >> >> If I convolve an Image A with a small NxN filter F to give image B then >> does there exist a inverse filter F' such that F' convolved with B gives >> A? >> If so then what is the size of F' and how can F' be found if only A and B >> are known? > > To explain it the simple way you should use FFTs. > In the frequency domain the convolution is done by multiplying every pixel > of the transformed filter mask (F) by the corresponding pixel in the > transformed image A (both image FFT(F) and FFT(A) have the same > dimensions), so to invert the effect (deconvolution) you divide the > transformed result FFT(B) by the transformed filter F... Thanks for that. Yes, I'm familiar with the duality that exists between the spatial and frequency domains. But suppose we have two 1024x1024 images which we know are related by some small filter which we seek to find. Solving the problem in the frequency domain would appear to involve an FFT on two largish images and then a very large matrix inversion followed by an equally large inverse FFT. Is this really the most efficient way to proceed? But what's really confusing me is the potential size of the inverse filter. I naively assume that the inverse filter would have the same size as the forward filter - but is this necessarily the case? Thanks again Jeff
Message-ID:<48f3d3fc$0$18147$4fafbaef@reader3.news.tin.it>
Subject:
Re: Inverting a Filter.
Date:Tue, 14 Oct 2008 00:05:09 +0100
> But suppose we have two 1024x1024 images which we know are related by some > small filter which we seek to find. Solving the problem in the frequency > domain would appear to involve an FFT on two largish images and then a > very large matrix inversion followed by an equally large inverse FFT. Is > this really the most efficient way to proceed? Frequency domain is preferred over spatial domain when the filter mask for the convolution is large, in this case I explained the problem in the frequency domain because it's easier to explain, in fact it took only a couple of lines for that. > But what's really confusing me is the potential size of the inverse > filter. I naively assume that the inverse filter would have the same size > as the forward filter - but is this necessarily the case? Maybe I didn't get your question, anyway the transformed filter mask that you use for deconvolution is exactly the same you use for convolution. I mean if you multiply a value v by another f you have to divide by f to obtain again v... Anyway mr. Brown already explained that this problem is ill posed and you must know the exact filter that tranformed the original image to proceed like explained. Blind deconvolution is being studied but till now only certain types of filters can be inverted, and anyway there're just but a handful of articles on this subject.
Message-ID:<92587370-9152-42fd-96df-6e7a5eedf671@u29g2000pro.googlegroups.com>
Subject:
Re: Inverting a Filter.
Date:Tue, 14 Oct 2008 18:33:02 +0100
On Oct 13, 9:22=A0am, "Jeff"wrote: > Hello > > Probably a very simple question but it has me a little confused at the > moment. > > If I convolve an Image A with a small NxN filter F to give image B then d= oes > there exist a inverse filter F' such that F' convolved with B gives A? No, not generally. Deconvolution is an approximation process and rarely is it attempted by convolution with some spatially invariant kernel. Consider the simple 1D case of convolution with [ 1 1 ] in matrix form: y =3D A x A =3D 1 1 0 0 0 1 1 0 0 0 1 1 A is a 3x4 matrix so it is underdetermined and has no inverse. There are an infinite number of x that satisfy that equation. However, one might select a solution, x', such that xTx is minimum, x' =3D AT (A AT)^-1 y Observe, A x' =3D A AT (A AT)^-1 y =3D y However, this particular kind of solution does not lead to natural looking images and is not recommended.
Message-ID:
Subject:
Re: Inverting a Filter.
Date:Tue, 14 Oct 2008 21:10:03 +0100
aruzinsky wrote: > On Oct 13, 9:22 am, "Jeff"wrote: >> Hello >> >> Probably a very simple question but it has me a little confused at the >> moment. >> >> If I convolve an Image A with a small NxN filter F to give image B then does >> there exist a inverse filter F' such that F' convolved with B gives A? > > No, not generally. Deconvolution is an approximation process and > rarely is it attempted by convolution with some spatially invariant > kernel. > > Consider the simple 1D case of convolution with [ 1 1 ] in matrix > form: > > y = A x > > A = > > 1 1 0 0 > 0 1 1 0 > 0 0 1 1 > > A is a 3x4 matrix so it is underdetermined and has no inverse. There > are an infinite number of x that satisfy that equation. However, one > might select a solution, x', such that xTx is minimum, > > x' = AT (A AT)^-1 y > > Observe, > > A x' = A AT (A AT)^-1 y = y > > However, this particular kind of solution does not lead to natural > looking images and is not recommended. You are between a rock and a hard place for regularising functions that create natural looking images. The best you can hope for in the absence of any other prior information is not to create unjustified correlations in the reconstructed image. AFAIK Maximum entropy f.log(f) is as good a choice as any. There is a cute Kangaroo problem posed by Steve Gull to illustrate the effects of various choices of regularising functions in a very simple underdetermined test case where human intuition can see the answer. You are given just two pieces of data and need to create a 2x2 contingency table for a bet on the proportion of blue eyed, left handed kangaroos in Australia. The observational data is: a. 1/3 of kangaroos have blue eyes b. 1/3 of kangaroos are left handed Common sense says that since you have no other evidence you would like to choose a reconstruction that gives an answer of 1/9 for blue eyed left handers. Sum p log(p) passes this test nicely. The most extreme positive correlation answer is 1/3 and the most extreme negative correlation answer is 0 And the general case is L R Blue x 1/3-x Other 1/3-x 1/3+x Other popular choices are p.p which gives 1/12 (negative correlation) And other barrier functions that also encourage positivity like log p which gives 0.130 (positive correlation) sqrt(p) which gives 0.122 (positive correlation) Ultimately you pays your money and takes your choice. Regards, Martin Brown ** Posted from http://www.teranews.com **
Message-ID:
Subject:
Re: Inverting a Filter.
Date:Wed, 15 Oct 2008 17:43:31 +0100
On Oct 14, 2:10=A0pm, Martin Brown <|||newspam...@nezumi.demon.co.uk> wrote: > ... > The best you can hope for in the absence > of any other prior information is not to create unjustified correlations > in the reconstructed image. > ... Typically, there is prior information. The distribution of derivatives, or gradient magnitudes, for a wide range of natural images follows ~ exp( -| x/s |^p ) with 0



RSS News Feed