Bitmapped Images

Download Report

Transcript Bitmapped Images

Bitmapped Images
Digital Multimedia, 2nd edition
Nigel Chapman & Jenny Chapman
Chapter 5
This presentation © 2004, MacAvon Media Productions
5
118
Bitmapped Images
•
•
•
Also known as raster graphics
Record a value for every pixel in the image
Often created from an external source
•
•
Scanner, digital camera, …
Painting programs allow direct creation of
images with analogues of natural media,
brushes, …
© 2004, MacAvon Media Productions
5
118–119
Device Resolution
•
Printers, scanners: specify as dots per unit
length, often dots per inch (dpi)
•
•
Desktop printer 600dpi, typesetter 1270dpi,
scanner 300–3600dpi,…
Video, monitors: specify as pixel dimensions
•
•
PAL TV 768x576px, 17" CRT monitor
1024x768px,…
dpi depends on physical size of screen
© 2004, MacAvon Media Productions
5
120
Image Resolution
•
•
Array of pixels has pixel dimensions, but no
physical dimensions
By default, displayed size depends on resolution
(dpi) of output device
•
•
physical dimension = pixel dimension/resolution
Can store image resolution (ppi) in image file to
maintain image's original size
•
Scale by device resolution/image resolution
© 2004, MacAvon Media Productions
5
120–122
Changing Resolution
•
If image resolution < output device resolution,
must interpolate extra pixels
•
•
Always leads to loss of quality
If image resolution > output device resolution,
must downsample (discard pixels)
•
•
Quality will often be better than that of an
image at device resolution (uses more
information)
Image sampled at a higher resolution than that
of intended output device is oversampled
© 2004, MacAvon Media Productions
5
122–123
Compression
•
•
•
•
Image files may be too big for network
transmission, even at low resolutions
Use more sophisticated data representation or
discard information to reduce data size
Effectiveness of compression will depend on
actual image data
For any compression scheme, there will always
be some data for which 'compressed' version is
actually bigger than the original
© 2004, MacAvon Media Productions
5
122–125
Lossless Compression
•
Always possible to decompress compressed
data and obtain an exact copy of the original
uncompressed data
•
•
•
•
Data is just more efficiently arranged, none
is discarded
Run-length encoding (RLE)
Huffmann coding
Dictionary-based schemes – LZ77, LZ78, LZW
(LZW used in GIF, licence fee charged)
© 2004, MacAvon Media Productions
5
125–126
JPEG Compression
•
•
•
•
Lossy technique, well suited to photographs,
images with fine detail and continuous tones
Consider image as a spatially varying signal
that can be analysed in the frequency domain
Experimental fact: people do not perceive the
effect of high frequencies in images very
accurately
Hence, high frequency information can be
discarded without perceptible loss of quality
© 2004, MacAvon Media Productions
5
125–127
DCT
•
Discrete Cosine Transform
•
•
•
Similar to Fourier Transform, analyses a
signal into its frequency components
Takes array of pixel values, produces an
array of coefficients of frequency
components in the image
Computationally expensive process – time
proportional to square of number of pixels
•
Apply to 8x8 blocks of pixels
© 2004, MacAvon Media Productions
5
127
JPEG – Quantization
•
Applying DCT does not reduce data size
•
•
•
•
Array of coefficients is same size as array of
pixels
Allows information about high frequency
components to be identified and discarded
Use fewer bits (distinguish fewer different values)
for higher frequency components
Number of levels for each frequency coefficient may
be specified separately in a quantization matrix
© 2004, MacAvon Media Productions
5
127
JPEG – Encoding
•
After quantization, there will be many zero
coefficients
•
•
Use RLE on zig-zag sequence (maximizes
runs)
Use Huffman coding of other coefficients (best
use of available bits)
© 2004, MacAvon Media Productions
5
128
JPEG – Decompression
•
•
•
•
Expand runs of zeros and decompress
Huffman-encoded coefficients to reconstruct
array of frequency coefficients
Use Inverse Discrete Cosine Transform to take
data back from frequency to spatial domain
Data discarded in quantization step of
compression procedure cannot be recovered
Reconstructed image is an approximation
(usually very good) to the original image
© 2004, MacAvon Media Productions
5
129
Compression Artefacts
•
•
If use low quality setting (i.e. coarser
quantization), boundaries between 8x8 blocks
become visible
If image has sharp edges these become
blurred
•
•
Rarely a problem with photographic images,
but especially bad with text
Better to use good lossless method with text
or computer-generated images
© 2004, MacAvon Media Productions
5
130
Image Manipulation
•
•
Many useful operations described by analogy
with darkroom techniques for altering photos
Correct deficiencies in image
•
•
Create artificial effects
•
•
Remove 'red-eye', enhance contrast,…
Filters: stylize, distort,…
Geometrical transformations
•
Scale (change resolution), rotate,…
© 2004, MacAvon Media Productions
5
131–132
Selection
•
•
No distinct objects (contrast vector graphics)
Selection tools define an area of pixels
•
•
•
•
Draw selection (pen tool, lasso)
Select regular shape (rectangular, elliptical,
1px marquee tools)
Select on basis of colour/edges (magic
wand, magnetic lasso)
Adjustments &c restricted to selected area
© 2004, MacAvon Media Productions
5
132–135
Masks
•
•
•
Area not selected is protected, as if masked by
stencil
Can represent on/off mask as array of 1 bit per
pixel (b/w image)
Generalize to greyscale image (semitransparent mask) – alpha channel
•
•
Feathered and anti-aliased selections
Use as layer mask to modify layer
compositing
© 2004, MacAvon Media Productions
5
136
Pixel Point Processing
•
Compute new value for pixel from its old value
•
•
p' = f(p), f is a mapping function
In greyscale images, ppp alters brightness and
contrast
•
•
Compensate for poor exposure, bad lighting,
bring out detail
Use with mask to adjust parts of image (e.g.
shadows and highlights)
© 2004, MacAvon Media Productions
5
136–139
Adjustments in Photoshop
•
Brightness and contrast sliders
•
•
Levels dialogue
•
•
•
Adjust slope and intercept of linear f
Adjust endpoints by setting white and black
levels
Use image histogram to choose values visually
Curves dialogue
•
Interactively adjust shape of graph of f
© 2004, MacAvon Media Productions
5
139–142
Pixel Group Processing
•
Compute new value for pixel from its old value
and the values of surrounding pixels
•
•
Compute weighted average of pixel values
•
•
•
Filtering operations
Array of weights k/a convolution mask
Pixels used in convolution k/a convolution
kernel
Computationally intensive process
© 2004, MacAvon Media Productions
5
142–144
Blurring
•
Classic simple blur
•
Convolution mask with equal weights
•
•
Unnatural effect
Gaussian blur
•
Convolution mask with coefficients falling off
gradually (Gaussian bell curve)
•
More gentle, can set amount and radius
© 2004, MacAvon Media Productions
5
144–147
Sharpening
•
Low frequency filter
•
•
•
3x3 convolution mask coefficients all equal
to -1, except centre = 9
Produces harsh edges
Unsharp masking
•
Copy image, apply Gaussian blur to copy,
subtract it from original
•
Enhances image features
© 2004, MacAvon Media Productions
5
148–150
Geometrical Transformations
•
Scaling, rotation, etc.
•
•
•
Simple operations in vector graphics
Requires each pixel to be transformed in
bitmapped image
Transformations may 'send pixels into gaps'
•
i.e. interpolation is required
•
Equivalent to reconstruction &
resampling; tends to degrade image
quality
© 2004, MacAvon Media Productions
5
150–151
Interpolation
•
•
•
Nearest neighbour
•
Use value of pixel whose centre is closest in
the original image to real coordinates of
ideal interpolated pixel
Bilinear interpolation
•
Use value of all four adjacent pixels,
weighted by intersection with target pixel
Bicubic interpolation
•
Use values of all four adjacent pixels,
weighted using cubic splines
© 2004, MacAvon Media Productions