Visualisation : Lecture 5 Discrete Data Structure and Colour Mapping Computer Animation and Visualisation – Lecture 10 Taku Komura Institute for Perception, Action & Behaviour School of Informatics Taku Komura Colour Mapping 1 Visualisation : Lecture 5 Overview Discrete data structure Topology and interpolation Topological dimension Data Representation − − Taku Komura Structure Topology - Cells Geometry - points Attributes Colour Mapping Colour Mapping 2 Visualisation : Lecture 5 Discrete Vs. Continuous Real World is continuous − Data is discrete − finite resolution representation of a real world (of abstract) concept Difficult to visualise continuous shape from raw discrete sampling − Taku Komura eyes designed towards the perception of continuous shape we need topology and interpolation Colour Mapping 3 Visualisation : Lecture 5 Topology Taku Komura Topology : relationships within the data invariant under geometric transformation − Which vertex is connected with which vertex by an edge? − Which area is surrounded by which edges? Colour Mapping 4 Visualisation : Lecture 5 Interpolation & Topology If we introduce topology our visualisation of discrete data improves − Taku Komura why ? : because then we can interpolate based on the topology Colour Mapping 5 Visualisation : Lecture 5 Interpolation & Topology Use interpolation to shade whole cube: − Taku Komura Interpolation: producing intermediate samples from a discrete representation Colour Mapping 6 Visualisation : Lecture 5 Taku Komura Colour Mapping 7 Visualisation : Lecture 5 Importance of representation What happens if we change the representation? Discrete data samples remain the same − Taku Komura topology has changed ⇒ effects interpolation ⇒ effects visualisation Colour Mapping 8 Visualisation : Lecture 5 Taku Komura Colour Mapping 9 Visualisation : Lecture 5 Topological Dimension Topological Dimension: number of independent continuous variables specifying a position within the topology of the data − different from geometric dimension (position within general space) point Topological 0D Geometric 2D/3D e.g. 2D (x,y) e.g. 3D point on curve curve 1D 2D/3D surface 2D 3D (in general) volume 3D 3D Temporal volume 4D 3D (+ t) Taku Komura e.g. MRI or CT scan Colour Mapping 10 Visualisation : Lecture 5 Structure of Data Structure has 2 main parts − topology : “set of properties invariant under certain geometric transformations” determines interpolation required for visualisation “shape” of data OR − geometry Taku Komura instantiation of the topology specific position of points in geometric space Colour Mapping 11 Visualisation : Lecture 5 Data Representation Data objects : − structure + value referred to as datasets Abstract Concrete Structure - Topology - Geometry ————————— Data Attributes Taku Komura Consists of Cells, points (grid) ————————— Scalars, vectors Normals, texture coordinates, tensors etc Colour Mapping 12 Visualisation : Lecture 5 Dataset Representation of the Structure Points specify where the data is known − specify geometry in ℝN Cells allow us to interpolate between points − specify topology of points Point with known attribute data (i.e. colour ≈ temperature) Cell (i.e. the triangle) over which we can interpolate data. Taku Komura Colour Mapping 13 Visualisation : Lecture 5 Cells Fundamental building blocks of visualisation − our gateway from discrete to interpolated data Various Cell Types − defined by topological dimension − specified as an ordered point list − primary or composite cells Taku Komura (connectivity list) composite : consists of one or more primary cells Colour Mapping 14 Visualisation : Lecture 5 Zero-dimensional cell types Vertex − − Primary zero-dimensional cell Definition: single point Polyvertex − Composite zero-dimensional cell − Taku Komura composite : comprises of several vertex cells Definition: arbitrarily ordered set of points Colour Mapping 15 Visualisation : Lecture 5 One-dimensional cell types Line − − Polyline − − Taku Komura Primary one-dimensional cell type Definition: 2 points, direction is from first to second point. Composite one-dimensional cell type Definition: an ordered set of n+1 points, where n is the number of lines in the polyline Colour Mapping 16 Visualisation : Lecture 5 Two-dimensional cell types - 1 Triangle − − Primary 2D cell type Definition: counter-clockwise ordering of 3 points Triangle strip − − Composite 2D cell consisting of a strip of triangles Definition: ordered list of n+2 points n is the number of triangles Quadrilateral − − Primary 2D cell type Definition: ordered list of four points lying in a plane Taku Komura order of the points specifies the direction of the surface normal constraints: convex + edges must not intersect ordered counter-clockwise defining surface normal Colour Mapping 17 Visualisation : Lecture 5 Two-dimensional cell types - 2 Pixel − Primary 2D cell, consisting of 4 points − numbering is in increasing axis coordinates Polygon − − Primary 2D cell type Definition: ordered list of 3 or more points Taku Komura topologically equivalent to a quadrilateral constraints: perpendicular edges; axis aligned counter-clockwise ordering defines surface normal constraint: may not self-intersect Colour Mapping 18 Visualisation : Lecture 5 Three-dimensional cell types Tetrahedron − Definition: list of 4 non-planar points Hexahedron − Taku Komura Six edges, four faces Definition: ordered list of 8 points six quadrilateral faces, 12 edges, 8 vertices constraint: edges and faces must not intersect Voxel − Topologically equivalent to Hexahedron − constraint: each face is perpendicular to a coordinate axis − “3D pixels” Colour Mapping 19 Visualisation : Lecture 5 Attribute Data Information associated with data topology − Taku Komura usually associated to points or cells Examples : − temperature, wind speed, humidity, rain fall (meteorology) − heat flux, stress, vibration (engineering) − texture co-ordinates, surface normal, colour (computer graphics) Usually categorised into specific types: − scalar (1D) − vector (commonly 2D or 3D; ND in ℝN) − tensor (N dimensional array) Colour Mapping 20 Visualisation : Lecture 5 Attribute Data : Scalar Single valued data at each location ozone levels elevation from reference plane − Taku Komura volume density (MRI) simplest and most common form of visualisation data Colour Mapping 21 Visualisation : Lecture 5 Attribute Data : Vector Data Magnitude and direction at each location − 3D triplet of values (i, j, k) Wind Speed Force / Displacement Magnetic Field − Taku Komura Also Normals – vectors of unit length (magnitude = 1) Colour Mapping 22 Visualisation : Lecture 5 Attribute Data : Tensor Data K-dimensional array at each location − − Generalisation of vectors and matrices Tensor of rank k can be considered a k-dimensional table Rank 0 is a scalar Rank 1 is a vector Rank 2 is a matrix Rank 3 is a regular 3D array Taku Komura Example : Tensor Stress Colour Mapping 23 Visualisation : Lecture 5 Visualisation Algorithms Taku Komura Generally, classified by attribute type − scalar algorithms − vector algorithms (e.g. glyphs) − tensor algorithms (e.g. tensor ellipses) (e.g. colour mapping) Colour Mapping 24 Visualisation : Lecture 5 Scalar Algorithms Scalar data : single value at each location Structure of data set may be 1D, 2D or 3D+ − we want to visualise the scalar within this structure Two fundamental algorithms Taku Komura − colour mapping − contouring (transformation : value → colour) (transformation : value transition → contour) Colour Mapping 25 Visualisation : Lecture 5 Colour Mapping Map scalar values to colour range for display − e.g. scalar value = height / max elevation colour range = blue →red Colour Look-up Tables (LUT) − provide scalar to colour conversion − scalar values = indices into LUT Taku Komura Colour Mapping 26 Visualisation : Lecture 5 Colour LUT Assume − scalar values Si in range {min→max} − n unique colours, {colour0... colourn-1} in LUT Define mapped colour C: − if Si < min then C = colourmin − if Si > max then C = colourmax − LUT colour0 Si colour1 C colour2 else C = colour S i − min colourn-1 max− min Taku Komura Colour Mapping 27 Visualisation : Lecture 5 Colour Transfer Function More general form of colour LUT A continuous function instead of a discrete LUT Taku Komura − scalar value S; colour value C − colour transfer function : f(S) = C − e.g. define f() to convert densities to realistic skin/bone/tissue colours Colour Mapping 28 Visualisation : Lecture 5 Colour Spaces - RGB Colours represented as R,G,B intensities − 3D colour space (cube) with axes R, G and B − each axis 0 → 1 − Black = (0,0,0) (origin); White = (1,1,1) (opposite corner) − Problem : difficult to map continuous scalar range to 3D space Taku Komura (below scaled to 0-255 for 1 byte per colour channel) can use subset (e.g. a diagonal axis) but imperfect Colour Mapping 29 Visualisation : Lecture 5 Colour Spaces - Greyscale Linear combination of R, G, B Defined as linear range − easy to map linear scalar range to grayscale intensity − can enhance structural detail in visualisation The shading effect is emphasized as distraction of colour is removed − not really using full graphics capability − lose colour associations : − Taku Komura e.g. red=bad/hot, green=safe, blue=cold Colour Mapping 30 Visualisation : Lecture 5 Example Winding numbers : − say we have a curve on a 2D plane − How much a point is surrounded by the curve − We can calculate the winding numbers at every location Taku Komura Winding numbers 1/4 1 0 Colour Mapping 31 Visualisation : Lecture 5 Winding numbers visualized by grey scale Taku Komura Cup with an open top Star with an open top A bar Colour Mapping 32 Visualisation : Lecture 5 Color Spaces – RGB Combining different channels to define a mapping function B(x) Taku Komura R(x) Colour Mapping 33 Visualisation : Lecture 5 Winding numbers visualized by red and blue Taku Komura Cup with an open top Star with an open top A bar Colour Mapping 34 Visualisation : Lecture 5 Colour spaces - HSV Colour represented in H,S,V parametrised space − H (Hue) = dominant wavelength of colour − “vibrancy” or purity of colour V (Value) = brightness of colour − Taku Komura colour type {e.g. red, blue, green...} S (Saturation) = amount of Hue present − commonly modelled as a cone brightness of the colour Colour Mapping 35 Visualisation : Lecture 5 Colour spaces - HSV HSV Component Ranges − Hue = 0 → 360o − Saturation = 0 → 1 e.g. for Hue≈blue 0.5 = sky colour; 1.0 = primary blue − Value = 0 → 1 (amount of light) Taku Komura e.g. 0 = black, 1 = bright All can be scaled to 0→100% (i.e. min→max) − use hue range for colour gradients − very useful for scalar visualisation with colour maps Colour Mapping 36 Visualisation : Lecture 5 Example : HSV image components Taku Komura Colour Mapping 37 Visualisation : Lecture 5 Winding numbers by HSV (only changing hue) Taku Komura Cup with an open top Star with an open top A bar Colour Mapping 38 Visualisation : Lecture 5 Different Colour Spaces Visualising gas density in a combustion chamber − Scalar = gas density − Colour Map = A: grayscale B: hue range blue to red A B C: hue range red to blue D: specifically designed transfer function highlights contrast C Taku Komura D Colour Mapping 39 Visualisation : Lecture 5 Color maps from Matlab Taku Komura Colour Mapping 40 Visualisation : Lecture 5 Colour Table/Transfer Function Design “More of an art than a science” Key focus of colour table design − emphasize important features / distinctions − minimise extraneous detail Often task specific − consider application (e.g. temperature change, use hue red to blue) − Rainbow colour maps – rapid change in colour hue representing a ‘rainbow’ of colours. shows small gradients well as colours change quickly. Taku Komura Colour Mapping 41 Visualisation : Lecture 5 Examples of Manually Designed LUT 3D Height Data HSV based colour transfer function − Taku Komura continuous transition of height represented 8 colour limited lookup table − discrete height transitions − Based on human knowledge Colour Mapping 42 Visualisation : Lecture 5 Summary Discrete data structure Topology and interpolation Topological dimension Data Representation − − Taku Komura Structure Topology - Cells Geometry - points Attributes Colour Mapping Colour Mapping 43