SUNY Geneseo Department of Mathematics
Digital Images
Friday, April 14
Math 230 02
Spring 2017
Prof. Doug Baldwin
Return to List of Lectures
Previous Lecture
Misc
Colloquium
- “Precision Medicine in the Age of ‘Big Data’: Leveraging Machine Learning and Genomics for Drug Discoveries”
- Katie Gayvert, Geneseo math alumna, class of 2012.
- Monday, April 17, 2:30, Newton 203.
- Extra credit for a write-up.
Questions?
Chroma Key and Digital Images
Example
A foreground or “subject” image taken against a distinctively colored screen
combined (“composited”) with a background image
Some Matlab commands for reading and displaying images:
-
imread
reads an image file into a Matlab array, for example
>> me = imread( 'Baldwin.jpg' );
-
image
displays an image in a figure window, for example
>> image( me )
Implementation
Relevant ideas or questions from reading
- Images are arrays of pixels.
- A pixel is a small spot of color.
- Color is represented as red, green, and blue components in an additive scheme, with each
component being a number usually between 0 and 255. Higher numbers mean brighter colors. For
example, white = (255,255,255).
- Gray-scale only uses 1 component to describe brightness.
- There was a color-to-gray-scale algorithm.
- Signal processing considerations due to pixels being discrete things:
- Differences between pixels can cause visual errors.
- Nyquist’s theorem applies due to each pixel being a sample of continuously varying color.
- The reading also discussed image compression.
How do you think chroma key works?
- Replace screen color pixels in the subject image (i.e., pixels whose red, green, and blue
match the red, green, and blue of the screen color) with pixels from the background image
(e.g., Mars in the above example).
- At a pseudcode level of detail, this could be
for each pixel, p, in the source image
if p's color is not the screen color
leave p's color alone
else
set p's color to the color from the corresponding background pixel
Matlab represents images as 3-dimensional arrays of rows, pixels within rows, and color
components within pixels.
>> size( mars )
ans =
387 516 3
>> mars( 1, 1, 1 )
ans =
178
>> mars( 1, 1, 2 )
ans =
135
>> mars( 1, 1, 3 )
ans =
93
Lab handout
Next
Indexing multi-dimensional arrays
Read textbook sections 8.5 - 8.7
Next Lecture