slide 1 bitmapped graphic data. slide 2 hardware – ccd charge-coupled device (ccd) a ccd is a...
TRANSCRIPT
Slide 1
Bitmapped Graphic Data
Slide 2
Hardware – CCD
Charge-Coupled Device (CCD)A CCD is a device containing grids of pixels that are used in scanners, digital cameras and digital video cameras as light-sensing devices.
Bit
map
ped
Gra
ph
ic D
ata
Slide 3
Hardware – CCD
An image is projected by a lens onto a 2D rectangular array of CCD image sensors causing each sensor to store light that representing the image.
Each sensor stores the light for a single pixel so the more CCDs the higher the resolution of the image.
An ADC is used to convert the signal to digital and a binary value for each CCD sensor is stored.
Bit
map
ped
Gra
ph
ic D
ata
Slide 4
Hardware – Digital Camera
Digital cameras
• Have a 2D rectangular array of CCD sensors to capture the image
• Each CCD sensor captures the light for roughly one pixel
• Therefore the more CCDs the higher the resolution of the image
• The CCD converts the light into an electrical signal i.e. a voltage
• An ADC is used to convert the signal to a digital signal
• Now the image can be stored on the computer in digital form
Bit
map
ped
Gra
ph
ic D
ata
Slide 5
Capturing photo-images/video
Sequence of events
Bit
map
ped
Gra
ph
ic D
ata
DSP
Storage
Image
Lens
CCD
ADC
1 Select IMAGE
2 Image is directed through LENS
3 Light attracted to CCD sensors
4 Pass analogue signal through ADC chip
5 Apply signal processing via DSP
6 Store on backing storage
Slide 6
Hardware – Scanner
Scanner
• Hard copy of image is scanned
• Light is reflected onto light-sensitive diodes that translate the light into a voltage
• An ADC converter translates each voltage into a digital pixel
• Pixel data is transferred to a software application the data can be read from
Bit
map
ped
Gra
ph
ic D
ata
Slide 7
Role of ADCB
itm
ap
ped
Gra
ph
ic D
ata
When an electrical signal is received from the CCD it needs to be converted to a digital signal by an Analogue to Digital Converter chip.
Slide 8
Storage of graphic dataB
itm
ap
ped
Gra
ph
ic D
ata
BitmapsThe entire image is stored as an ordered map of binary codes that represent the individual colour of each pixel.
The size of each binary value is known as the colour (bit) depth.
We can easily work out how many colours can be represented:
Examples
Bit depth is 1 bit: 21 => 2x1 = 2 coloursBit depth is 2 bits: 22 => 2x2 = 4 coloursBit depth is 3 bits: 23 => 2x2x2 = 8 colours…Bit depth is 8 bits: 28 = 2x2x2x2x2x2x2x2 = 256 colours
Number of colours = 2 bit depth
So, a bitmap that has 16 colours means a bit depth of 4 bits!
Slide 9
Storage of graphic dataB
itm
ap
ped
Gra
ph
ic D
ata
Indexed ColourColours available are indexed in an array that acts as a ‘palette’ of available colours - known as a Colour Lookup Table (CLUT).
Each pixel stores the index to the array (palette) for the colour shade required rather than the actual binary colour code. These tables typically store 4, 16, or 256 distinct colours.
Advantage: Indexed Colour reduces file/memory size and transfer times.
Disadvantage: Limited number of distinct colours.
Slide 10
Storage of graphic dataB
itm
ap
ped
Gra
ph
ic D
ata
Indexed Colour Examples
4 colours
256 colours
16 colours
24 bits
Slide 11
Bit
map
ped
Gra
ph
ic D
ata
Each pixel actually consists of three smaller dots – one for each of the primary colours, which in electronics are Red, Green and Blue.
Green 0-255
Red 0-255
Blue 0-255
In 24-bit colour each of the primary colours has a byte (8 bits) allocated to store the colour shade so there are 16, 777, 216 possible shades.
Note: A colour lookup table is not needed as the bitmap stores the actual 24-bit colour code.
24-bit BitmapA set of 3 bytes (24 bits) represents the colour of each pixel, known as the RGB Colour Code.
Storage of graphic data
Slide 12
Bit
map
ped
Gra
ph
ic D
ata
Storage of graphic data
Slide 13
Bit
map
ped
Gra
ph
ic D
ata
Hexadecimal and colour codes
Hex is a base 16 numbering system commonly used to represent RGB colour codes to reduce the number of digits to be worked with. Hex uses the digits:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Where A = 10, B =11, C = 12, D = 13, E = 14 and F = 15.
This example hex colour code #9900CC means the RGB mix for this shade is:
Red – 99 Green – 00 Blue - CC
And this converts nicely into binary and into decimal…..
Colour: Red Green Blue
Hex: 9 9 0 0 C C
Binary: 1 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0
Decimal: 153 0 204
Extension
Slide 14
Bit
map
ped
Gra
ph
ic D
ata
Hexadecimal and colour codes
In a Windows application you can enter the decimal values for Red, Green and Blue to customise and mix the colour shade you require.
Always remember though that the colour code will always be stored by the computer system as a 24-bit binary code!
Extension
Slide 15
Storage of graphic dataB
itm
ap
ped
Gra
ph
ic D
ata
Run Length Encoding (RLE)RLE is a simple lossless data compression algorithm. Sequences of repeating data (runs) are stored as a count and a single data value.
Example:
Before RLE: aaaaaaaaaabbaaaaaabbaaaaaaaaaabbaaaaaabb
After RLE: 10a2b6a2b10a2b6a2b
So original 40 characters reduced to 18 characters!
RLE and bitmapsRLE can be applied to bitmaps to reduce file size. It works best where there are solid blocks of colour and a count is made of the number of pixels in the run with the same colour code.
The length of each run is held in 1 byte so the maximum size of a run of colour is 255 repetitions.
Slide 16
Storage of graphic dataB
itm
ap
ped
Gra
ph
ic D
ata
Example – RLE and Bitmaps
A run of 10 x 10 pixels all shaded black with bit depth of 8 bits (1 byte).
RLE algorithm
Image Bitmap Compressed Bitmap
Original file: 100 bytes
Compressed file: 40 bytes
Slide 17
Storage of graphic dataB
itm
ap
ped
Gra
ph
ic D
ata
Graphics Interchange Format (GIF)Compressed using LZW lossless compression with a colour depth of 8-bits and a palette of 256 RGB colours.
Colour limitation means not suited to photographs but ideal for continuous colour blocks e.g. logos, clip-art etc.
GIF files can be stored as:
• Non-interlaced - each line of the image is drawn one after the other
• Interlaced - every alternate line or bit (fuzzy to sharp) is drawn and then the rest after.
GIF supports transparency and animation, usually 25 frames per second and with a separate 256 colour palette per frame.
Advantage: with interlaced the user can see the graphic build up and decide whether they want to view it before the full image is complete.
Slide 18
Interlacing in Action• Allows you to view an image before it is fully
downloaded• Image is gradually revealed
Slide 19
Storage of graphic dataB
itm
ap
ped
Gra
ph
ic D
ata
Lempel-Ziv-Welch (LZW)
A lossless data compression algorithm that is part of the GIF
format.
It stores repeated patterns of data in a dictionary/table and uses
pointers to point to the dictionary to obtain the colour code for the
pixels in the pattern.
Colour Pattern Dictionary Code
1
2
..
256
257
258
259
Converted to
258,259,258
Original Image
Slide 20
Storage of graphic dataB
itm
ap
ped
Gra
ph
ic D
ata
Portable Network Graphics (PNG)
Designed to replace GIF; uses lossless compression and up to 256 colours from
an RGB palette-indexed colour table (CLUT) or can be 24-bit RGB.
Parts of the image can be made
transparent i.e. a single pixel value or an
alpha channel.
Can be interlaced allowing a clearer low-
resolution image to be visible earlier in the
transfer.
PNGs are better than JPGs for storing photographs that require further editing.
Once finally edited, the PNG can be converted to JPEG to reduce file size.
However they are single-image so do not support animation.
Slide 21
Storage of graphic dataB
itm
ap
ped
Gra
ph
ic D
ata
Joint Photographic Expert Group (JPEG)A graphics format that uses lossy compression to cut out parts of the image that the human eye will not notice.
It supports 24-bit colour and is suited to graduated colours and textures so works well for photographs.
Advantage
Far superior to GIF, and preferable to PNG
as files sizes are smaller (due to lossy
compression) with very little loss of overall
quality.
Disadvantage
Suffers from generation loss i.e. the loss
of quality when editing after compression.
Does not support transparency
Slide 22
Bit
map
ped
Gra
ph
ic D
ata
How to calculate the number of pixels
ExampleAn image is 400 pixels by 400 pixels at 72 dpi. How many pixels in this image?
Solution
No. of pixels: 400 x 400 = 160,000 pixels
ExampleAn image is 2 x 3 inches at 2048 dpi. How many pixels in this image?
Solution
No. of pixels: 2048 x 2048 x 2 x 3 = 25,165,824 pixels
Slide 23
Bit
map
ped
Gra
ph
ic D
ata
How to calculate file size
ExampleAn image is 2 x 3 inches at 2048 dpi and has a colour depth of 24 bits.What is the file size of this image?
Formula
File size (bits) = resolution (pixels) x colour depth (bits)
8
Or
File size (bytes) = resolution (pixels) x colour depth (bytes)
Solution
No. of pixels: 2 x 3 x 2048 x 2048 = 25,165,824 pixels
Colour depth: 3 bytes
= 25,165,824 pixels x 3 bytes = 75,497,472 bytes
= 75,497,472 bytes / 1024 / 1024 = 72 Mbytes.
= 72 Mbytes File Size
Slide 24
Bit
map
ped
Gra
ph
ic D
ata
How to calculate colour depth
Example
An image is 2 x 3 inches at 2048 dpi and has a file size of exactly 72 Mb.
What is the colour depth of this image?
Formula
Colour depth (bits) = No. of bits
resolution (pixels)
Solution
No. of pixels: 2 x 3 x 2048 x 2048 = 25,165,824 pixels
No. of bits: 72 x 1024 x 1024 = 603,979,776 bits
= 603, 979, 776 bits / 25, 165, 625 pixels = 24 bits per pixel
= 24 bit colour depth
Slide 25
Bit
map
ped
Gra
ph
ic D
ata
Dithering
Dithering is a technique that creates an illusion of extra colours and shades by varying the pattern of dots. It has the effect of mixing colours together to improve the appearance or ‘gradation’ of colour.
The image below has bands of colour instead of a gradual transition between colours.
Dithering is the most common method of reducing the colour range of an image such as a JPEG down to 256 colours (or less) such as an 8-bit GIF.
Applying dithering reduces the banding effect.
Colours reduced Dithered
Slide 26
Dithering In Action
256 Colour 4 Colour Non-Dithered
4 Colour with Dithering
Slide 27
Bit
map
ped
Gra
ph
ic D
ata
Anti-aliasing
Anti-aliasing simulates extra resolution in an image to reduce its ‘blocky’ appearance.
Anti-aliasing shades pixels around an image using intermediate colours between the foreground and the background.
Before anti-aliasing After anti-aliasing Result
It has the effect of fooling the human eye into seeing straight lines and curves where there are none!
No anti-aliasing With anti-aliasingLets take a closer look:
Slide 28
Bit
map
ped
Gra
ph
ic D
ata
Anti-aliasing
Both pieces of text have exactly the same resolution
Slide 29
Bit
map
ped
Gra
ph
ic D
ata
Increase resolution - Resampling
It is possible to increase the resolution of a graphic by ‘resampling’ it and reducing the effect of pixellation. Resampling is the process of adding colour to the new pixels created when an image is enlarged.
ExampleA graphic, 100 x 100 pixels is rescaled by 400%, so now 400 x 400 pixels. Each pixel is replaced by 4 x 4 pixels so 16 times more of the same colour!
100 x 100 pixels 400 x 400 pixels After resampling
Scale by 400% Resample
Each additional pixel is given an individual and distinct colour which was found by calculating the average colour value of the four neighbouring pixels (a mathematical technique known as bicubic interpolation.).
However, resampling is only a kind of ‘guesstimate’ and image will quality will be lost. Better to capture the image at a higher resolution in the first place!!
Slide 30
Graphics cardsB
itm
ap
ped
Gra
ph
ic D
ata
Digital Signal Processing (DSP)
Processes the signal to remove
noise/distortion/allows the addition of
effects to be applied by the hardware.
Graphics Processing Unit (GPU)
A graphics card has its own GPU which can generate images faster and of better
quality than the main processor and frees the main CPU from the load e.g. 3-D
graphics require millions of calculations to be performed each time they are
drawn!
The graphics card has chips that convert
analogue signals to digital signals, known as
ADC / DAC.