Professional Documents
Culture Documents
Matlab code:
x = imread(‘lena.ppm’);
figure; imshow(x);
R figure; imshow(x(:,:,1));
figure; imshow(x(:,:,2));
figure; imshow(x(:,:,3));
Note:
Size of x: (512, 512, 3)
G B
CMPT365 Multimedia Systems 28
Color Space: RGBàYUV
Color
Compress
Conversion
R G B
Y Cb Cr
❒ Most information is in Y channel (brightness)
❍ Cb and Cr are small à easier for compression
❒ Human eyes are not sensitive to color error
❍ Don’t need high resolution for color component
CMPT365 Multimedia Systems 32
4.3.3 YIQ Color Model
• YIQ is used in NTSC color TV broadcasting. Again, gray pixels
generate zero (I, Q) chrominance signal.
Bit-planes
CMPT365 Multimedia Systems 46
Grayscale Image
Bi-level With
only dithering
we can first re-map image values in 0..255 into the new range 0..4 by
(integer) dividing by 256/5. Then, e.g., if the pixel value is 0 we print
nothing, in a 2 x 2 area of printer output. But if the pixel value is 4
we print all four dots.
❒ Note that the image size may be much larger, for a dithered
image, since replacing each pixel by a 4 x 4 array of dots, makes
an image 16 times as large.
❒ An ordered dither consists of turning on the printer out-put bit for a pixel
if the intensity level is greater than the particular matrix element just at
that pixel position.
(a): 8-bit grey image “lenagray.bmp”. (b): Ordered dithered version of the
image. (c): Detail of dithered version.
BEGIN
for x = 0 to xmax // columns
for y = 0 to ymax // rows
i = x mod n
j = y mod n
// I(x, y) is the input, O(x, y) is the output,
//D is the dither matrix.
if I(x, y) > D(i, j)
O(x, y) = 1;
else
O(x, y) = 0;
END
(a) (b)
(c) (d)
Fig. 5: High-resolution color and separate R, G, B color channel images.
(a): Example of 24-bit color image “forestfire.bmp”.
(b, c, d): R, G, and B color channels for this image
❒ Many systems can make use of 8 bits of color information (the so-
called “256 colors”) in producing a screen image. Why ?
❒ Many systems can make use of 8 bits of color information (the so-
called “256 colors”) in producing a screen image.
❒ Such image files use the concept of a (color index) lookup table to
store color information.
❍ Basically, the image stores not color, but instead just a set of bytes,
each of which is actually an index into a table with 3-byte values that
specify the color for a pixel with that lookup table index.
❒ Note the great savings in space for 8-bit images, over 24-bit ones:
a 640x480 8-bit color image only requires 300 kB of storage,
compared to 921.6 kB for a color image (again, without any
compression applied).
❒ The idea used in 8-bit color images is to store only the index, or
code value, for each pixel. Then, e.g., if a pixel stores the value 25,
the meaning is to go to row 25 in a color look-up table (LUT).
a) The idea is to sort the R byte values and find their median;
then values smaller than the median are labelled with a “0” bit
and values larger than the median are labelled with a “1” bit.
3. TIFF was originally a lossless format but now a new JPEG tag
allows one to opt for JPEG compression.
❒ 3. The EXIF standard also includes specification of file format for audio
that accompanies digital images. As well, it also supports tags for
information needed for conversion to FlashPix (initially developed by Kodak).
❍ PDF files that do not include images have about the same compression ratio, 2:1 or
3:1, as do files compressed with other LZW-based compression tools.
IMAGES
Overview
• Colors and palettes in Multimedia
• Creation of multimedia images.
• Creation of still images.
• Image file types used in multimedia.
Before You Start to Create:
• Plan your approach using flowcharts
and storyboards
• Organize your tools means with
multimedia tools you can make text,
buttons, sounds, etc.
• Use multiple monitors (especially for
a program like Director where
changes in one window are visible in
the presentation window)
Making Still Images
• Bitmaps ( paint graphics or raster
graphics) – used for photo-realistic
images and detailed drawings
• Vector graphics – used for lines, polygons
and other mathematical objects
• Saved as GIF,JPEG,PNG files with
compression
6
M
M
D
S
Colour
1
2 Light source, object, observer
0
1 Electromagnetic spectrum
S
t
u
a
r
t
F
r
a
s
20/09/20217
M
M
D
S
It’s a Brain Thing
1
2 Colour optical illusions
0
1 Pure yellow light will register on both
S the red absorbing cones and the
t green absorbing cones
u
a Red and green mixed yellow with
r register slightly on the blue
t
F
absorbing cones
r Brain filters out the small blue amount
a
s
as a white addition
I.e. red, green, blue produce white so 20/09/2021
the 8
M
M
D
S
Not just a Brain Thing
1
2 Colour blindness
0 Affects roughly 8% of males to varying
1
S
degrees.
t X chromosome determines the red and
u green acuity
a Men have only one X so if one is bad the
r other can’t be used to fix it
t
F Different wave lengths require different
r focal lengths to see
a Red tends to jump out, blues not so good
s for short sighted people. 20/09/20219
M
M
D
S
1 Colour affects our depth perception
2
0
And therein lies a misconception:
1
S It’s not a universal creed
t
u That reds advance and blues recede;
a
r For some there is a better chance
t
F
r That blues advance and reds recede.
a
s
20/09/2021
10
Complications of color
Why does the prism separate
the light into its spectral
Components?
15
COLOR REPRODUCTION
Color images on printed surface are formed
using subtractive process.
Light is reflected from the printed surface.
Pigments that form an image absorb some of the
colors.
Remaining colors reach the eye to produce image.
16
Color images on computer monitor use
additive process.
Varying amounts of Red, Green, and Blue light are
added together to create the color.
Graphic artists convert from RGB(additive)
color models to CMYK model if image is
printed.
17
Color
• Color and Culture
– Western culture: Red = anger, danger
Black = death, funerals
– Eastern culture Red = happiness
White = death, funerals
( Eastern Weddings and restaurants most often
use RED )
Internet study (p.142) world’s favorite color is
blue
Color
• Psychology of Color – how you perceive it
• Computer monitors produce color with red,
green and blue light – the ADDITIVE primary
colors. Tiny red, blue and green dots on the
screen, light up when bombarded by
electrons.
• The reflected light from a printed page is
SUBTRACTIVE primary colors ( cyan,
magenta, yellow and a little black)
Color
• Computerized Color
• Monitors and Color – most monitors today
are set to display 640 X 480 pixels and 256
colors, can be adjusted for more Called
VGA ( Video Graphics Array)
• Minimum configuration for Windows and
MAC
• More colors requires more memory
Color
• Computerized color
Computers combine red, green, and blue (RGB) light
Bit depth determines the number of possible colors
Varying Saturation
Hue
Definition – a ROY G. BIV =
distinct color of the Red
color gamut (range Orange
of a color model) Yellow
Green
Defined by a Blue
particular Indigo
wavelength Violet
This is what most of
us refer to when we
say “color”
Saturation
Definition:
“the amount of white light (or gray paint) mixed with the
hue”
how MUCH color; the dominance of the hue
High Saturated colors include little gray or white light
These are bright and vibrant
Low Saturated colors appear grayish in color
These include pastels and “muddier” colors
High saturation
Low saturation
Webpage Example
The two screen shots
primarily differ based on
their saturation…
How has the appeal
changed?
Is one of the slides more
“generally appealing”
than the others?
Value
Definition:
“the intensity of light present”
how light or dark the color is
Also referred to as “brightness” or “intensity”
Range from “tints” (light values) to “shades” (dark
values)
Often accomplished by mixing the color with various
amounts of white or black
shades
tints
M
M
D
S
Munsell
1
2 One of the first to try and conceive of a
0 notation for colour
1
S Not just arbitrary naming
t Notation is characterised by the hue,
u
a chroma and value
r
t
F
r
a
s
20/09/2021
41
M
M
D
S
CIE/ CIE Lab
1
2 Comission Internationale de l'Eclairage
0 (International Commission on
1
S Illumination)
t Device independent
u
a Used in colour
r management
t
F
r
a
s
20/09/2021
42
M
M
D
S
Colour Schemes
1
Monochromatic
2
All one hue
0
1 Analogous
S Hues next to one another on colour wheel
t Complimentary
u Split complimentary (opposite on colour wheel)
a Tetradic (Double split complimentary lines near each other)
r Triadic
t Split colour wheel into three 120°
F Discord
r Mismatch, rude, yet can be eye catching (attention grabbing)
a
s
20/09/2021
43
M
M
D
S
Colour Wheel
1 Newton’s Colour Wheel
2
0
Primaries
1 Can’t be made from mixing
S two pigments
t Secondaries
u Made from equal parts of
a adjacent primaries
r
t Tertiary
F Made from equal parts of a
r primary and adjacent
a secondary
s
20/09/2021
44
Color Wheels
Help to arrange colors and determine
appropriate combinations of color
Three types
artist’s wheel (paint mixing)
subtractive color wheel
additive color wheel
Additive Color Wheel
Models how projected color
combines
Black = no light (i.e., no
color)
White = all light (i.e., all
color)
Primary colors =
RED
GREEN
BLUE
From which we get RGB
Used in computer monitors,
Color Model: RGB
RGB stands for the primary
additive colors
RED
GREEN
BLUE
Has become a standard and
is often used in languages
and programs (i.e., HTML,
Flash)
Each value given an integer
range from 0 to 255
Can also be expressed as a
hexadecimal value
Subtractive Color Wheel
Models how painted color
combines (since it is now
on the paper and
reflecting the light)
White = no color (all
reflected)
Black = all color (none
reflected)
Traditional (artist’s
wheel) primary colors =
RED
YELLOW
BLUE
OR…
Subtractive Color Wheel
Printers (computer) use the
following primary colors =
CYAN
MAGENTA
YELLOW
From which we get CMYK
(more detail later
Subtractive color works
through light absorption
(what we see is the color not
absorbed)
Magenta + Cyan = Blue
Cyan + Yellow = Green
Yellow + Magenta = Red
Color Harmony
• Certain combinations of colors tend
to be pleasing. They arise from the
color harmony schemes:
– Monochromatic
– Complementary
– Analogous
– Triadic
Color Harmony
83
BITMAPPED IMAGES
Line art
Two colors, usually black and white.
Line art is
Advantages 1-bit color
84
BITMAPPED IMAGES
Grayscale
Generally 8-bit images of 256 shades of
gray
For images that require more detail than
line art.
Advantages
Excellent representation of black and
white photos
Smaller files size than full color
Lower printing costs than color. 85
BITMAPPED IMAGES
Color
Consists of a pattern of colored pixels
Bit depth: the number of bits used to
encode each pixel determines the
amount of color possibilities.
Photo-realistic color requires 24-bit color.
Two methods to create color on a
computer:
Identify a table of possible colors for the
computer (Color Lookup Table) 86
MAKING COMPUTER COLOR
8-bit color presents a specific range of
colors in a table.
PCs and Macs use different tables.
Web-safe table provides colors that
display
the same on all platforms.
87
BITMAPPED IMAGE
QUALITY
Image quality depends on spatial and
color resolution.
Spatial resolution = density of pixels per
inch.
Color resolution = number of colors each
pixel can display.
Spatial resolution measurements.
Monitor output is measured in ppi (pixels
per inch).
Print output is measured as dpi (dots per
88
SPATIAL RESOLUTION
Higher spatial resolution
Captures more detail.
Pixels are smaller and closely
packed.
Produces sharper, more accurate
images.
Lower spatial resolution
Captures less detail.
Pixels are larger.
Images appear fuzzy.
High spatial resolutions yield large file sizes
but better image quality.
89
DEVICE-DEPENDENCE
Dimensions of an image depend on the
resolution of the output device.
Monitors have low spatial resolution:
72 ppi (Mac) or 96 ppi (PC).
Printers/phones/tablets have higher spatial
resolutions:
300 dpi to 2400 dpi.
Bitmapped images are device-dependent.
300 ppi image prints the original size
on 300 dpi printer.
Same image is greatly enlarged on a
72 ppi monitor.
90
COLOR RESOLUTION
Bit-depth determines color resolution.
Making the bit-depth choice:
Simple color images do not require
many colors. Low bit-depth yields small file size.
Complex color images require millions of
colors. High bit-depth yields better quality
but larger files.
Low color resolution may cause quantization
and color banding.
Quantization leads to breaks
in shades of continuous tone images.
91
COLOR RESOLUTION
Indexing
A specific palette of colors is identified to
optimize the appearance of lower color
resolution image.
Dithering
Combining pixels of different colors to produc
another color not available in the indexed
palette.
Improves image quality without increasing bit
depth.
92
Image File Formats
• MAC has a single standard format PICT
• Windows uses device independent bitmaps
DIBs written as .bmp files, which is a
windows bitmap file
• TIFF ( tagged interchange file formats) are
universal bitmap files – used in desktop
publishing
• Adobe creates .psd files for photoshop
• See pp. 150-151 for other formats
BITMAPPED FILE FORMATS
Compression of bitmapped graphics are:
Lossy
Lossless.
Common graphic file formats are:
PICT
BMP
TIFF
What form of
JPEG compression do
each of these
GIF formats use?
PNG
94
BMP vs GIF
95
GIF vs JPEG
96
JPEG vs GIF
97
PNG vs GIF
98
SVG Scalable Vector Graphic
99
VECTOR-DRAWN GRAPHICS
Vector: a line with length, curvature, and
direction.
Vector graphics: images created from
mathematically defined shapes.
Draw programs: software used to create
vector graphics.
Main advantages:
Images can be enlarged without distortion
Small file size.
100
How vector drawn images work
A vector is a line that is described by the
location of its two endpoints.
Vector drawing makes use of Cartesian
coordinates.
Cartesian coordinates are numbers that
describe a point in two or three dimensional
space as the intersection of the X, Y, and Z
axes.
L1 [ <0,0,0>, <10,3,6>
101
DEVICE INDEPENDENCE
Vector graphics can be used with
different devices without altering the
image dimension.
Printers and monitors preserve the
original dimension of the image.
102
ADVANTAGES
BITMAPPED IMAGES VECTOR IMAGES
3-D objects
combine
various shapes
Modeling 3-D objects
• Start with a shape ( block, cylinder,
sphere, …)
• You can draw a 2-D object and extrude or
lathe it into the third dimension
• Extrude – extends the shape
perpendicular to the shapes outline
• A lathed shape is rotated around a defined
axis to create the 3-D object.
Modeling 3-D objects
Shapes can be
extruded…
Modeling 3-D objects
…or lathed
Modeling 3-D objects
• Once a 3-D object has been created,
you can apply color and texture to
make it look realistic
• To model a scene, place all the
objects into 3-D space and set up
lighting effects and shadows.
• Objects will reflect or flare where
light is most intense.
Modeling 3-D objects
• Add a background or set a camera view
from which you will view the scene
• Shading can be applied in many ways (
See p. 304)
• Finally, the scene must be rendered- using
the algorithms to apply the effects you
have specified on the objects
• Rendering requires great computer power
and can often take hours for a single
image
• Toy Story were rendered on a “farm” of 87 dual processor and 30 quad-
processor 100 MHz SPARCstation 20s. It took 46 days of continuous
processing to render that film’s 110,000 frames at a rate of about one
frame every one to three hours.
Modeling 3-D objects
Gouraud
Flat
shading
shading
Ray Phong
tracing shading
Introduction to
Multimedia Computing
p g
Fiona Yan Liu
Department of Computing
The Hong Kong Polytechnic University
Learning Outputs of Lecture 06
Learning Outputs of Lecture 06
Lossy compression
Lossy compression definition
Distortion measure
The rate‐distortion theory
Quantization
Uniform scale quantization
Nonuniform
N if scale quantization
l ti ti
Transform coding
1D Discrete Cosine Transform
Compression scheme for 1D DCT
Compression scheme for 1D DCT
2D Discrete Cosine Transform
Compression scheme for 2D DCT
Reference reading
Reference reading
Chapter 8
Lecture 07: Image Data Compression 2
Outline of Lecture 07
Outline of Lecture 07
Image compression standard JPEG
Block diagram for JPEG encode
Transform RGB color model to YUV or YIQ
DCT coding for image block
Uniform scalar quantization
ZigZag scan for quantized DCT coefficients
DPCM for DC coefficients
DPCM f DC ffi i t
RLC for AC coefficients
Entropy coding
Entropy coding
JPEG file generation
Lecture 07: Image Data Compression 3
Image Compression Standard JPEG
Image Compression Standard JPEG
JPEG is an image compression standard that was
JPEG i i i d d h
developed by the “Joint Photographic Experts Group”
JPEG was formally accepted as an international
JPEG was formally accepted as an international
standard in 1992
JPEG combines several lossless and lossy compression
JPEG combines several lossless and lossy compression
techniques
Transform codingg
Quantization
DPCM
Run‐length coding
Entropy coding
Lecture 07: Image Data Compression 4
Block Diagram for JPEG Encode
Block Diagram for JPEG Encode
Lecture 07: Image Data Compression 5
JPEG: Transform RGB Color Model
to YUV or YIQ
Lecture 07: Image Data Compression 6
Transform RGB Color Model to
YUV or YIQ
Motivation
M i i
Partition the image data based on the visual acuity
Visual acuity is the accuracy in distinguishing closely spaced lines
y y g g y p
Human’s visual acuity is much greater for gray than for color
YUV color model
Y: luminance information
Y l i i f ti
U and V: chrominance information
YIQ color model
Q
Y in YIQ is the same as in YUV
I and Q are a rotated version of U and V
R f
Reference reading
di
Lecture 2
Lecture 07: Image Data Compression 7
JPEG: DCT Coding for Image Block
JPEG: DCT Coding for Image Block
Lecture 07: Image Data Compression 8
Compression Scheme of 2D DCT
for Image Data
S ti l f
Spatial frequency
Indicates how many times pixel values change across an
image block
The DCT formalizes spatial frequency
With a measure of how much the image contents change in
p y p
correspondence to the number of cycles of a cosine wave per
block
Motivation of DCT
Spatial redundancy of the image
Spatial redundancy of the image
Useful image contents change relatively slowly
DCT can concentrate the information within first several
components
Humans are not sensitive to the loss of information of high
spatial frequency
Lecture 07: Image Data Compression 9
DCT Coding for Image Block
DCT Coding for Image Block
P ii
Partition the image to the blocks of 8 pixels * 8 pixels
h i h bl k f 8 i l * 8 i l
2D DCT for each block in encoding part
2D IDCT for each block in decoding part
Reference reading
Lecture 5
Lecture 07: Image Data Compression 10
JPEG: Uniform Scalar Quantization
JPEG: Uniform Scalar Quantization
Lecture 07: Image Data Compression 11
Uniform Scalar Quantization
Uniform Scalar Quantization
M i i
Motivation
Yield higher compression ratio
Main source for compression in JPEG
Main source for compression in JPEG
Quantize DCT coefficients
F (u, v)
Fˆ (u, v) round ( )
Q(u , v)
F(u,v) represents a DCT coefficients
Q(u,v) is a “quantization table" entry
Fˆ (u, v) represents the quantized DCT coefficients
Reference reading
Reference reading
Lecture 5
Lecture 07: Image Data Compression 12
Quantization Table
Quantization Table
Use different quantization tables for luminance
U diff t ti ti t bl f l i
information and chrominance information
The entries of Q(u,v) tend to have larger values
The entries of Q(u,v) tend to have larger values
towards the lower right corner
Lecture 07: Image Data Compression 13
JPEG: ZigZag Scan
JPEG: ZigZag Scan
Lecture 07: Image Data Compression 14
Zig‐Zag Scan for Quantized DCT
Coefficients
Zig‐Zag scan
Lecture 07: Image Data Compression 15
JPEG: DPCM for DC Coefficients
JPEG: DPCM for DC Coefficients
Lecture 07: Image Data Compression 16
DPCM for DC Coefficients
DPCM for DC Coefficients
Q
Quantized DCT coefficients
ti d DCT ffi i t
Direct current (DC) coefficient ~ F(0,0)
Alternate current (AC) coefficient
te ate cu e t ( C) coe c e t ~ other F(u,v)
ot e (u, )
The DC coefficients are coded separately from the AC ones.
Differential Pulse Code Modulation
DPCM is the coding method for DC coefficients
Example of encoding DC coefficients
DC coefficients for the first 5 image blocks: 150,155, 149,
DC coefficients for the first 5 image blocks: 150 155 149
152, 144
Coding result: 150, 5, ‐6, 3, ‐8
R f
Reference reading
di
Lecture 3
Lecture 07: Image Data Compression 17
JPEG: RLC for AC Coefficients
JPEG: RLC for AC Coefficients
Lecture 07: Image Data Compression 18
RLC for AC Coefficients
RLC for AC Coefficients
Zig Zag Scan
Zig‐Zag
Lecture 07: Image Data Compression 19
JPEG: Entropy Coding
JPEG: Entropy Coding
Lecture 07: Image Data Compression 20
Entropy Coding
Entropy Coding
The DC and AC coefficients finally undergo an entropy
Th DC d AC ffi i fi ll d
coding step to gain a possible further compression
Each DPCM coded DC coefficient is represented by
Each DPCM coded DC coefficient is represented by
(SIZE, AMPLITUDE)
Each RLC coded AC coefficient (RUNLENGTH VALUE)
Each RLC coded AC coefficient (RUNLENGTH, VALUE)
is represented by (RUNLENGTH, SIZE, AMPLITUDE)
SIZE is Huffman coded
SIZE is Huffman coded
AMPLITUDE and RUNLENGTH use actual values
Reference reading
Reference reading
Lecture 4
Lecture 07: Image Data Compression 21
Entropy Coding for DPCM Coded DC
Coefficient
SIZE indicates how many bits are needed for
SIZE i di t h bit d df
representing the coefficient
AMPLITUDE contains the actual bits.
AMPLITUDE contains the actual bits.
Example of DPCM coded dc coefficients
150, 5, −6, 3, −8
(8, 10010110), (3, 101), (3, 001), (2, 11), (4, 0111) .
Lecture 07: Image Data Compression 22
JPEG File Generation
JPEG File Generation
Lecture 07: Image Data Compression 23