images n file compression
images n file compression
Syllabus Content:
1.1.2 Images
show understanding of how data for a bitmapped image is encoded
terminology associated with bitmaps: pixel, file header, image resolution, screen
resolution
perform calculations estimating the file size for bitmapped images of different
resolutions
show understanding of how data for a vector graphic is represented and encoded
terminology associated with vector graphics: drawing object, property and drawing
list
features found in bitmapped and vector graphics software are used in practice
justify where bitmapped graphics and/or vector graphics are appropriate for a given
task
Graphic images that have been processed by a computer can usually be divided into
two distinct categories.
Such images are either bitmap files or vector graphics. This section will cover the two
main image types: vector and bitmap(pixels), along with some compression
techniques.
Bitmap Graphics:
File header:
BMP, PCX, JPEG, FLI/FLC, and AVI files include headers that define the image size,
number of colors, and other information needed to display the image. Fastgraph
provides functions for reading the image headers and retrieving their more useful items.
However, there may be times when you need additional information stored in the file
header.
Resolution:
Image Resolution - how many pixels do an image contains per inch/cm?
Measurements of dots per inch (dpi) are called image resolution.
Screen Resolution - The screen resolution tells you how many pixels your
screen can display horizontally and vertically. It's written in the form 1024 x 768. In this
example, the screen can show 1,024 pixels horizontally, and 768 vertically:
The higher the resolution, the more pixels are available. Therefore the crisper the
picture
File size is always an issue with an image file. A large file occupies more memory space
and takes longer to display or to be transmitted across a network. A vector graphic file
will have a smaller size than a corresponding bitmap file. A bitmap file has to store the
pixel data but the file must also have a header that defines the resolution of the image
and the coding scheme for the pixel colour.
You can calculate the minimum size (the size not including the header) of a bitmap
file knowing the resolution and the colour depth. As an example, consider that a
bitmap file is needed to fill a laptop screen where the resolution is 1366 by 768. If the
colour depth is to be 24 then the number of bits needed is:
3147264/1024 = 3073.5 KB
307305/1024 = 3 MB approx.
Greyscale
Coloured Images:
At least eight bits per pixel are necessary to code a coloured image. The number of
bits per pixel is sometimes referred to as the colour depth.
(8 bits or 1 byte for 1 pixel in coloured image) (Computer Science Book)
24 bits almost always uses 8 bits of each of RGB(Red:8 Green:8 Blue:8) 8X8X8 = 24
As of 2018 24-bit color depth is used by virtually every computer and phone display and
the vast majority of image storage formats. (Wikipedia)
Sample Questions:
(9608/11/M/J/17)
Q3 (ii) A picture has been drawn and is saved as a monochrome bitmap image. State
how many pixels are stored in one byte.
.......................................................................................................................................[1]
Answer: 8
Q3(iii) A second picture has width 2048 pixels and height 512 pixels. It is saved as a
256-colour image.
.......................................................................................................................................
.......................................................................................................................................
.......................................................................................................................................
.......................................................................................................................................
....................................................................................................................................... [3]
Working:
Vector graphics
It is normal for an image that is created by a drawing package or a computer-aided
design (CAD) package to consist of a number of geometric objects. The outcome is
then usually for the image to be stored as a vector graphic file
Unlike bitmaps, vector images are not based on pixel patterns, but instead use
mathematical formulas to draw lines and curves that can be combined to create an
image from geometric objects such as circles and polygons. Vector images are edited
by manipulating the lines and curves that make up the image using a program such as
Adobe Illustrator.
Vector images have some important advantages over bitmap images. Vector images
tend to be smaller than bitmap images. That’s because a bitmap image has to store
color information for each individual pixel that forms the image. A vector image just has
to store the mathematical formulas that make up the image, which take up less space.
Vector images are also more scalable than bitmap images. When a bitmap image is
scaled up you begin to see the individual pixels that make up the image. This is most
noticeable in the edges of the image. There are ways of making these jagged edges
less noticeable but this often results in making the image blurry as well. When a vector
image is scaled up, the image is redrawn using the mathematical formula, so the
resulting image is just as smooth as the original.
The three most popular image formats used on the Web (PNG, JPEG, and GIF) are
bitmap formats. The Scalable Vector Graphics (SVG) format comes in a distant fourth
due to a legacy of poor support for vector graphics in early browsers. Today however,
all major browsers support the SVG (Scalable Vector Graphics) format.
Bitmap formats are best for images that need to have a wide range of color gradations,
such as most photographs. Vector formats, on the other hand, are better for images that
consist of a few areas of solid color. Examples of images that are well suited for the
vector format include logos and type.
We do not need to consider how an image of this type would be created. We do need to
consider how the data is stored after the image has been created.
Drawing list: - a set of commands used to define a vector image. A vector graphic
file contains a drawing list. The list contains a command for each object included in the
image.
Each command has a list of attributes that define the properties of the object.
Drawing Properties: -The properties include the basic geometric data such as, for
a circle, the position of the centre and its radius. In addition properties such as the
thickness and style of a line, the colour of a line and the colour that fills the shape, if that
is appropriate, are defined. An example of what could be created as a vector graphic file
is shown in Figure.
The most important property of a vector graphic image is that the dimensions of the
objects are not defined explicitly but instead are defined relative to an imaginary
drawing canvas. In other words, the image is scalable.
Whenever the image is to be displayed the file is read, the appropriate calculations are
made and the objects are drawn to a suitable scale. If the user then requests that the
image is redrawn at a larger scale the file is read again and another set of calculations
are made before the image is displayed. This process cannot of itself cause distortion of
the image.
This image illustrates the difference between bitmap and vector images. The bitmap
image is composed of a fixed set of dots (pixels), while the vector image is composed of
a fixed set of shapes. In the picture, scaling the bitmap reveals the pixels and scaling
the vector image preserves the shapes.
Syllabus Content:
1.1.3 Sound
show understanding of how sound is represented and encoded
use the associated terminology: sampling, sampling rate, sampling resolution
show understanding of how file sizes depend on sampling rate and sampling
resolution
understanding of how typical features found in sound editing software are used in
practice
(1.1.3) Sound:
Sound is an oscillation of pressure transmitted through a solid, liquid, or gas (there is no
sound in outer space as space is a vacuum and there is no solid, liquid or gas to
transmit sound through!). A speaker works by moving its center cone in and out; this
causes the air particles to bunch together forming waves. These waves spread out from
the speaker travelling at 340 m/s. If your ear is in the way, then the waves of sound
particles will collide with your ear drum, vibrating it and sending a message to your
brain. This is how you hear:
Natural sound consists of variations in pressure which is detected by the human ear. A
typical sound contains a large number of individual waves each with a defined
frequency. The result is a wave form in which the amplitude of the sound varies in a
continuous but irregular pattern.
If there is a need to store sound or transmit it electronically the original analogue sound
signal has to be converted to a binary code.
A sound encoder has two components.
1. Band limiting Filter
2. Analogue to digital converter.
Band-limiting filter:
This is needed to remove high-frequency components. The ear would not be able to
detect these and they could cause problems for the coding if not removed.
The method of operation of the ADC is described with reference to Figure. The
amplitude of the wave (the red line) has to be sampled at regular intervals. The blue
vertical lines indicate the sampling times. The amplitude cannot be measured exactly;
instead the amplitude is approximated by the closest of the defined amplitudes
represented by the horizontal lines. In Figure 1.08, sample values 1 and 4 will be an
accurate estimate of the actual amplitude because the wave is touching an amplitude
line. In contrast, samples 5 and 6 will not be accurate because the actual amplitude is
approximately half way between the two closest defined values.
Once in a digital format you can edit sounds with programs such as audacity.
To play digital audio you convert the sound from digital values into analogue electrical
signals using the
DAC, these signals are then passed to a speaker that vibrating the speaker cone,
moving the air to create sound waves and analogue noise.
Digital audio: Sounds created on a computer exist as digital information encoded as audio
files.
This section will cover how we record, store and transmit sound using computers.
Sound waves in nature are continuous, this means they have an almost infinite amount
of detail that you could store for even the shortest sound. This makes them very difficult
to record perfectly, as computers can only store discrete data, data that has a limited
number of data points
Audio Bandwidth:
Bandwidth is the ability of a recorded signal to be reproduced at varying degrees of
resolution. Think of it like enlarging a low-resolution image versus a high-resolution
image. After a certain point, enlarging a lower-resolution image will become pixelated
and difficult to see, where the hi-resolution image will resize clearly.
Like images, audio signals can have a limited bandwidth if recorded digitally. Once a
digital recording is made, the bandwidth is set in place.
Digital sound is broken down into thousands of samples per second. Each sound
sample is stored as binary data.
Digital audio quality Factors that affect the quality of digital audio include:
sample resolution/ bit depth: - the number of bits assigned to each sample of sound
bit rate - the number of bits used to store one second of sound
Sound Sampling:
amplitude of sound wave taken at different points in time
measurement of value of analogue signal at regular time intervals/a point in time
Sample rate
The sample rate is how many samples, or measurements, of the sound are taken each
second.
The more samples that are taken, the more detail about where the waves rise and fall is
recorded and the higher the quality of the audio. Also, the shape of the sound wave is
captured more accurately.
Each sample represents the amplitude of the digital signal at a specific point in time.
The amplitude is stored as either an integer or a floating point number and encoded
as a binary number.
Sound Sampling
So we should know by now that sound waves are continuous and computers can only
store discrete data. How exactly does an Analogue to Digital Converter convert a
continuous sound wave into discrete digital data? To do this we need to look at how
computers sample sound.
A higher sampling rate means the waveform will be converted from analog to digital
form more accurately.
The quality of a sound produced using a sound sampler depends on the sampling rate
and sampling resolution.
The higher the sampling resolution (bit depth), the higher the quality of the audio.
Higher sampling rate/resolution means larger file size
A typical, uncompressed high-quality audio file has a sample rate of 44,100 samples per
second, a sample resolution (bit depth) of 16 bits per sample and 2 channels of stereo
audio. The bit rate for this file would be:
44,100 samples per second × 16 bits per sample × 2 channels = 1,411,200 bits per
second (or 1,411.2 kbps)
A four-minute (240 second) song at this bit rate would create a file size of:
A common audio sample rate for music is 44,100 samples per second. The unit for
the sample rate is hertz (Hz). 44,100 samples per second is 44,100 hertz or 44.1
kilohertz (kHz).
Telephone networks and VOIP services can use a sample rate as low as 8 kHz. This
uses less data to represent the audio. At 8 kHz, the human voice can still be heard
clearly - but music at this sample rate would sound low quality.
Compression
Compression is a useful tool for reducing file sizes. When images, sounds or videos are
compressed, data is removed to reduce the file size. This is very helpful
when streaming and downloadingfiles.
Streamed music and downloadable files, such as MP3s, are usually between
128 kbps and 320 kbps - much lower than the 1,411 kbps of an uncompressed file.
Videos are also compressed when they are streamed over a network.
Streaming HD video requires a high-speed internet connection. Without it, the user
would experience buffering and regular drops in quality. HD video is usually around
3 mbps. SD is around 1,500 kbps.
Lossless compression:
Lossless compression means that as the file size is compressed, the audio quality
remains the same - it does not get worse. Also, the file can be restored back to its
original state. FLAC and ALAC are open source lossless compression formats.
Lossless compression can reduce file sizes by up to 50% without losing quality.
Run-length encoding: compression in which sequences with same data value in many
consecutive values are stored as a single data value and count
Lossy compression:
Lossy compression permanently removes data. For example, a WAV file
compressed to an MP3 would be lossy compression. The bit rate could be set at 64
kbps, which would reduce the size and quality of the file. However, it would not be
possible to recreate a 1,411 kbps quality file from a 64 kbps MP3.
With lossy compression, the original bit depth is reduced to remove data and reduce the
file size. The bit depth becomes variable.
MP3 and AAC are lossy compressed audio file formats widely supported on different
platforms. MP3 and AAC are both patented codecs. Ogg Vorbis is an open source
alternative for lossy compression.
Lossy Compression is in which file accuracy is low, but file size is smaller than
lossless
Perceptual coding: works by reducing certain parts of a sound which are less audible
to human hearing.
Sound Editing
Simply recording sound and storing a digital representation is not enough for many
applications.
Once a digital representation of the sound has been stored in a file, it can be
manipulated using sound-editing software. This will typically have features for:
If you are interested in sound editing you can start editing your own music using a
program called Audacity.
Using Audacity you can create your own sound samples with different sample rates and
sample resolutions, listening to the difference between them and noting the different file
sizes.
Features
This is a list of features in Audacity, the free, open source, cross-platform audio editor.
Recording
Audacity can record live audio through a microphone or mixer, or digitize recordings
from cassette tapes, records or minidiscs. With some sound cards, and on any
Windows Vista, Windows 7 or Windows 8 machine,
Audacity can also capture streaming audio.
Sound Quality
Supports 16-bit, 24-bit and 32-bit (floating point) samples (the latter preserves samples
in excess of full scale).
Sample rates and formats are converted using high-quality re-sampling and dithering.
Tracks with different sample rates or formats are converted automatically in real time.
Editing:
Easy editing with Cut, Copy, Paste and Delete.
Unlimited sequential Undo (and Redo) to go back any number of steps.
Edit and mix large numbers of tracks.
Multiple clips are allowed per track.
Label tracks with selectable Sync-Lock Tracks feature for keeping tracks and
labels synchronized.
Draw Tool to alter individual sample points.
Envelope Tool to fade the volume up or down smoothly.
Automatic Crash Recovery in the event of abnormal program termination.
Accessibility
Tracks and selections can be fully manipulated using the keyboard.
Large range of keyboard shortcuts.
Excellent support for JAWS, NVDA and other screen readers on Windows, and
for VoiceOver on Mac.
Effects
Change the pitch without altering the tempo (or vice-versa).
Remove static, hiss, hum or other constant background noises.
Alter frequencies with Equalization, Bass and Treble, High/Low Pass and Notch
Filter effects.
Adjust volume with Compressor, Amplify, Normalize, Fade In/Fade Out and
Adjustable Fade effects.
Remove Vocals from suitable stereo tracks.
Create voice-overs for podcasts or DJ sets using Auto Duck effect. Other built-in
effects include:
Echo
Paulstretch (extreme stretch)
Phaser
Reverb
Reverse
Truncate Silence
Wahwah.
Run "Chains" of effects on a project or multiple files in Batch Processing mode.
Syllabus Content:
1.1.4 Video
Show understanding of the characteristics of video streams:
o the frame rate (frames/second)
o interlaced and progressive encoding
o video interframe compression algorithms and spatial and temporal
redundancy
o multimedia container formats
1.1.5 Compression techniques
show understanding of how digital data can be compressed, using either ‘lossless’
(including runlength encoding – RLE) or ‘lossy’ techniques
Video is an electronic medium for the recording, copying and broadcasting of moving
visual images characteristics of video streams.
The emphasis here is on the visual aspect of a video recording and, in particular, how
the image is displayed on a screen.
Video is not stored very simply as a succession of still images or frames and the only
concern would be the frame rate defined as the number of frames displayed per
second.
Interlaced encoding:
The data from a single frame are encoded as two separate fields.
One containing the data for the even numbered rows / lines and the other has the
data for the odd numbered rows / lines.
The image is rendered by alternating between the even field and the odd field (of
each successive frame).
The viewer sees data from two frames simultaneously
The rate of picture display (the field rate) is twice the rate of image frame display
(the frame rate).
Originally used in television broadcasting and adapted for video recordings.
Produces what appears to the eye to be a high refresh rate.
Halves the transmission bandwidth requirements.
Progressive encoding
Stores the data for an entire frame and displays all the frame data at the same time.
The rate of picture display is the same as the frame rate.
Used by traditional film / video digitised from a film camera / computer displays
progressive encoding.
High bandwidth requirements.
Frame rate, the number of still pictures per unit of time of video, ranges from six or eight
frames per second (frame/s) for old mechanical cameras to 120 or more frames per
second for new professional cameras.
PAL (Europe, Asia, Australia, etc.) and SECAM (France, Russia, parts of Africa
etc.) standards specify 25 frame/s,
NTSC (USA, Canada, Japan, etc.) specifies 29.97 frame/s.
Film is shot at the slower frame rate of 24 photograms/s, which complicates
slightly the process of transferring a cinematic motion picture to video.
The minimum frame rate to achieve a comfortable illusion of a moving images about
sixteen frames per second.
Inter-frame compression:
Spatial redundancy: elements that are duplicated within a structure, such as pixels in a
still image and bit patterns in a file. Exploiting spatial redundancy is how compression is
performed.
Temporal redundancy: pixels in two video frames that have the same values in the
same location. Exploiting temporal redundancy is one of the primary techniques in video
compression.
In MPEG, where temporal compression is used, the current picture/ object is not sent in
its entirety; instead the difference between the current picture/object and the previous
one is sent. The decoder already has the previous picture/object, and so it can add the
difference, or residual image, to make the current picture/object. A residual image is
created by subtracting every pixel in one picture/object from the corresponding pixel in
another. This is trivially easy when pictures are restricted to progressive scan, as in
MPEG-1, but MPEG-2 had to develop greater complexity (continued in MPEG-4) so that
this can also be done with interlaced pictures. The handling of interlace in MPEG will be
detailed later.
Figure 5.18: (a) Spatial or intra-coding works on individual images. (b) Temporal or
inter-coding works on successive images. (c) In MPEG inter-coding is used to create
difference images. These are then compressed spatially.
A residual is an image of a kind, although not a viewable one, and so should contain
some kind of spatial redundancy. Figure 5.18(c) shows that MPEG takes advantage of
both forms of redundancy. Residual images are spatially compressed prior...
Temporal redundancy:
Pixels in two video frames that have the same values in the same location. Exploiting
temporal redundancy is one of the primary techniques in video compression.
Spatial redundancy:
Elements that are duplicated within a structure, such as pixels in a still image and bit
patterns in a file. Exploiting spatial redundancy is how compression is performed.
Contrast with temporal redundancy.
References:
www.wikipedia.com
https://en.wikipedia.org/wiki/Vector_graphics
https://en.wikipedia.org/wiki/File:Bitmap_VS_SVG.svg
https://www.corporate3design.com/blog/112/
http://etc.usf.edu/techease/win/images/what-is-the-difference-between-bitmap-and-
vector-images/
https://www.klipsch.com/blog/digital-vs-analog-audio
https://www.bbc.com/education/guides/z7vc7ty/revision/2
http://www.globalspec.com/reference/37829/203279/5-7-spatial-and-temporal-
redundancy-in-mpeg
https://robbfoxx.wordpress.com/2015/07/12/discussion-6-2-1-what-is-redundancy-
temporal-redundancy-and-spatial-redundancy/
http://www.pcmag.com/encyclopedia/term/56086/spatial-redundancy
http://christmanwd.weebly.com/uploads/2/5/9/5/25956852/805063_orig.jpg