Professional Documents
Culture Documents
3 4 Image Data Representation and Color
3 4 Image Data Representation and Color
Chapter Three:
Graphics/Image Data Representation
1
Graphics/Images
A digital image contains 2D samples of a surface, which can be
represented as matrices
Each sample in an image is called a pixel
A pixel is the smallest image component and thus shows the smallest detail
Each pixel contains values representing a particular color
Pixels
Each pixel is given a numerical
value that represents the
corresponding color
They are the smallest unit of
information that makes up a
picture. Usually round or
square, they are typically
arranged in a 2-dimensional
2 grid.
Where to get digital images
By scanning existing images (a drawing or an old photograph or a painting)
By taking a picture with our digital camera
By creating something original using MS Paint or Photoshop or some
graphics program
image with 4
samples
(2x2)
4
Sampling
image with
8x8 samples
Image with
88X88 samples
5
Quantizing for Images
represent the color of each square with 1 bit
(only 2 colors)
6 NOTE: all these images have the exact same number of samples
Image Quality
Image quality depends on:
Spatial resolution and
Color (Intensity Level) resolution
Spatial resolution
Density of pixels per inch.
A measure of the smallest discernible detail in an image
When scanning or getting an image from our digital camera, the
scanner or the camera can determine how many samples to take
(how finely to break down the images)
The more samples that are taken, the higher the resolution will
be.
Given in terms of dots(pixels) per inch
Samples on scanners/printers are measured as dots per inch (DPI)
Samples on a monitor are measured as pixels per inch (PPI)
7
Higher spatial resolution
o Captures more detail.
Pixels are smaller and closely packed.
o Produces sharper, more accurate images.
Lower spatial resolution
o Captures less detail
Pixels are larger.
o Images appear fuzzy.
High spatial resolutions yield large file sizes but better
image quality.
8
Example
If we scan an 8 inch by 10 inch image at 100dpi, the image will be (8*100)
* (10*100) = 800*1000 = 800,000 samples (almost 1 million samples).
QUESTION: What do we call a sample in an image?
Thus the above image would have 800,000 pixels.
9
Pixels in Digital Cameras
How many megapixels (millions of pixels) you can capture in a
photograph on your digital camera
A table below shows relation between megapixels and image sizes in
digital cameras
Megabytes Size of image Total # of Printing at 300dpi,
(pixels WxH) Pixels biggest suggested print
12
Intensity Level Resolution
1 bit per pixel (binary image)
13
8 bits per pixel (gray scale image)
15
Binary Image
Also referred as 1-bit image
Each pixel is stored as a single bit (0 or 1)
Use for pictures containing simple graphics or text
A 640 × 480 binary image requires 37.5 KB of
storage
Gray Scale Image
Also referred as 8-bit Images
Each pixel is represented by a single byte
Each pixel has a gray-value between 0 & 255
A 640 × 480 grayscale image requires 300 KB of storage
16
True Color Images
Also referred as 24-bit Color Images
Each pixel is represented by three bytes, usually RGB
supports 256 × 256 × 256 possible colors.
A 640 × 480 24-bit color image would require 921.6 KB of storage
without any compression
Some 24‐bit color images are stored as
32‐bit image
Extra byte of data for
special‐effect information
8-bit Color Image
Only 256 colors
Use the concept of a lookup
table to store color information.
The image stores not color, but a
17
set of indexes into a table
Bitmapped Images Vs. Vector Graphics
Bitmapped Graphic Image
Image consists of pixels in a grid
Also called raster graphics image
Bitmapped images are resolution dependent
All images from scanners and digital cameras are bitmapped
images
18
Resampling Bitmapped images
Process of increasing or decreasing the number of samples
described in a file.
Upsampling: adding samples to the file.
Downsampling: reducing the samples in the image.
Upsampling: used to enlarge the physical dimensions of an
image on a given device.
Software creates additional pixels for the image.
• Algorithms interpolate the pixel and color to add.
Can significantly degrade the original image.
Downsampling: reducing the pixels in the file can produce
smaller images that maintain good quality
20
Common Bitmap Formats
Common bitmap file formats are:
BMP(BitMap)
GIF(Graphics Interchange format)
JPEG, JPG(Joint Photographic Expert Group)
PNG(Portable Network Graphics)
PICT (Macintosh)
PCX
TIFF(Tagged Image file format)
PSD (Adobe Photoshop)
Popular bitmap editing tools/software packages:
Microsoft Paint
Adobe Photoshop
Corel Photo-Paint, Corel Paint Shop Pro
The Gimp
21
Vector Graphics
Vector image is made up of individual, scalable
objects.
Objects are defined by mathematical equations
Objects consist of lines, curves and shapes
No distortion as image is enlarged
22
Most browsers don’t display vector graphics
without a plug in.
Only can be used with drawings, not photographs
Usually vector graphic image has a smaller file
size than the same image stored as a bitmap.
Below: enlarging and shrinking an image: left
using a vector graphical image, right using a
bitmapped
23
Common Vector File Formats
Common Vector file formats include:
AI (Adobe Illustrator)
CDR (CorelDRAW)
CMX (Corel Exchange)
CGM Computer Graphics Metafile
DXF AutoCAD
WMF Windows Metafile
EPS (Encapsulated PostScript)
Popular vector drawing programs/software packages are:
Adobe Illustrator
CorelDRAW
Xara Xtreme
Serif DrawPlus
24
25
How do we pick the most appropriate file format?
26
Depends on type of image!
The type of image we are trying to compress will
determine the best file format to choose!
3 file formats we will look at:
GIF
JPG
PNG
27
GIF (Graphic Interchange Format)
Widely used on the World Wide Web
Cross Platform (works on Macs, Windows)
Supports 8 bit colour
Not great for photographs but good for clipart, logos,
animation
28
GIF
Produces smaller file sizes than jpgs
Does a lossless compression:
Assume we have an image that is
200 by 200 pixels
If the original image had 256 colours or less
With no compression the file size would be:
200*200*3/1024 = 117 KB
Same image, save as a gif:
With 256 Colours 8.4 KB
With 16 Colours (cant pick less than 9 in Photoshop)
5 KB
NOTICE: NO CHANGE IN QUALITY,
LOSSLESS COMPRESSION!
29
Transparency
Allows for transparency
of ONE colour
Background will show
through:
GIF Transparency
30
GIF Animation
Allows for animation
Don’t need a plug in for gif animation!
Works in all browsers, universal format!
31
GIF Dithering
Allows for dithering:
Question: What do you think a program, that converts
images into gifs does, if the image has more than 256
colors?
Solution 1: Substitute one of the colors you have for one
of the colors you are missing
Solution 2: dithering
32
GIF Dithering
Juxtaposing (place side by side) pixels of two colors
to create the illusion that a third color is present
(grainy look)
Example:
◦ Assume our image uses 257 colours
◦ The 257th colour that is not in our palette is:
◦ Assume we do have these 2 colours: and
◦ Thus dithering will change this
◦ To this
33
Another Example of Dithering
34
GIF Interlacing
How images are downloaded to your
screen
Interlacing lets you have a feel for the
whole picture, you don’t have to wait
around to see it download (good for
dial up connections)
a process by which the image is
drawn in a series of passes rather
than all at the same time (file size
bigger)
35
JPG (JPEG) – Joint Photographic Experts Group
36
JPG
Good for photographs, computer games, screenshots,
stills from a movie, etc
Best for blends of color, softer shadow effects, subtle
changes in color
Not good for well-defined lines or sharp contrasts between
colours
Question: Guess which one is the GIF and which one is
the JPG:
37
JPG
JPG does a lossy compression
Discards more data about colours than about brightness
Not all of the information in the original image is
preserved – not the same as the original
Compression is achieved by ‘forgetting’ certain details
about the image, which the JPG will then try to fill in later
when it is being displayed
Degree of amount of information LOST (lossyness) can
be varied by adjusting compression parameters.
(controlled by you)
38
JPG
Original 0%
Compression = 100%
Quality
40
PNG (Portable Network Graphics)
Pronounced PING
Does LOSSLESS compression
Two versions of PNG
PNG-8
PNG-24
41
PNG-8
Similar to GIF
Only allows for 256 colours
Allows for 1 transparent colour
Storing of colours is more efficient in PNG files than
GIFS thus PNG-8 files might be SMALLER than their
GIF counterparts
42
PNG-24
Allows for 24 bit colour
It is LOSSLESS so JPG files will be smaller than the
same image saved as PNG-24 file
Allows for transparency on each pixel, with different
levels of opacity:
43
Comparison of GIF, JPG, PNG
GIF JPG PNG-8 PNG-24
Best For Logos, Photographs Logos, Photograph
Cartoons, Cartoons, Images with a
Drawings Drawings need for
transparency
Type of Lossless Lossy Lossless Lossless
Compression
Well Supported All All All Not on IE6
in Browsers
Transparency One COLOUR NO One COLOUR Varying levels
only only of opacity and
transparency
Animation Yes No No No
Dithering Yes No Yes No
Interlacing Yes No Yes Yes
Shape of image Must be
44 rectangular
Warm up Question:
1. GIF
2. PNG
3. JPG
45
MULTIMEDIA SYSTEM
Chapter Four :
Colour Models in Images
46
Color
Produced by light of various wavelengths - when light strikes an
object and reflects back to the eyes
Colour images
Colour images have two components:
Raster data – an array of pixels;
Colour model – a description of how pixels are mapped to colours.
A pixel is defined in terms of its components in a particular colour space.
47
Color
An element of art with three properties:
Hue : The name given to a color
Example: red, yellow, blue
48
Combining lights of two different colors
Additive color mixing
49
Color Models
Color models:
Different ways of representing information about color
Example:
RGB
HSB
CMYK
HSB Model
Based on human perception of color, describe three fundamental
properties of color:
Hue
Saturation (or chroma)
Brightness - relative lightness or darkness of color, also measured as
%
50
HSB Model
Hue - color reflected from or
transmitted through an object,
measured on color wheel
Brightness - relative
lightness or darkness of
color, also measured as %
0% 50% 100%
Black white
51
uses additive colors
specifies colors according
RGB Color Model