- Forward


Visual Content
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Visible Light
Back SMYC Forward
  • The part of the electromagnetic spectrum with wavelengths ranging from about 380 to 740 nanometers
  • A source of an electromagnetic wave creates electric and magnetic fields, perpendicular to each other, that travel away from the source
  • The energy of an EM wave is stored in the electric and magnetic fields
  • EM waves can travel through a vacuum
Visible Light (cont.)
Back SMYC Forward

An EM Wave

em-wave
Visible Light (cont.)
Back SMYC Forward
  • A spectral color is light of a single wavelength in the visible spectrum.
  • The visible spectrum is commonly divided into seven bands named red, orange, yellow, green, blue, indigo and violet (listed in decreasing wavelength).
  • It is very difficult to reproduce spectral colors using conventional techniques.
Light Sources and Reflected Light
Back SMYC Forward
  • Light from common objects (whether they are sources of light or objects that reflect light) consists of a range of different wavelengths.
  • Hence, light is often characterized using a spectral power distribution that provides the power of the light at each wavelength in the visible spectrum.
Human Vision
Back SMYC Forward

The Eye

eye
Human Vision (cont.)
Back SMYC Forward
  • Light enters through the cornea
  • Is focused by the lens
  • Stimulates sensors in the retina
Human Vision (cont.)
Back SMYC Forward
  • Visible Light:
    • 400 to 700 nanometers
  • Rods:
    • Stimulated by short wavelengths
    • Respond quickly
  • Cones:
    • \(\beta\) sensors are sensitive to wavelengths between 400 and 550 nm, but are most sensitive to a wavelength of 450 nm (what we call blue)
    • \(\gamma\) sensors are sensitive to wavelengths between 420 and 660 nm, but are most sensitive to a wavelength of 540 nm (what we call green)
    • \(\rho\) sensors are sensitive to wavelengths between 400 and 700 nm, but are most sensitive to a wavelength of 580 nm (what we call red)
Visual Perception
Back SMYC Forward
  • Processing the Output from Rods:
    • Impacts our perception of luminance or brightness
    • Perceived brightness is approximately logarithmic
  • Processing the Output from Cones:
    • Results in our perception of color
    • The data processed by the brain is just the total levels of activity in the three types of cones
Visual Perception (cont.)
Back SMYC Forward
  • Depth and Distance Cues:
    • Retinal disparity (between the two eyes)
    • Size
    • Shadows
  • Motion Cues:
    • "On" and "Off" photoreceptors
    • Head and eye movements
Visual Output Devices
Back SMYC Forward
  • Defined:
    • A machine that is capable of presenting visual information transmitted from a computer (i.e., making information stored in a computer perceivable by the human eye)
  • Types:
    • Continuous Display Space (vector devices)
    • Discrete Display Space (raster devices)
Coordinate Systems
Back SMYC Forward
  • Coordinates:
    • Quantities that designate the position of a point in relation to a given reference frame
  • The Quantities:
    • Can be linear and/or angular
Coordinate Systems (cont.)
Back SMYC Forward
  • Cartesian Coordinates:
    • The origin is at the center
    • The basis consists of the horizontal and vertical axes
    • Positive values in the "north east" quadrant
  • An Illustration:
    • cartesian-coordinates
Coordinate Systems (cont.)
Back SMYC Forward
  • Another Common Rectangular Coordinate System:
    • The origin is at the upper-left
    • The basis consists of the horizontal and vertical axes
    • Positive values in the "south east" quadrant
  • An Illustration:
    • coordinates
Modeling Color
Back SMYC Forward

The (Linear) Color Cube

rgb-cube
Modeling Color (cont.)
Back SMYC Forward
  • The RGB Model:
    • Begin with black then add red, green, and or blue
    • An additive model
    • Often used for displays/monitors
  • The CMYK Model:
    • Begin with white then remove cyan, magenta, and/or yellow
    • A subtractive model
    • Often used for printing
Rendering
Back SMYC Forward
  • Defined:
    • The process of taking an internal representation of visual content and presenting it on a visual output device
  • Rendering Engines in Java:
    • Graphics
    • Graphics2D
Rendering (cont.)
Back SMYC Forward
  • The "Black Box" Parts of the Process:
    • Conversion of the color space
    • Conversion of coordinate systems
    • Rasterization or vectorization of the internal representation
  • Parts of the Process of Concern:
    • Clipping
    • Composition
Coordinate Transforms
Back SMYC Forward

A Translation of (25,25)

coordinates_translation
Coordinate Transforms (cont.)
Back SMYC Forward

A Rotation of \(- \pi / 6\) Radians

coordinates_rotation
Coordinate Transforms (cont.)
Back SMYC Forward

A Scaling of (1.5, 1.5)

coordinates_scaling
Coordinate Transforms (cont.)
Back SMYC Forward

A Reflection About the Horizontal Axis

coordinates_reflection
Clipping
Back SMYC Forward
  • Clipping Defined:
    • Limiting the portion of the object that will be "drawn" by the rendering engine
  • Clipping in Java:
    • Methods in the Graphics2D class
Composition
Back SMYC Forward
  • Composition Defined:
    • Combining the points being drawn (the source points) with the points on the background (the destination points)
  • Composition Using Alpha Blending:
    • Four channels -- one each for red, green and blue and one for alpha (a weighting factor)
Composition (cont.)
Back SMYC Forward
  • The Source Over Destination Rule:
    • \(R_d = R_s + R_d (1 - \alpha_s)\)
    • \(G_d = G_s + G_d (1 - \alpha_s)\)
    • \(B_d = B_s + B_d (1 - \alpha_s)\)
    • \(\alpha_d = \alpha_s + \alpha_d (1 - \alpha_s)\)
  • Alpha Blending in Java:
    • The AlphaComposite class
Obtaining a Rendering Engine in Java
Back SMYC Forward
  • The JComponent Class:
    • An part of a GUI
    • When it needs to be rendered its paint(java.awt.Graphics) method is called and is passed a rendering engine
  • Rendering:
    • Write a class that extends JComponent
    • Override its paint() method
Obtaining a Rendering Engine in Java (cont.)
Back SMYC Forward

An Example

javaexamples/visual/BoringComponent.java
 
Obtaining a Rendering Engine in Java (cont.)
Back SMYC Forward
  • What About the Output Device?
    • We'll start by using the display/monitor
  • Remember Content Panes:
    • The specialization of JComponent can be added to the content pane of a MultimediaApplication or MultimediaApplet
Designing a Visual Content System
Back SMYC Forward
  • Requirements:
    • Add and remove content
    • Control the \(z\)-order of content
    • Render all of the content
    • Support multiple different presentations of the same content
    • Support the transformation of visual content
    • Be thread safe
  • Alternative Designs:
    • We'll consider several
Designing a Visual Content System (cont.)
Back SMYC Forward

A Common Design

visualization_design1
Designing a Visual Content System (cont.)
Back SMYC Forward

A Design with a Problem

visualization_design2a
Designing a Visual Content System (cont.)
Back SMYC Forward

A Better Design

visualization_design2
Designing a Visual Content System (cont.)
Back SMYC Forward

A Design that Satisfies Almost All of the Requirements

visualization_design3a
Designing a Visual Content System (cont.)
Back SMYC Forward

"Enhancing" the View with Specialization

visualization_design3b
Designing a Visual Content System (cont.)
Back SMYC Forward

A Good Design

visualization_design3
Implementation
Back SMYC Forward

The SimpleContent Interface

javaexamples/visual/statik/SimpleContent.java
 
Implementation (cont.)
Back SMYC Forward

The Visualization Class

Skeleton:

javaexamples/visual/Visualization.java (Fragment: 1)
 

Content Management:

javaexamples/visual/Visualization.java (Fragment: content)
 
javaexamples/visual/Visualization.java (Fragment: move)
 

View Management:

javaexamples/visual/Visualization.java (Fragment: views)
 

Forcing Rendering:

javaexamples/visual/Visualization.java (Fragment: repaint)
 
Implementation (cont.)
Back SMYC Forward

The VisualizationView Class

Skeleton:

javaexamples/visual/VisualizationView.java (Fragment: skeleton)
 

Rendering:

javaexamples/visual/VisualizationView.java (Fragment: render)
 
Implementation (cont.)
Back SMYC Forward

The PlainVisualizationRenderer Class

javaexamples/visual/PlainVisualizationRenderer.java (Fragment: render)
 
Implementation (cont.)
Back SMYC Forward

The ScaledVisualizationRenderer Class

Skeleton:

javaexamples/visual/ScaledVisualizationRenderer.java (Fragment: skeleton)
 

Before Rendering:

javaexamples/visual/ScaledVisualizationRenderer.java (Fragment: preRendering)
 

After Rendering:

javaexamples/visual/ScaledVisualizationRenderer.java (Fragment: postRendering)
 
Implementation (cont.)
Back SMYC Forward

The PartialVisualizationRenderer Class

Skeleton:

javaexamples/visual/PartialVisualizationRenderer.java (Fragment: skeleton)
 

Before Rendering:

javaexamples/visual/PartialVisualizationRenderer.java (Fragment: preRendering)
 

After Rendering:

javaexamples/visual/PartialVisualizationRenderer.java (Fragment: postRendering)
 
Designing a Visual Content System (cont.)
Back SMYC Forward
  • An Additional Requirement:
    • The ability to transform content
  • Alternative Designs:
    • Add a Transformation class that contains the necessary attributes and behaviors
    • Add the necessary attributes and behaviors to implementations of SimpleContent
Designing a Visual Content System (cont.)
Back SMYC Forward

Adding Transformations using a Helper

Transformable_design3
Designing a Visual Content System (cont.)
Back SMYC Forward

Adding Transformations using Stand-Alone Interfaces

Transformable_design1
Designing a Visual Content System (cont.)
Back SMYC Forward

Adding Transformations using Individual Interfaces

Transformable_design2
Designing a Visual Content System (cont.)
Back SMYC Forward

The Best Way to Add Transformations

TransformableContent
Implementation (cont.)
Back SMYC Forward

The AbstractTransformableContent Class

javaexamples/visual/statik/AbstractTransformableContent.java
 
There's Always More to Learn
Back -