File: dithering.htm

package info (click to toggle)
extrema 4.3.6-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 19,212 kB
  • ctags: 6,452
  • sloc: cpp: 86,428; sh: 8,229; makefile: 814
file content (186 lines) | stat: -rw-r--r-- 9,259 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<HTML>
<HEAD>
<TITLE>Dithering</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">

<P><font size="+3" color="green"><B>Dithering</B></font></P>

<TABLE border="1" cols="2" frame="box" rules="all" WIDTH="610">
<TR>
<TD width="15%" valign="top"><B>Syntax</B>:</TD>
<TD width="85%" valign="top"><CODE>
DENSITY\DITHERING { x y } z { p1 p2 }<br />
DENSITY\DITHERING\DITHERVECTOR d { x y } z { p1 p2 }<br />
DENSITY\DITHERING\LEVELS lvl { x y } z { p1 p2 }<br />
DENSITY\DITHERING\LEVELS\DITHERVECTOR d lvl { x y } z { p1 p2 }</CODE>
</TD></TR>
<TR>
<TD width="15%" valign="top"><B>Qualifiers</B>:</TD>
<TD width="85%" valign="top"><CODE>
\LEGEND, \DITHERVECTOR, \CONTOURS, \LEVELS, \AREAS, \VOLUMES, \LINES, \EQUALLYSPACED,
\PARTIAL, \XPROFILE, \YPROFILE, \BORDER, \AXES, \RESET</CODE>
</TD></TR>
<TR>
<TD width="15%" valign="top"><B>Defaults</B>:</TD>
<TD width="85%" valign="top"><CODE>
if <CODE>z</CODE> is a matrix:
<CODE>x=[1;2;3;...], y=[1;2;3;...],</CODE>
<CODE>p1=0, p2=1,</CODE>
d=[1;1;2;1;2;2;3;2;3;3;4;3;4;4;5;5;6;6;0;0], \-PARTIAL, \-LEGEND, \-XPROFILE,
\-YPROFILE, \BORDER, \AXES, \RESET, \-LEVELS, \-AREAS, \-VOLUMES, \-LINES, \-EQUALLYSPACED</CODE>
</TD></TR>
</TABLE>
<P>
 In this type of density plot, by default, the range of data values is divided into
 ten (10) equally spaced levels and a different dithering pattern is associated with
 each level. A value is interpolated at every pixel location within the bounds of the
 data region to determine the level for that point. The dithering pattern for that
 level then determines whether that pixel is to be lit up. Thus, the boundaries
 of the data are divided up into different dithering pattern regions.</p>
<P>
 <font size="+1" color="green">Input variables</font></P>
<P>
 If <CODE>z</CODE> is a vector, the parameters <CODE>x</CODE> and <CODE>y</CODE>
 are expected and must be vectors. <CODE>x</CODE> and <CODE>y</CODE> are assumed to represent a scattered set
 of points, where <CODE>z[i]</CODE> is the altitude corresponding to the location
 <CODE>(x[i],y[i])</CODE>. A matrix is interpolated on these scattered points by means of a Thiessen
 triangulation of the plane. The three vectors must be the same length.</p>
<p>
 If <CODE>z</CODE> is a matrix, the parameters <CODE>x</CODE> and <CODE>y</CODE> default to
 <CODE>[1;2;3;...]</CODE>, but if entered they must be vectors. Each matrix element,
 <CODE>z[i,j]</CODE>, is associated with the coordinates <CODE>(x[j],y[i])</CODE>.  The
 length of <CODE>x</CODE> must be equal to the number of columns of <CODE>z</CODE> and the length of
 <CODE>y</CODE> must be equal to the number of rows. The vectors <CODE>x</CODE> and
 <CODE>y</CODE> are used for scaling the axes.</p>
<p>
 <font size="+1" color="green">Dithering pattern definition</font></p>
<p>
 The default dithering pattern vector is:</p>
<p>
 <CODE>[ 1;1; 2;1; 2;2; 3;2; 3;3; 4;3; 4;4; 5;5; 6;6; 0;0 ]</CODE></p>
<p>
 A user defined dithering pattern can be entered by using the
 <CODE>\DITHERVECTOR</CODE> qualifier and entering the
 dithering pattern vector, <CODE>d</CODE>, as the first parameter.</P>
<P>
 The dithering pattern is determined by pairs of numbers from
 <CODE>d</CODE>, so the number of dithering patterns defined by <CODE>d</CODE> is &frac12; the 
 length of <CODE>d</CODE>.</p>
<p>
 For pattern number <CODE>i</CODE>, every
 <CODE>d[2i-1]</CODE><sup>th</sup> pixel is lit up horizontally, and every
 <CODE>d[2i]</CODE><sup>th</sup> pixel is lit up vertically. For example, if 
 <CODE>d[1]=1</CODE> and <CODE>d[2]=1</CODE>, then for level <CODE>1</CODE> every pixel is lit up, while if
 <CODE>d[3]=2</CODE> and <CODE>d[4]=3</CODE>, then for level <CODE>2</CODE> every
 second pixel is lit up horizontally and every third pixel is lit up vertically.</p>
<p>
 <font size="+1" color="green">Changing the range of values</font></p>
<p>
 The optional parameters <CODE>p1</CODE> and <CODE>p2</CODE> can be used to broaden or shrink
 the range of data values. If <CODE>z<sub>max</sub></CODE>
 is the maximum value of the data and <CODE>z<sub>min</sub></CODE>} is the minimum value of the
 data, the full colour range will be from a minimum of 
 <CODE>min = p1*(z<sub>max</sub>-z<sub>min</sub>)+z<sub>min</sub></CODE>
 to a maximum of <CODE>max = p2*(z<sub>max</sub>-z<sub>min</sub>)+z<sub>min</sub></CODE>.
 If <CODE>z</CODE> is a data value and if
 <CODE>z &lt; p1*(z<sub>max</sub>-z<sub>min</sub>)+z<sub>min</sub></CODE>,
 that data value is treated as <CODE>z<sub>min</sub></CODE>.
 If <CODE>z &gt; p1*(z<sub>max</sub>-z<sub>min</sub>)+z<sub>min</sub></CODE>,
 that data value is treated as <CODE>z<sub>max</sub></CODE>.
 The default values are: <CODE>p1=0</CODE> and <CODE>p2=1</CODE>.</p>
<p>
 <font size="+1" color="green">Legend</font></p>
<p>
 If the <CODE>\LEGEND</CODE> qualifier is used, a legend is
 drawn along the right side of the axes. The legend requires the right end of the
 <i>x</i>-axis to be set to <CODE>75%</CODE> of the window, that is,
 <CODE><a href="../Characteristics/Xaxis/xupperaxis.htm">XUPPERAXIS</a>
 </CODE> is set to <CODE>75%</CODE>.</P>
<p>
 When a <i>y</i>-profile is drawn, using the
 <CODE>\YPROFILE</CODE> qualifier, the right edge of the
 axis box must allow space for the profile as well as a possible legend. If a
 <i>y</i>-legend profile and a legend are present, then
 <CODE>XUPPERAXIS</CODE> is set to <CODE>65%</CODE>. If a
 <I>y</I>-legend profile is present but not a legend, then
 <CODE>XUPPERAXIS</CODE> is set to <CODE>85%</CODE>.</p>
<p>
 By default, <CODE>XUPPERAXIS</CODE> is reset to its former value after the
 <CODE>DENSITY</CODE> command. If the <CODE>/-RESET</CODE> qualifier is used, the
 axis location  is not reset.</p>
<p>
 <font size="+1" color="green">Contours</font></p>
<p>
 By default, a contour line is drawn around the boundary of each dithering
 pattern region. If the <CODE>\-LINES</CODE> qualifier is
 used, then these contour lines will not be drawn.</p>
<p>
 If the qualifier <CODE>\CONTOURS</CODE> is used, an
 automatically created vector named
 <CODE><font color="orange">DENSITY$CONTOURS</font></CODE> will be made which will
 contain the boundary values of each region. If there are <CODE>N</CODE> regions, the
 length of <CODE><font color="orange">DENSITY$CONTOURS</font></CODE> will be
 <CODE>N+1</CODE>.</P>
<P>
 <font size="+1" color="green">User specified contour levels</font></P>
<P>
 A specific set of contour levels can be entered by using
 <CODE>\LEVELS</CODE> and entering a vector of contour level
 values, <CODE>lvl</CODE>, as the first parameter,
 unless the <CODE>\DITHERVECTOR</CODE> qualifier is also used,
 in which case the contour level vector should be the second parameter.  If both are
 used, and the length of the dithering vector is <CODE>N</CODE>, the length of the
 level vector must be <CODE>N/2 - 1</CODE>. Suppose that
 <CODE>z<sub>min</sub></CODE> and <CODE>z<sub>max</sub></CODE> are the minimum and
 maximum of the data <CODE>z</CODE>. The level vector must be
 strictly monotonically increasing, with <CODE>lvl[1] &gt; z<sub>min</sub></CODE>
 and <CODE>lvl[#] &lt; z<sub>max</sub></CODE>.</p>
<p>
 The <CODE>\EQUALLYSPACED</CODE> qualifier only applies
 to the case of a dithering type density plot with legend, where the user supplies the
 contour levels, for example:</p>
<p>
 <CODE>DENSITY\DITHERING\LEVELS\LEGEND\EQUALLYSPACED lvl x y m</CODE></P>
<P>
 If the <CODE>\EQUALLYSPACED</CODE> qualifier is used, the
 legend boxes will all be the same size, irregardless of the values specified in the
 levels vector, <CODE>lvl</CODE>.</P>
<P>
 <font size="+1" color="green">Areas and volumes</font></P>
<P>
 If the <CODE>\AREAS</CODE> qualifier is used, an
 automatically created vector named <CODE><font color="orange">DENSITY$AREAS</font></CODE>
 will be made which will contain the percentage areas contained within each region. If
 the <CODE>\VOLUMES</CODE> qualifier is used, an automatically created vector named
 <CODE><font color="orange">DENSITY$VOLUMES</font></CODE> will be made which will
 contain the percentage volumes contained within each region.  If there are
 <CODE>N</CODE> regions, the length of
 <CODE><font color="orange">DENSITY$AREAS</font></CODE> and
 <CODE><font color="orange">DENSITY$VOLUMES</font></CODE> will both be <CODE>N</CODE>.
 Also, the sum of the elements of each of these vectors will always be
 <CODE>100</CODE>.</P>
<P>
 <font size="+1" color="green">Examples</font></P>
<p>
 These examples use the following vectors.</p>
 <pre>
 X=[  1;  0;  1;  0;   .2; .3;   .5;  .8]
 Y=[  5;  5;  0;  0;    1;1.5;  2.5;   4]
 Z=[ 10; 10; 10; 10; -100; 10; -100; 500]
 D=[ 1;1; 2;2; 4;4; 7;7; 11;11; 0;0 ]
 </PRE>

 <font color="blue"><CODE>DENSITY\DITHERING X Y Z</CODE></font><br />
 <img src="dithering1.png"><br />
 <font color="blue"><CODE>DENSITY\DITHERING\LEGEND X Y Z</CODE></font><br />
 <img src="dithering2.png"><br />
 <font color="blue"><CODE>DENSITY\DITHERING\DITHERVECTOR\LEGEND D X Y Z</CODE></font><br />
 <img src="dithering3.png"><br />
<p>
 <a href="gradients.htm"><img src="../shadow_left.gif">&nbsp;
 <font size="+1" color="olive">GRADIENTS</font></a><br />
 <a href="diffusion.htm"><img src="../shadow_right.gif">&nbsp;
 <font size="+1" color="olive">DIFFUSION</font></a></P>
</BODY>
</HTML>