ch3: data representationsolar.gmu.edu/.../ch3_data_representation.pdf · ch3.1 continuous data...
Post on 10-Aug-2020
7 Views
Preview:
TRANSCRIPT
CDS 301
Spring, 2013
CH3: Data Representation
Jan. 29, 2013 - Feb. 12, 2013
Jie Zhang Copyright ©
Outline
3.1. Continuous Data
3.2. Sampled Data
3.3. Discrete Datasets
•Basis function for reconstruction
3.4. Cell Types
•point, line, triangle, quad, tetrahedron, hexahedron
•Transformation between world cell and reference
cell
3.5. Grid Types
•Uniform, rectlinear, structured, Unstructured
3.6. Attributes
•Scalar, Vector, Color, Tensor, Non-numerical
3.7. Computing Derivatives of Sampled Data
3.8. Implementation
3.9. Advanced Data Representation
CH3.1 Continuous Data versus
Discrete Data
•Continuous Data (Intrinsic)
•Most scientific quantities are continuous in nature
•Scientific Visualization, or scivis
•Discrete Data (Intrinsic)
•E.g., text, images and others that can not be
interpolated or scaled
•Information Visualization, or infovis
•Continuous data, when represented by computers, are
always in discrete form
•These are often called “sampled data”
•Originated from continuous data
•Intended to approximate the continuous quantity
Continuous Data
2
2 )()('',
)()(),(
dx
xfdxf
dx
xdfxfxf
a: discontinuous
function
b: first-order
continuous
function
c: high-order
continuous
function Discontinuous:
with jumps or holes
Continuous Data
f is a function: d-geometrid dimension, and c values
D: function domain
C: function co-domain
)....,()....,(
C
D
CD:
2121 dc
c
d
xxxfyyy
f
R
R
Continuous data can be modeled as:
Continuous Data
||f(p)-f(x)||
then
||p-x||
ifsuch that
0 0,
Cauchy criterion of continuity
Graphically, a function is continuous if the graph of the
function is a connected surface without “holes” or “jumps”
In words, small changes in the input always result in small
changes in the output
For all ε, there
exists a δ
Continuous Dataset
f) C, (D,cD1. D: Function domain
2. C: Function co-domain
3. f: Function itself
Dimensions
•Geometric dimension: d
• the space into which the function domain D is embedded
•It is always 3 in the usual Euclidean space: d=3
•Topological dimension: s
•The function domain D itself
•A line or curve: s=1, d=3
•A plane or curved surface: s=2, d=3
•It is determined by how many independent variables in
the function
•Dataset dimension refers to the topological dimension
•Function values in the co-domain are called dataset attributes
•Attribute dimension: dimension of the function co-domain
CH3.2 Sampling and
Reconstruction
To prepare for the visualization of the continuous dataset:
1. Sampling
• For a given continuous data, produce a set of sampled
data points
• as an input to the computer
2. Reconstruction
• For a given sampled dataset, recover an approximate
version of the original continuous data
• The approximation shall be of piecewise continuous
functions
Computer can not “see” continuous data domain,
because of limited spatial resolution
Sampling and Reconstruction
fff i
~
Sampled Dataset
Sampled dataset
f) C, (D,D
})({ k
iiii },{Φ}, {f}, {CpsD
Continuous dataset
1. p: sampled points
2. c: cell or shape that groups neighboring points
3. f: sampled values
4. Φ: basis function or interpolation function
Jan. 29, 2013 Stopped Here
(To be continued)
Jan. 31, 2013
Review
Sampled dataset
f) C, (D,D
})({ k
iiii },{Φ}, {f}, {CpsD
Continuous dataset
1. p: sampled points
2. c: cell or shape that groups neighboring points
3. f: sampled values
4. Φ: basis function or interpolation function
Sampling •Sampled data is provided only at the vertices of the
cells of a given grid
•Sample points (pi): where the data domain is sampled
•Cell (ci): primitive shapes formed by a set of points as
the vertices of the cell, e.g., polygons
•Grid (or mesh)(D): the union of cells that completely
covers the topological domain of the data.
D
0
}....,{
,
21
ii
ji
ni
d
i
cU
ji,cc
pppc
p RPoint
Cell
Grid
Sampling (on the domain D)
A data domain is sampled in a grid that contains a set of
cells defined by the sample points as vertices
Point,
Cell,
Grid
Reconstruction
function basis called is where
)()(~
}...2,1{},
i
1
xfxf
Ni{f
N
i
ii
i
or interpolation function
Reconstruction 1-D example:
•sinuous function
•10 points sampling
•Cell type: line segment
•Cell vertices: two vertices per cell
2/)()(
value,same thehave wouldcell e within thpoints All
vertices) twoof (because 2/1
function, basisconstant is If
)()(
}p,{pc
21
2
1
21j
ffxf
(x)
xfxf
j
i
i
iij
staircase
Reconstruction
Constant basis function
i
icx
cNx
,0
x,/1{)(
i0
It has virtually no
computational cost,
but provide a poor,
staircase like
approximation of the
original function
Reconstruction
Linear basis function
rfrfrf
rr
rr
21
1
2
1
1
)1()(
,)(
,1)(
For 1-D line
P1 P2
0 r 1
reference cell
Basis Function
Basis function shall be orthonormal
1. Orthogonal: only vertex points within the
same cell have contribution to the
interpolated value
2. Normal: the sum of the basic functions of all
the vertices shall be unity.
Basis Function (Example) Linear basis function: indicated by “1” in the superscript
For 2-D quad
srsr
rssr
srsr
srsr
)1(),(
),(
)1(),(
)1)(1(),(
1
4
1
3
1
2
1
1
cell=(p1,p2,p3,p4)
D: (x,y,z)
cell=(v1,v2,v3,v4)
D: (r,s,t) and t=0
Basis Function
Coordinate Transformation •Basis function is defined in reference cell
•Reference cell: axis-aligned unit cell, e.g., unit
square in 2-D, unit line in 1-D
•Data are sampled at actual (world) cells
•Mapping between actual cell and reference cell
N
i
ii zyxTfzyxf
zyxTtsrzyx
zyxTtsr
tsrTzyx
1
1
1
1
)),,((),,(~
)),,((),,(),,(
),,(),,(
),,(),,(
CH3.4 Cell Types
Vertex s=0
1),(
}{
0
1
1
sr
vc
Line s=1
2
12
1211
1
2
1
1
21
||||
)()(),,()(
)(
1)(
},{
pp
ppppzyxTr
rr
rr
vvc
Line (cont.)
Actual line along the X-axis
12
12
12
21
12
1
2211 ,,
xx
xxf
xx
xxff
xx
xxr
xpxpxp
Example
Question:
Considering the following two cells, C1 and C2, of the line-
segment type in 1-D function domain: C1={P1,P2}, C2={P2, P3},
where P1=15, P2=30, and P3=45 respectively. The sampling
values at the three sampling points are f1=0.7, f2=3.4 and f3=5.0,
respectively. You are asked to reconstruct the data values using
interpolation at points PA=22 and PB=40
(1) Find fA and fB using a constant basis function
(2) Find fA and fB using a linear basis function
Example Answer:
(1) In the case of constant basis function
(2) In the case of linear basis function
2.4
1.2
B
A
f
f
5.4
0.2
B
A
f
f
Line (cont.)
Actual line in X-Y plane
2
12
2
12
121121
222111
)()(
))(())((
),(),,(),,(
yyxx
yyyyxxxxr
yxpyxpyxp
Quad s=2
2
14
141
2
12
121
1
4
1
3
1
2
1
1
4321
||||
)()(
||||
)()(
)1(),(
),(
)1(),(
)1)(1(),(
},,,{
pp
pppps
pp
ppppr
srsr
rssr
srsr
srsr
vvvvc
Example
Question:
Considering an actual cell of quad type in 3-D space, C1={P1,
P2, P3, P4}, where P1=[1.0, 1.0, 1.0] and P2=[2.0, 1.0, 1.0],
P3=[2.0, 2.0 ,1.5], and P4=[1.0, 2.0, 1.8], The functional values of
the four vertex points are f1=1.0, f2=1.2, f3=1.5 and f4=1.5. You
are asked to reconstruct the functional value at point PA, where
PA=[1.5, 1.2, 1.3]
(1)To find fA, use constant basis function
(2)To find fA, use linear basic function.
Example Answer:
(1) In the case of constant basis function
(2) In the case of linear basis function
30.1Af
23.1Af
See scanned note for details
Jan. 31, 2013 Stopped Here
(To be continued)
February 05, 2013
Review •Basis function is defined in reference cell
•Reference cell: axis-aligned unit cell, e.g., unit
square in 2-D, unit line in 1-D
•Data are sampled at actual (world) cells
•Mapping between actual cell and reference cell
N
i
ii zyxTfzyxf
zyxTtsrzyx
zyxTtsr
tsrTzyx
1
1
1
1
)),,((),,(~
)),,((),,(),,(
),,(),,(
),,(),,(
Triangle s=2
2
13
131
2
12
121
1
1
3
1
2
1
1
321
||||
)()(
||||
)()(
),(),,(
),(
),(
1),(
},,{
pp
pppps
pp
ppppr
srzyxT
ssr
rsr
srsr
vvvc
Cell Types
1. The cell types of quads and triangles are well
suited for surface visualization.
2. But for volume visualization (s=3), topologically
3-D cells (s=3) are needed
Volume Visualization
Tetrahedron s=3
2
14
141
2
13
131
2
12
121
1
1
4
1
3
1
2
1
1
4321
||||
)()(
||||
)()(
||||
)()(
),,(),,(
),(
),(
),(
1),(
},,,{
pp
ppppt
pp
pppps
pp
ppppr
tsrzyxT
tsr
ssr
rsr
tsrsr
vvvvc
Hexahedron s=3
strsr
rstsr
tsrsr
tsrsr
trsr
trssr
tsrsr
tsrsr
vvvvvvvvc
)1(),(
),(
)1(),(
)1)(1(),(
)1)(1(),(
)1(),(
)1)(1(),(
)1)(1)(1(),(
},,,,,,,{
1
8
1
7
1
6
1
5
1
4
1
3
1
2
1
1
87654321
Hexahedron (cont.) s=3
2
18
181
2
14
141
2
12
121
1
||||
)()(
||||
)()(
||||
)()(
),,(),,(
pp
ppppt
pp
pppps
pp
ppppr
tsrzyxT
Effect of Reconstruction
Geometry:
Constant
Geometry:
Linear
Lighting:
Constant
Staircase
shading
Flat
Shading
Lighting:
Linear
--------- Smooth
(Gouraud)
shading
Effect of Reconstruction
Staircase Shading Flat Shading Smooth Shading
Note: all three images are based on (1) the same data sampling, (2)
the same data mapping, but (3) different rendering
Homework #2 1. Write a portable Matlab program to create the
following two images. Do not use the existing GUI.
CH 3.5 Grid Types
•Grid is the pattern of cells in the data domain
•Grid is also called mesh
•Uniform grid
•Rectilinear grid
•Structured grid
•Unstructured grid
Uniform Grid
2-D 3-D
Uniform Grid •The simplest grid type
•Domain D is usually an axis-aligned box
•Line segment, when s=1
•Rectangle, when s=2
•Parallelepiped, when for s=3
•Sample points are equally distributed on every axis
•Structured coordinates: the position of the sample
points in the data domain are simply indicated by d
integer coordinates (n1,..nd); d=1, 2 or 3
•Simple to implement
•Efficient to run (storage, memory and CPU)
•Numerical simulations are mostly run on uniform grid
Uniform Grid •Data points, even s=3, can be simply stored in the
increasing order of the indices, that is, an 1-D array
•Lexicographic order
213121
121
12
121
2
1
1
1
3,d If
mod
2,d If
)(
NNnNnni
)N (ni n
i/Nn
, orNnni
Nnnid
k
k
l
lk
Rectilinear Grid
2-D 3-D
Rectilinear Grid
•Domain D is also an axis-aligned box
•However, the sampling step is not equal
•It is not as simple or as efficient as the uniform grid
•However, improving modeling power
Structured Grid
•Further relaxing the constraint, a structured grid can be
seen as the free deformation of a uniform or rectilinear
grid
•The data domain can be non-rectangular
•It allows explicit placement of every sample points
•The matrix-like ordering of the sampling points are
preserved
•Topology is preserved
•But, the geometry has changed
Structured Grid
Circular domain Curved Surface 3D volume
Unstructured Grid •It is allowed to define both sample points and cells explicitly
•The most general and flexible grid type
•However, it needs to store
•The coordinates of all sample points pi
•For each cell, the set of vertex indices ci={vi1,…viCi), and
for all cells {c1,c2…}
Unstructured Grid
Feb. 05, 2013 Stopped Here
(To be continued)
February 12, 2013
CH 3.6 Attributes
•Attribute data are the set of sample values of a sampled
dataset
•Attribute = {fi}
})({ k
iiii },{Φ}, {f}, {CpsD
Sampled dataset
Attribute Types
•Scalar Attribute
•Vector Attribute
•Color Attribute: c=3
•Tensor Attributes c = (3 x 3) matrix
•Non-Numerical Attributes
1
C
c
cR
3or ,2
C
cc
cR
Scalar Attributes
•E.g., temperature, density,
RR
RR
3
2
:
or ,:
f
f
Vector Attributes
E.g.,
•Normal direction
•Force
•velocity
•A vector has a magnitude and orientation
3
2
RR
RR
3
2
:
or ,:
f
f
Tensor Attributes
•A high-dimensional generalization of vectors
VV
VyVyVxV
VVVVVV
VVVVVV
VVVVVV
BzAzByAzBxAz
BzAyByAyBxAy
BzAxByAxBxAx
),,(
,,
,,
,, ,
BAVVVTensor
Vector
Scalar
•A tensor describes physical quantities that depend on
both position and the direction at the position
•Vector and scalar describes physical quantities that
depend on position only
Tensor Attributes
•E.g. curvature of a 2-D surface
•E.g., diffusivity, conductivity, stress
Tensor
Non-numerical Attributes
•E.g. text, image, voice, and video
•Data can not be interpolated
•Therefore, the dataset has no basis function
•Domain of information visualization (infovis)
Color Attributes
•A special type of vector attributes with dimension c=3
•RGB system: convenient for hardware and implementation
•R: red
•G: green
•B: blue
•HSV system: intuitive for human user
•H: Hue
•S: Saturation
•V: Value
RGB Cube R
G
B
yellow
magenta
Cyan
RGB System
•Every color is represented as a mix of “pure” red, green and
blue colors in different amount
•Equal amounts of the three colors determines gray shades
•RGB cube’s main diagonal line connecting the points (0,0,0)
and (1,1,1) is the locus of all the grayscale value
•(0,0,0) - dark
•(1,1,1) - white
•(0.5,0.5,0.5) - intermediate gray
•(1,0,0) - red
•(0,1,0) - green
•(1,1,0) -yellow
•(1,0,1) - magenta
•(0,1,1) - cyan
HSV System
•Hue: distinguish between different colors of different
wavelengths, from red to blue
•Human eyes are sensitive to visible wavelengths
•Saturation: represent the color of “purity”, or how much hue
is diluted with white
•S=1, pure, undiluted color
•S=0, whitened
•Value: represent the brightness, or luminance
•V=0, always dark
•V=1, brightest color for a given H and S
HSV Color Wheel
HSV Color Wheel
(V=1) http://www.codeproject.com/KB/miscctrl/CPicker/ColorWheel.jpg
S=0
S=1
Color, Light, Electromagnetic
Radiation
http://www.dnr.sc.gov/ael/personals/pjpb/lecture/spectrum.gif
RGB to HSV •All values are in [0,1]
max=max(R,G,B)
min=min(R,G,B)
diff=max-min
•V = max
•largest RGB component
•S = diff/max
•For hue H, different cases
•H = (G-B)/diff if R=max
•H =2+(B-R)/diff if G=max
•H =4+(R-G)/diff if B=max
•then H=H/6
•H=H+1 if H < 0
Exp: Full Green Color
(R,G,B)=(0,1,0)
(H,S,V)=(1/3, 1,1)
Exp: Yellow Color
(R,G,B)=(1,1,0)
(H,S,V)=(1/6, 1, 1)
HSV to RGB
huecase = {int} (h*6)
frac = 6*h – huecase
lx= v*(1-s)
ly= v*(1-s*frac)
lz= v*(1-s(1-frac))
huecase =6 (0<h<1/6): r=v, g=lz, b=lx
huecase =1 (1/6<h<2/6): r=ly, g=v, b=lx
huecase =2 (2/6<h<3/6): r=lx, g=v, b=lz
huecase =3 (3/6<h<4/6): r=lx, g=ly, b=v
huecase =4 (4/6<h<5/6): r=lz, g=lx, b=v
huecase =5 (5/6<h<1): r=v, g=lx, b=ly
Exp: Full Green Color
(H,S,V)=(1/3,1,1)
(R,G,B)=(0,1,0)
Exp: Yellow Color
(H,S,V)=(1/6,1,1)
(R,G,B)=(1,1,0)
End
of Chap. 3
Note:
•The class has covered section 3.1 to 3.6.
•We have skipped section 3.7, 3.8, and 3.9. You may
want to study these section by yourselves.
top related