Journey into the Zone (Plates)

I have exper­i­ment­ed recent­ly with zone plates, which are the 2‑D equiv­a­lent of a chirp. Zone plates make for excel­lent test images to detect defi­cien­cies in image pro­cess­ing algo­rithms or dis­play and cam­era cal­i­bra­tion. They have inter­est­ing prop­er­ties: Each point on a zone plate cor­re­sponds to a unique instan­ta­neous wave vec­tor, and also like a gauss­ian a zone plate is its own Fouri­er trans­form. A quick image search (google, bing) turns up many results, but I found all of them more or less unus­able, so I made my own.

Zone Plates Done Right

I made the fol­low­ing two 256×256 zone plates, which I am releas­ing into the pub­lic so they can be used by any­one freely.

Cosine zone plate with constrast weighting

Cosine zone plateCC0

Zone plates with contrast weighting

Sine zone plateCC0

On both images, I shift­ed the ori­gin of the wave func­tion to the low­er left cor­ner so that the high fre­quen­cies, where usu­al­ly the action is, appear in the cen­ter. The pix­el val­ues were cal­cu­lat­ed as

    \[I = 255 \left( { a y + 1 \over 2} \right) ^ {{}^1/_{\gamma}},\]

where I is the pix­el val­ue, y is the wave func­tion, a is a con­trast weight­ing func­tion and gamma is the dis­play gam­ma expo­nent. The con­trast weight­ing func­tion is intend­ed to cor­rect for the effect of box shaped pix­els (more about that below). The gam­ma expo­nent cor­rects for the non-lin­ear sRGB trans­fer curve, and is cho­sen so that 50% grey cor­re­sponds to a pix­el val­ue of 187.

It is pos­si­ble that your brows­er mess­es with these images and your don’t get to see them as they were intend­ed. You can right click on these images and select “Save image to Downloads...” to get the ver­ba­tim ver­sion. To give you an impres­sion how it should look like, here is a pho­to tak­en from my Mac with the cosine zone plate opened in the Pre­view appli­ca­tion, at 2× zoom (on a reti­na dis­play, the effec­tive zoom fac­tor was 4). The aver­age grey val­ue of the entire zone plate should be uni­form, with­out any Moiré pat­terns, and all rings should appear to have the same con­trast between them:

IMG_1214The Wave Function

The wave func­tion y is one of

    \begin{align*} y &= \cos \pi R ( u^2 + v^2 ) & \text{or} & & y &= \sin \pi R ( u^2 + v^2 ), \end{align*}

depend­ing on whether the cosine or the sine ver­sion is desired. The image coor­di­nates u and v are assumed to be in the range 0…1 with the ori­gin in the low­er left cor­ner. The res­o­lu­tion para­me­ter R is equal to the image dimen­sion in pix­els (which is 256 here).

The Apparent Wave Vector

The instan­ta­neous wave vec­tor \vec{k} can be found by ana­lyz­ing how fast the argu­ment to the cosine or sine func­tion changes per pix­el when either u or v changes. It becomes

    \[\vec{k} = \begin{pmatrix} k_u \\ k_v \end{pmatrix} = \pi \frac{R}{R} \begin{pmatrix}\tfrac{\partial}{\partial u} \\ \tfrac{\partial}{\partial v} \end{pmatrix} ( u^2 + v^2 ) = 2 \pi \begin{pmatrix} u \\ v \end{pmatrix} ,\]

where the ele­ments k_u and k_v are the spa­tial fre­quen­cies along u and v direc­tion, in radi­ans per pix­el. Each com­po­nent hits the Nyquist lim­it when it reach­es \pi radi­ans per pix­el (equal to a wave­length of 2 pix­els), which hap­pens halfway along each coor­di­nate. Beyond this lim­it the fre­quen­cy folds back giv­ing a mir­ror copy. The appar­ent wave vec­tor \vec{k}' that takes into account this fre­quen­cy fold­ing is

    \[\vec{k}' = 2 \pi \begin{pmatrix} \min u, 1 - u \\ \min v, 1 - v \end{pmatrix} .\]

The Contrast Weighting Function

Now I’m going to explain the con­trast weight­ing func­tion a, which is

    \[a = \frac{4}{ \pi^2 \, \operatorname{sinc} \frac{k'_u}{2} \, \operatorname{sinc} \frac{k'_v}{2} } .\]

where \operatorname{sinc} \, x = {\sin x \over x} is the unnor­mal­ized car­di­nal sine func­tion. This is the inverse trans­fer func­tion of a 1 by 1 pix­el wide box fil­ter, nor­mal­ized to uni­ty. To under­stand why this addi­tion­al func­tion is employed, I’m going to dis­cuss an ide­al­ized math­e­mat­i­cal mod­el of a com­put­er display.


A com­put­er screen with per­fect­ly “box shaped” pix­els can be mod­eled math­e­mat­i­cal­ly as sequence of two trans­for­ma­tions, as shown in the fig­ure above. On the left is the orig­i­nal con­tin­u­ous sig­nal, as it is com­put­ed by our wave func­tion. In a first step this sig­nal is thought to be ring mod­u­lat­ed with an “impulse lat­tice” to give the sig­nal in the mid­dle. This step is non-lin­ear and is respon­si­ble for all the sam­pling arti­facts, because it cre­ates side bands. Final­ly, in a sec­ond step, the sig­nal is con­volved with a box fil­ter to arrive at the pixel­lat­ed end result on the right.

It is this box fil­ter con­vo­lu­tion of the last step that the weight­ing func­tion a seeks to neu­tral­ize. With­out this cor­rec­tion, the pixel­lat­ed sig­nal would under­rep­re­sent the con­trast of high­er spa­tial fre­quen­cies. You can ver­i­fy this effect for your­self by eye­balling the above fig­ure from a dis­tance or look­ing at a the fil­tered ver­sion below.


Conclusion: Should we do blur-correction like we do gamma-correction?

The the­o­ry behind the “con­trast weight­ing func­tion” sug­gests that this loss of con­trast applies to all syn­thet­i­cal­ly gen­er­at­ed images. It would there­fore be the­o­ret­i­cal­ly jus­ti­fied to employ some kind of sharp­en­ing post fil­ter in a 3‑D engine togeth­er with a cor­re­spond­ing blur­ring of the source tex­tures, on sim­i­lar grounds as gam­ma cor­rec­tion: the tex­ture artist work­ing by visu­al feed­back on a com­put­er screen is like­ly to over­sharp­en the tex­ture because the com­put­er mon­i­tor does not faith­ful­ly repro­duce the light field that should cor­re­spond to the tex­ture 2‑D signal.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Please answer the following anti-spam test

Which thing makes "tick-tock" and if it falls down, the clock is broken?

  1.    table
  2.    watch
  3.    ruler
  4.    chair
  5.    pencil