Page History: Random Noise Patch Element
Compare Page Revisions
Page Revision: 2011/07/21 09:15
|
New Element
|
Info |
Category: |
Realtime stimuli generators |
|
AddIn: |
Base Elements |
Creator: |
OkazoLab Team |
|
Scope: |
Parent Event |
Owns Snippets: |
no |
|
Usage: |
Runtime Screen,Snippets |
Random dots element is capable of generation of 2D pixel surface where every pixel has a random luminance, color value or a combination of both.
Description
The element employs the graphics hardware and an ultra-fast randomization algorithm. It allows generation of the screen size surface in a fraction of second – it takes less than 100ms on the standard PC to generate a 1024x768 full-screen surface and render it on the screen. The element is proposed for real-time stimuli generation in experiments with high-speed demands, however, it also can be used for the deterministic stimulus generation, where each generated surface is determined by two integer indexes. Given these indexes, an exact copy of the surface can be recreated at any moment, if required.
In order to use this element the VisialKernels AddIns has to be loaded in EventIDE.
Snapshots
The examples of rendered element with three available random dots types (the insets show zoomed patterns):
Random luminance surface | Snapshot 2 |
Practical Use
Generation of random dots surfaces via the graphics hardware implies certain limitations on type of a randomization algorithm. Our algorithm requires a relatively slow initialization where the random seed map is created by a standard random number generator. Later this seed map is used for generation of new random surfaces by ultra-fast shuffling of the original pixel positions.
There are two major ways of using the element for generation of multiple random dots surfaces (e.g., one per trial). Every surface generated by the element is defined by the index of the seed map and index of the surface itself. You may choose how to control these indexes in experiment.
If you need to present an incidental random dots surface (for example, for introducing a random noise to stimuli), you can setup the automatic time-dependent indexes. For this purpose, set two index properties [Seed map] and [Surface] to zero. Then the element will automatically generate the seed map and random dot surface with indexes that are random themselves. If you want to log these indexes, anytime you can read them in the statistical properties [Current Map] and [Current Surface]. In order to generate a new incidental surface at runtime you should initiate one of runtime actions in your code snippets: [Update Seed Map] or [Update Surface]. The runtime action is initiated by assigning TRUE to the property in a snippet.
If you need to present a deterministic random dots surface then you have to set the indexes manually, at design-time or in code snippets at runtime. You can do by assigning a certain positive integer value to the [Seed map index] or [Surface Index] properties which causes immediate regeneration of the surface. Thus, for the "deterministic" scenario you don't need to initiate the runtime actions [Update Seed Map] or [Update Surface].
In most cases the regeneration of the seed map is not necessary, since there are 2,147,483,648 unique random surfaces can be created with a single seed map.
By default, the seed map is generated with the same dimensions as a current size of the random dot element. If you change the size of the element in runtime, it might be a good practice to initiate regeneration of the seed map in parallel by the runtime action [Update Seed Map] - it will guarantee a correct randomization process.
Evaluation of the randomization algorithm ¶
Our randomization algorithm of reshuffling the pixel positions has an important gain for many experimental scenarios – it allows keeping the overall luminance intensity of each generated surface nearly constant. The graph below demonstrates the frequency distribution of the RGB luminance for 10000 random dots surfaces (1024x768) generated by the random dots element. Notice that the entire distribution falls within a single RGB step.
The algorithm has been also tested for cross-correlation of two randomly selected pixels in a sequence of the generated surfaces. The results are shown below on the scatter plot. The cross-correlation has been found to be not significant after 10000 runs and r is -0.02. The red line shows the "zero" correlation trend with confidence intervals.
Our randomization algorithm has been designed to produce a continuous uniform distribution of random values for every pixel. For luminance the distribution falls within the standard gray RGB range, 0..255, by default. We evaluated the goodness of the produced uniform distribution by comparing it with the distribution of pixel sampling by the standard random number generator in the C# programming language. Below are three graphs showing frequency distributions of the RGB luminance for two pixels (coordinates are randomly selected) and the standard random numbers generated in ~ 10000 passes.
We assesses the most common statistical measures of all the obtained distributions and did not find significant differences in results between our and standard randomization algorithms. Notice the Kurtosis values in the table below, the negative values are indicative for the uniform distributions.
Generator | N | Mean | Sum | Minimum | Maximum | Variance | Std. Dev. | Std. Error | Kurtosis |
---|
Pixel A | 10000 | 126.9760 | 1378959 | 0.00 | 255.0000 | 5446.435 | 73.79997 | 0.708176 | -1.18102 |
Pixel B | 10000 | 128.8085 | 1398860 | 0.00 | 255.0000 | 5457.436 | 73.87446 | 0.708891 | -1.18804 |
Standard | 10000 | 126.8245 | 1377314 | 0.00 | 255.0000 | 5365.272 | 73.24802 | 0.702880 | -1.17682 |
Notes
- If you need a random dots surface with individual dots larger than the screen pixel (like as a grid with large cells of random colors), the best way is to simply apply the pixelation effect with the selected ratio to the element. The pixelation effect would zoom the generated pixel pattern such that a color of the central pixel in each cell would define the color of the cell itself. Then the element can be rendered as on the example below.
- You can enable different visual effects on the random dots element in order to obtain various rendering outputs, useful in real scenarios. One example below demonstrates the random dots surface made of only black and white pixels. The result is obtained with the contrasts visual effect set to +100%.
- Another example below shows a monochromatic random dots surface made of combination of the gray random dots and the "orange" color filter effect.
Properties
Generic Properties
Name | Description | Attributes | Value Type |
---|
Settings |
Dots Type | Type of the random dots on a generated surface. | D,R | Int32 Struct:
0-Luminance
1-LuminanceColor
2-Color |
Values Range | Normalized range of the random values such that 0..1 denotes the full range. The range is applied to RGB values [0..255] for the luminance and luminance-color randomizations. For the color randomization the range defines the selected section of the 360 degrees hue ring. | D,R | clRange |
Surface | Index of the random dot surface. If value is 0 then an automatic time dependent index is used. Otherwise has to be a positive integer. | D,R | Int32 |
Seed Map | Index of the seed map. If value is 0 then an automatic time dependent index is used. Otherwise has to be a positive integer. | D,R | Int32 |
Runtime |
Update Surface | Runtime action. Being set to true at runtime, initiates regeneration of the random dots surface. | Run-time action | Boolean |
Update Seed Map | Runtime action. Being set to true at runtime, initiates regeneration of the seed map. | Run-time action | Boolean |
Current Surface | Actual surface index of the current surface, time-dependent or manual. | D,R, Read-Only | Int32 |
Current Seed Map | Actual seed map index of the current seed map, time-dependent or manual. | D,R, Read-Only | Int32 |