Tutorial #8
Working
with the screen buffer
& working with complex array
Before diving into this tutorial you should spend some time drawing upon the screen, doing a Fourier transform of the drawing and then looking closely at the relation between the numbers in the upper left of the document window. They change as you move the cursor around the window. The location of the pixel and the values contained in the real and imaginary parts are displayed. The magnitude and phase are calculated from these values and presented. Next to these numbers in the "view options" box is displayed the "gray value". This number (stored in the screen buffer) is the number calculated to display the contents of the screen at that pixel. The range of values is usually scaled to best show the contents. The numbers translate directly into grey values on the screen and (if colorize has not been selected) 0 being white & 255 being black (or the other way around it invert color is chosen)
This scaling can be controlled or defeated by the two check boxes you see on the drawer. If you click the "Show 0 to 255 only" check box the presentation will probably look very strange unless the values in the big array happen to span a large part of the values 0 to 255. The contents of the displayed part of the array are converted to integer and the bottom 8 bits used for gray display. The results can be very strange. So positive values are capped at 255, negative values are gone. Values near zero are hard to see.
The screen buffer (using the Light Valve Compensation button & Icon)
Light valves have in general non-linear response characteristics. Since the content of the big array has already been interpreted onto the screen buffer as number values ranging from 0 to 255 (best seen by not using "colorize" or "black & white") one needs only to map these 255 values to a new set of values. One way of dealing with this problem is to make a table characterizing the light valve, which consists of a mapping from the calculated gray level to the new gray level that gives the desired result.
Let us assume that you have such a table, and wish to apply it to the output of your light valve. The usual situation is to have an external monitor and light valve both connected to the video output of a Mac (using a splitter) and set up in a non-mirroring configuration.
You are then able to see what is being displayed on the light valve. The "BIG Window." on the "Goodies" menu is designed to be placed on such a screen and can be sized and dragged into place on the external monitor. The "Big Window" mirrors the content of the main document window.
In the main window create a default lens by selecting the "zonal lens" button and clicking "OK".
If you select "phase angle" in the view options the display will look much like the above. We wish however to adjust the gray levels with a table of values found in the Tutorial files. Click on the "Filter" button at the top and load the file "grayFix.csv" the result should now look much like below. Note that the file contains just a single column of 256 integers. Each entry between 0 and 255.
Hide the filter window and click again on the filter button. The screen changes to reflect the filtering action immediately. The state is fragile since clicking on the view options will revert to the previous state. If this happens just click "Filter" again. Note that clicking twice produces undesirable results. Click again on display mode and then click "Filter."
I suggest that you play with various window settings like viewing the real part, imaginary part, and magnitude and then applying the Filter. You will notice among other things that the change in the histogram does not reflect any change in the big array. This is inconsistent with the histograms usual purpose, and I apologize, but it does make it easier to see that something has happened.
When you use
the equivalent icon from the scripting menu you will see that it does not change
the histogram. I assume that the user has faith that the action will take place.
(Check anyway.) When you use this in a script make sure that the preceding icon
in the execution is a display icon.
For example. This script will
give the same results. (display phase)
Another Way
If you are running a large script with many instances of the Display Icon you
may not want the light valve window flashing with each change of the main window
(which the Big Window menu selected window is mirroring). The
Display Icon is capable of displaying
a separate window which is very much like the Big Window display
but only displayed when the icon is executed. To make this display make use
of the filder you should connect the filter to the Display Icon
by means of a red data flow line. For example .
The complex array (changing the big array & forcing gray level compliance)
The scripting
window has an icon which, when loaded with a file consisting of two
columns of data with more than 4 rows, will act upon either the real
or imaginary part of the big array by replacing the value found in the big array
finding its placement in the first column of data replacing it with the value
found in the second column. The interpolation is done by fitting a cubic polynomial
to the 4 points in the columns surrounding the interpolation point. It acts
upon the entire array.
The script at right will
do the same with the following settings.
The third icon has placed the phase angles into the real part (radians) so the rescale icon multiplies by 128/Pi and then adds 128 so the real part now contains numbers from 0 to 255 the "Look up Fn" icon will apply the file "grayFnFix2Cal.CSV" which has two columns. (Look at it in a spread sheet.) The display icon shows the real part. The result does not look right unless you also set the "show 0 to 255 only" button on the drawer. The whole manipulation is designed to put the range of numbers from 0 to 255 in the real part of the big array. The function acts upon this to return values in the same range but adjusted for the characteristics of the light valve. The values are in the real part which is usually displayed with 0 in the big array mapping into gray level 127. The "show 0 to 255 only" button overrides this.
This is clearly much more complicated, but useful at times. The rescale icon can be eliminated by causing the first column of the function definition to range from -pi to pi while the second goes from 0 to 255.