Data Representation Storing Images jamiedrfrostmaths com www drfrostmaths

  • Slides: 15
Download presentation
Data Representation : : Storing Images jamie@drfrostmaths. com www. drfrostmaths. com @Dr. Frost. Maths

Data Representation : : Storing Images jamie@drfrostmaths. com www. drfrostmaths. com @Dr. Frost. Maths Last modified: 16 th July 2019

www. drfrostmaths. com Registering on the Dr. Frost. Maths platform allows you to save

www. drfrostmaths. com Registering on the Dr. Frost. Maths platform allows you to save all the code and progress in the various Computer Science mini-tasks. It also gives you access to the maths platform allowing you to practise GCSE and A Level questions from Edexcel, OCR and AQA. Everything is completely free. Why not register? With Computer Science questions by: Your code on any mini-tasks will be preserved. Note: The Tiffin/DFM Computer Science course uses Java. Script as its core language. Most code examples are therefore in Java. Script. Using these slides: Green question boxes can be clicked while in Presentation mode to reveal. ? Slides are intentionally designed to double up as revision notes for students, while being optimised for classroom usage. The Mini-Tasks on the DFM platform are purposely ordered to correspond to these slides, giving your flexibility over your lesson structure.

 Learning Objectives Directly from the OCR specification:

Learning Objectives Directly from the OCR specification:

RECAP : : Binary If you haven’t learnt about converting numbers to/from binary, it

RECAP : : Binary If you haven’t learnt about converting numbers to/from binary, it is recommended you look at the Binary/Hexadecimal resource first before continuing with this topic. Binary Denary/Decimal 100 4 1010 ? Recall that the right-most bit is worth 1, the next left 2, the next 4, then 8, and so on. So we have 4 + 0 = 4 ? Find the highest power of 2 that is less than 10 (which is 8). Then see if we want each power of 2 less than that: • We do want the 8 (so first binary digit is 1), leaving 2 left to make up. • We don’t want the 4 (so 0) • We do want the 2 (so 1) • We don’t want the 1 (so 0) 10 1101 13 10001 ? 17 ? ?

 Types of Images There are two main types of image formats: Vector image

Types of Images There are two main types of image formats: Vector image Bitmap These store images by a grid ? What is it of pixels (i. e. square dots). Type file formats Advantages Disadvantages ? Simplementation, ? more suitable for photos. png, jpg, bmp Image becomes ‘pixelated’ (i. e. blocky) when we zoom in. ? Image represented exactly using 2 D ? What is it points connected with lines/polygons. ? Type file formats svg, eps Advantages Can represent lines/polygons in an exact way – quality is maintained when you zoom in. Disadvantages Can convert vector images to bitmap (known as ‘rasterising’ but the other way round is difficult! ? ?

 More on Vector Images Animated Movies We can output movie stills at any

More on Vector Images Animated Movies We can output movie stills at any image size. There will only be blockiness if any of the textures used on 3 D surfaces are bitmaps. Up © Disney/Pixar PDFs Any diagrams, text and mathematical notation will be vector information. Fonts in general can be made arbitrarily large in size whilst remaining smooth. Where are they used? These Power. Point slides! If you were to zoom into the oval in the middle, the would no loss in smoothness in the curve. Adobe Photoshop If you save as a normal Photoshop project rather than output as a bitmap (e. g. png), all shape data is preserved. CAD (Computer Aided Design) images This is Dr Frost’s house!

 More on bitmaps Bitmap images are just represented as a long list of

More on bitmaps Bitmap images are just represented as a long list of bits. The colour depth is the number of bits used for each pixel. 0 0 0 0 1 1 1 1 0 0 0 0

 Increasing the bit depth… ? 00 00 11 01 01 11 00 01

Increasing the bit depth… ? 00 00 11 01 01 11 00 01 11 10 10 11 01 00 11 11 00 00 10 11 11 10 00 00 00 10 10 00 00 bpp stands for ‘bits per pixel’.

 24 bit-depth ? Our eyes can only say around 10 million different colours,

24 bit-depth ? Our eyes can only say around 10 million different colours, so this seems appropriate. We use 8 bits to represent the amount of red, green and blue light for each pixel respectively. We previously saw that 8 bits can be represented using 2 hexadecimal characters: Hex R G B Bits FF 80 00 255 128 0 1111 10000000 ? 0000 161 99 00100000 10100001 ? 01100011 ? 40 A 1 63 64 ? ? ?

 Opacity (Not in GCSE syllabus) In addition to R (Red), G (Green) and

Opacity (Not in GCSE syllabus) In addition to R (Red), G (Green) and B (Blue) we also have A (Alpha), which is the opacity of the pixel. 255 Fully opaque. Colour appears as normal 128 Some transparency, so we’d slightly see whatever image is behind, but red tinted. 0 Fully transparent. We’d see whatever is behind the image. Background black when mouse hovers over. Transparency is useful for non-rectangular web icons where we want the page background to be seen behind the image. This adds a further 8 bits, so the bit depth becomes 32 bits. The RGBA colour model is supported by png and gif but not by jpg.

 Resolution The resolution of an image is the density of pixels. Dots per

Resolution The resolution of an image is the density of pixels. Dots per inch (dpi) is how many pixels can be fit along an inch. ? 3 dpi So there’s 2 factors which affect the image size: • The bit depth, i. e. bits required for each pixel’s colour information. • The resolution (e. g. in dpi) of the image Increasing either leads to better image quality, at the expense of a larger file size.

 Image Metadata means ‘data about data’. In the case of images, it’s additional

Image Metadata means ‘data about data’. In the case of images, it’s additional data that tells us how to interpret the list of bits that we’ve used to represent the pixels of an image. Possibility 2 Possibility 1 000000010010011110 For example. Suppose we had these 18 bits for our image pixels. How could we interpret them? The bit depth is 1 (thus 18 pixels), which we arrange into a 6 by 3 grid. 0 0 0 0 1 1 0 The bit depth is 2 (thus 9 pixels), which we arrange into a 3 by 3 grid. 00 00 00 01 00 10 01 11 10 So our ‘metadata’ should contain at least the bit depth and the dimensions (width and height) to avoid such ambiguity.

 Image Metadata Image file Metadata Dimensions Filename Resolution Camera info Time last modified

Image Metadata Image file Metadata Dimensions Filename Resolution Camera info Time last modified GPS data Bit depth File format Pixel bits 01010100010110111000111… On Windows for example you can access the meta data by right-clicking the file and choosing ‘Properties’, and then the ‘Details’ tab.

 Exam Question ? ? We haven’t done this yet. ?

Exam Question ? ? We haven’t done this yet. ?

Coding Mini-Tasks Return to the Dr. Frost. Maths site to complete the various tasks

Coding Mini-Tasks Return to the Dr. Frost. Maths site to complete the various tasks on storing images.