Presentation is loading. Please wait.

Presentation is loading. Please wait.

How pictures are stored in computers. While it is useful to know how to use picture editing software, Computer Scientists should understand how pictures.

Similar presentations


Presentation on theme: "How pictures are stored in computers. While it is useful to know how to use picture editing software, Computer Scientists should understand how pictures."— Presentation transcript:

1 How pictures are stored in computers

2 While it is useful to know how to use picture editing software, Computer Scientists should understand how pictures are stored in computers This is important in its own right But it will also be important when you start writing programs in PHP to create pictures In what follows, you will –learn something about the format of image files –discover that picture editing software can contain bugs –discover that many programs do not adhere strictly to the image format standards

3 How pictures are stored in computers Understanding computer storage of pictures involves several main points: a picture is a collection of dots, called pixels the colour of each dot in a picture must be stored any colour can be represented as a mixture of certain proportions of red, green and blue in computers, all information is stored as a sequence of zeros and ones there is frequently a lot of repetition in a picture, so the zeros and ones can often be compressed

4 Representation of information as zeros and ones In computers, all information is stored as a sequence of zeros and ones –since only two symbols are used, this is called binary representation the Latin prefix, bi-, means two Why are only two symbols used? Because most forms of electronic storage device have only two easily-distinguishable states A clear example can be seen by looking at early computer technology

5 The CDC 6600 computer designed by Seymour Cray first delivered in 1964 was considered a "supercomputer" –three times faster than the fastest computer before it cost $10 million each –at a time when a 3- bedroom house in Ireland cost about $2500 –so it cost the same as 4000 houses

6 CDC 6600 memory Memory boards from a CDC 6600 computer Let's look more closely

7 A single memory board

8 Closer view of a CDC 600 memory board Memory boards were then called "mats" It's easy to see why A mat consisted of wires woven through rings Each ring was called a core

9 Closer view (of a different board) Each core was several millimetres in diameter

10 Core memory was used for a long time Core memory was developed around 1950 It was the fastest memory available until the late 1980s

11 Why cores were used Each core was actually a circular magnet

12 Why cores were used A core could be magnetized in one of two directions, clockwise or anti- clockwise

13 Two states means only two values These two direction could be used to represent two different symbols –Clockwise, say, can represent a 0, –while anti-clockwise can represent a 1

14 How cores are magnetized The direction of magnetization in a core can be changed by temporarily running a current along a wire that runs through the core

15 Direction of current The final direction of magnetization in the core depends on the direction of the current along the wire

16 Threshold current To change the direction of magnetization in a core the current must exceed a threshold current, I

17 Threshold current If the current is less than the threshold current, the state of the core is not changed

18 How cores were controlled It's worth seeing how individual cores in a mat were controlled Similar principles are still used in newer memory technologies

19 Several wires through each core There were actually three wires running through each core Two wires ran in each of two perpendicular directions –These are called the address wires The third wire ran diagonally –this is called the sense wire

20 Wires in a core mat The perpendicular and diagonal wires on a core-memory mat from 1951

21 Selecting (addressing) a specific core The fact that the current must exceed a threshold is used to select the core we want to change To change a specific core, we send half the threshold current along each of the two address wires that pass through the target core

22 How to write information into a core To achieve a specific state in the core, –we send the currents in a specific direction One direction creates 0 The other direction creates 1

23 How to read from a core To read a core, we set it to 0 and see if that causes a pulse along the sense wire Then, if necessary, we reset the core to the correct value If the core originally contained 0, we need to do nothing But if the core originally contained 1, we must write that 1 back into the core

24 Memory locations The address wires run in two perpendicular directions One direction, say the horizontal, is more significant than the other Each wire in this direction selects a group of cores that belong to one memory location Wires in the other direction can select individual bits in the location

25 Sizes of memory location Early computers had locations of different sizes In the top board shown here, each location had 16 bits In the bottom board, each location had 8 bits In most (all?) modern computers, each memory location has 8 bits A group of 8 bits is called a byte So modern computer memory is what is called byte-addressable

26 Contents of a memory byte A memory byte can contain 256 different patterns, ranging from 00000000 to 11111111

27 Contents of a memory byte It is easier to write a byte pattern as two groups of four bits, with a space in the middle So, a memory byte can contain 256 different patterns, ranging from 0000 0000 to 1111 1111

28 Shorthand notation A group of 4 bits is sometimes called a nibble A nibble can contain 16 different patterns

29 Shorthand notation A group of 4 bits is sometimes called a nibble A nibble can contain 16 different patterns It is common to use a shorthand notation for these 16 different patterns

30 Shorthand notation A group of 4 bits is sometimes called a nibble A nibble can contain 16 different patterns It is common to use a shorthand notation for these 16 different patterns This notation is called hexadecimal notation

31 Shorthand notation for bytes So, a byte can contains 256 different hexadecimal patterns, ranging from

32 Shorthand notation for bytes So, a byte can contains 256 different hexadecimal patterns, ranging from 00 to FF

33 Image files Binary representation is not confined to the internal memory of a computer It is also used in files that are stored on disks So, image files also use binary representation We can see this by using a program which shows us the raw contents of an image file

34 Hex editors A hex editor is a program which can be used to examine and edit the raw contents of any file on a computer disk They are called hex editors because they display the contents of the file using hexadecimal notation We will use a freely-available hex editor called XVI32 But many others are available

35 An example image file Consider the following file: http://www.cs.ucc.ie/j.bowen/cs1107/imageFormats/test.bmp It is in the BMP format - the Windows bitmap format It was created using PhotoShop, not PhotoPlus –as we will see later, this is not unimportant We will examine this file with XVI32 But, first, let's see what image the file contains Download the file to your computer And open it in PhotoPlus

36 test.bmp It is a very small image

37 test.bmp Use menu Image -> Image Size to check the size

38 test.bmp It is 4 pixels wide by 4 pixels high

39 test.bmp Even though the picture contains only 16 pixels, the file is quite big –it contains 1,094 bytes

40 Using XVI32 to examine test.bmp XVI32 is on your workstation desktop

41 Using XVI32 The initial display, when no file has been opened

42 Viewing test.bmp in XVI32 The display when test.bmp has been opened

43 Viewing test.bmp in XVI32 The display when test.bmp has been opened

44 Viewing test.bmp in XVI32 The highlighted area is used to show the binary contents of the file Each byte is shown in hexadecimal notation

45 Viewing test.bmp in XVI32 Consider the first byte in the file, byte 0 It contains 42 hex That is 0100 0010

46 Viewing test.bmp in XVI32 Consider the fortieth byte in the file, byte 28 hex It contains 0B hex That is 0000 1011

47 Viewing test.bmp in XVI32 The highlighted area gives a different view of the contents of the file It interprets the bytes as characters using the ASCII code

48 The ASCII code interprets a byte as one 256 different characters This slide shows the first 128 of these

49 The ASCII code interprets a byte as one 256 different characters This slide shows the second 128 of these

50 Viewing test.bmp in XVI32 The first three bytes in the file contain 42 hex 4D hex 46 hex If these were interpreted as ASCI character codes, they would represent BMF However, most of the time, we will not be interested in the ASCII interpretations


Download ppt "How pictures are stored in computers. While it is useful to know how to use picture editing software, Computer Scientists should understand how pictures."

Similar presentations


Ads by Google