Re: A "slanted edge" analysis program



Bart van der Wolf wrote:

"Lorenzo J. Lucchini" <ljlbox@xxxxxxxxxx> wrote in message news:Gay_e.1611$133.572@xxxxxxxxxxxxxxxxxxxxxxxx
SNIP


[snip]

So in your opinion it's ok if I just consider an arbitrary number of pixels (like Imatest does) as constituting "the edge", without going to great length trying to have the program make an educated guess?

Yes, although flatbed scanners exhibit a significantly wider ESF with long tails. Don't be too conservative. The range used by Imatest is from -6 to +10 in quarter pixel increments, and thus allows to handle at least a symmetrical PSF with a support of 13 pixels, which would be for a *very* blurry image.

Well, I will use -10 .. +10 for now, if it doesn't get too slow (but using the "4x bins" thing it should all go much faster, I think).
That should allow plenty of room.


SNIP

You'll have to window because of the abrupt edges. That's reality in Fourier transforms, we deal with a small subset of the real data which reaches out to infinity.


Yes, but there are two other options I've considered:

1) taking *many* DFTs of small (Hanning-windowed) pieces of the LSF, and then average them together. Wouldn't this avoid the change of LSF shape that using a single, big window may cause?


Although possible, it's probably more efficient to code the binning/averaging many single row LSFs, thus approaching the real LSF. It's the real LSF that needs to be 'DFT'ed. IMO it's not so useful to perform many DFTs on such a small (e.g. 64 quarter pixels if ranging from ) array, it becomes less efficient and I think complex. Some calculations are easier/faster in the frequency domain (e.g. deconvolution) and others in the spatial domain (averaging and small kernel convolution). The windowing has only to be done once on the multiple LSF average (which already has lower noise than single samples).

No, sorry, I didn't mean to take the DFTs of all single-row LSFs.

What I meant is:
- assume you have a (final) LSF that is 128 values long
- you take the windowed DFT of the first 16 values
- then you take the DFT of values from 8 to 24
- then from 16 to 32
- etc
- then you average all these together

I've not just invented this strange thing, I've read it somewhere, though not in a graphics context, and I might have misinterpreted it.

2) not using any window, but "cropping" the LSF so that the edges are (very near) zero. Would this have any chances of working? It would completely avoid changing the LSF's shape.

Truncation loses information, I don't think that's helpful. Windowing will further reduce the already low response and it suppresses noise at the boundaries. That's helpful.

I see. Well, at least I guess that taking a "longer" LSF (i.e. considering more pixels "part of the edge") could help reduce any artifacts caused by the windowing, since most of the "important" data is in a small part of the whole LSF.


Also, do you think a Hanning window is a reasonable choice for my purposes, or should I choose a different window type?

SNIP

Yes, I do this.
MTF[i]=SquareRoot(ImaginaryPart[i]^2+RealPart[i]^2)

Depending on the library implementation, for complex numbers , Abs[z] gives the modulus |z| .

No, there isn't such a function in FFTW. However, there are functions to directly obtain a real-to-real FFT; I probably should look at them, although I'm not sure if the real data they output are the moduli or simply the real parts of the transform's output.


Also note http://www.library.cornell.edu/nr/bookcpdf/c5-4.pdf (5.4.3) which is a more robust way of doing it in extreme cases (which may never occur, but it's still more robust).

Site down at the moment :-) I'm starting to worry that it may somehow be me...


> [snip]
>
In the Netherlands we have a saying, "there are several roads, all leading to Rome" ;-)

Tutte le strade portano a Roma (all roads bring to Rome), clearly we have that too, and in our case, it's actually true ;-) at least for those roads that were originally built in ancient Roman times.


[snip]

Let us see if I've understood this.

[...]

I think I have an even better suggestion. I have some C code examples from the ISO that shows how it could be implemented. If I can email the 48KB Word document (is your ljlbox@xxxxxxxxxx in the signature valid?), it'll become quite clear, I'm sure.

It's valid, yes.
Only, how copyrighted is that stuff, and what's the legal state of those documents? ISO might get upset with both of us, if somehow I wasn't supposed to read or use their papers (ok, ok, in the real world they won't even notice we exist I suppose).


I also have a 130KB PDF file you'll love to read because it describes the various steps and considerations in more detail.

Sure, if the main concepts can be understood without going too deeply technical, it'll be most welcome.


One more remark. I've been having some discussions with Fernando Carello (also from Italy) about PSFs and types of restoration. He was willing (if time permits) to attempt to tackle that side of the challenge.

I've read through some of the threads you've had with him.

Although I understand that it's always a bit difficult to fathom a mix of programming styles, it could potentially help (again, if his time allows).

Sure! And if we work on separate aspects of the issue, the problem of mixed programming styles is easily solved by having separate sources/libraries communicate through an interface, you know, like I've heard real programmers (rarely) do ;-)


Hm, I see a problem though... these PSF MTF ESF DFT regression curve fitting etc thingies, I don't know how to call most of them in Italian :-D


by LjL ljlbox@xxxxxxxxxx .



Relevant Pages

  • Re: A "slanted edge" analysis program
    ... Now I can compile for Windows without using a custom DFT, since there is FFTW in Cygwin, but I'll probably still include a custom transform procedure in case someone wants to compile without FFTW installed. ... it always seem to go from -6 pixels to +8 pixels from the edge center. ... taking *many* DFTs of small pieces of the LSF, ... depends on how high you want your frequencies to be -- i.e., if I want to show the MTF up to 4xNyquist, I should have 4x more samples than there are real pixels. ...
    (comp.periphs.scanners)
  • Re: newbie questions on OpenGL and C#. I am using NeHe example code
    ... > and 2) you can have the window covered by another window ... This implies that read pixels is not ... to put a red square down on the drawing surface. ... >> graphics card then you're rendering in software. ...
    (comp.graphics.api.opengl)
  • Re: Filtering kernel width
    ... , how wide should the window be, ... function leaves a realizable filter of finite size: ... becomes when it is convoluted with the function as more pixels ... Well I didn't see a problem with performing the convolution, ...
    (comp.graphics.algorithms)
  • Re: Filtering kernel width
    ... , how wide should the window be, ... function leaves a realizable filter of finite size: ... becomes when it is convoluted with the function as more pixels ... Well I didn't see a problem with performing the convolution, ...
    (comp.graphics.algorithms)
  • Re: A "slanted edge" analysis program
    ... The range used by Imatest is from -6 to +10 in quarter pixel increments, and thus allows to handle at least a symmetrical PSF with a support of 13 pixels, which would be ... Wouldn't this avoid the change of LSF shape that using a single, ... The windowing has only to be done once on the multiple LSF average (which already has lower noise than single samples). ... larger numbers of ESFs make a more likely approximation of the actual ESF. ...
    (comp.periphs.scanners)