390 likes | 544 Views
What we’ll cover for Part 2 : Representing concepts in a computer 1st type: Numeric values --brief review Today: How are some of the other concepts represented in the box ?. Representing Concepts Part 2--. 1234.
E N D
What we’ll cover for Part 2 : Representing concepts in a computer 1st type: Numeric values --brief review Today: How are some of the other concepts represented in the box? Representing Concepts Part 2-- 1234
Information theory:Study of the most efficient way to encode concepts:information that interests us. All information must be captured & stored, processed, and transmitted. Using numbers to represent information allows us to use a discrete symbol system: distinct, unambiguous, precise. Discrete numbers are much easier to engineer than continuous numbers. Quick review of Part 1: • How do we represent numeric values such as 1378 or 17.2351 in a computer? • Logical structure? Physical structure? • Mathematical operations (add, subtract, multiply, divide) operate on numeric information.
Digression: Binary Addition • Rules • 0 + 0 = 0 • 1 + 0 = 0 + 1 = 1 • 1 + 1 = 1 0 1 Carry: 1 1 1 0 1 1base 2 1 1 1 1base 2 1 0 0 1 1 Sum:
Representing characters • A - Za - z0 - 9! @ # $ % ^ & * ( ) + = • Must work with binary coding schemes (why?) • Digression:the program determines if a stored bit pattern represents a numericvalue, or an alphanumerictext, or part of a sound, or part of a picture, or part of an instruction..... • With unique bit patterns, we can represent any character (including foreign characters), just the way we already used unique bit patterns to represent decimal values……
Another digression: • However: Bit patterns that represent characters (alphanumeric) are typically not used used for mathematical computations like add or subtract. • Instead: alphanumeric characters are mostly used to store textual content, which may be sorted or concatenated. • So: although both numeric values (used for counting & math) and alphanumeric characters (used for text) are both represented using a bit pattern, they are treated differently.
Consider: • Numbercharacters (alphanumeric) are treated by the computer as text characters: • 9 not= “9” • 9 + 9 = 18 while “9” + “9” = “99” The Binary pattern that represents 9 is different from the binary pattern that represents “9”. • yet sorting is possible because text characters also have a binary (numeric) value: The numericvalue of the binary representation of a is smaller than b and also b is smaller than c and so on …
128 64 32 16 8 4 2 1 “Place” “0” 0 1 0 1 0 0 0 0 “1” 0 1 0 1 0 0 0 1 “2” 0 1 0 1 0 0 1 0 “A” 0 1 0 0 0 0 0 1 “B” 0 1 0 0 0 0 1 0 “C” 0 1 0 0 0 0 1 1 Letter B in binary code Letter B “in the box” How to represent C ??? NOTICE how A < B < C ……
Decimal value 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Bit pattern 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Number of symbols possible Remember? x bits could represent 2xnumbers 2 bits 22 = 4 different bit patterns 4 bits? 16 different [24 = 16] SAME THING when representingalphanumeric characters: A two-bit code (two bulbs) can represent (e.g. encode) fouruniquecharacters.
22 = 4 Base # bits = number of unique combinations (that represent values) A = 1 1 0 0 1 1 0 0 B = = C = D
LOGICAL Representation (bit coding scheme): Bit pattern length Base# of bits used=number of unique symbols the coding scheme can represent #-of-States#of bulbs= number of unique symbols the bulbs can represent CORRESPONDS DIRECTLY to the PHYSICAL Representation (hardware “bits”): How many bulbs (switches, transistors, vacuum tubes, magnetized locationson disk, ...)
2 2 0 2 1 1 0 0 1 2 0 1 1 1 2 2 0 0 G = = A D = = H B = E = F = = C I = 32 = 9 combinations What if we use more expensive light bulbs? OFF LOW HIGH QUICK! Would that allow us to represent/encode MORE or LESS unique things? WHY? (assume will use only 2 bulbs) Then what has changed?Nothow many bulbs, but what? #-of-States# of bulbs = number of unique combinations; which indicates number of unique values the bulbs can represent
What if we don’t want to use complicated bulbs---how else can we INCREASE how many things can be represented?? A = D = G = 0 0 0 0 1 1 1 1 0 B = E = H? = 0 0 1 1 0 0 1 1 1 C = F = 23 =8 combinations 0 1 0 1 0 1 So, base (# of states) is two:(0 , 1) (off , on) NOW whatMUST change? #-of-States# of bulbs=number of unique combinations; which indicates number of unique things the bulbs can represent Base# of bits used=number of unique things the coding scheme can represent
22 = 4 combinations 23 = 8 “ 24 = 16 “ 25 = 32 “ 26 = 64 “ 27 = 128 “ 28 = 256 “ 216= 65536 “ .... .... So, to get more things represented, we just keep adding bits (or light bulbs)
Bit pattern 0101 0000 0101 0001 0101 0010 0101 0011 (etc) 0100 0001 0100 0010 0100 0011 0100 0100 0100 0101 (etc) Character (text) value 0 1 2 3 (etc) A B C D E (etc) For alphanumeric character values: 7, 8, 16, 32, and 64-bit patterns are used for alphanumeric character values: 27= 128 character values 28= 256 character values 216= 65,536 character values 232= > 4 billion char values 264= 18,446,744,073,709,551,616 character values 14
What two parts of the equation do we already know? Base# bits used=no. of unique thingscoding schemecan represent States# bulbs used=no. of unique thingscoding scheme “ “ Challenge 1: 26 upper-case characters in our alphabet. Want our electronic word processor to manipulate all 26. • Must create binary coding scheme that will allow us enough unique patterns to encode all 26. • What is the minimum bit pattern length that is required for our coding scheme? (minimum number of bulbs) x 2 >= 26 x=5 (25=32)
What parts do we already know? Base# of bits used=no. of unique thingscoding schemecan represent Challenge 2: there are X number of characters in Zuni alphabet. Want our word processor to manipulate all of them. • A binary coding scheme, which is six bits long, would allow enough unique patterns to be able to manipulate all the characters of the Zuni alphabet. • Maximum number of characters in the Zuni alphabet? 26>= X X=64
ASCII and Extended ASCII (ANSI): Standard ASCII: Basic set for character data: 7-bit code can represent how many characters? Character formats 128 • ANSI: Extended ASCII to 8-bits. (Windows apps use 8 bits) • can represent how many characters? • 8 bits: each pattern also fits nicely into 1 memory cell. 256
8-bit ASCII 0 0101 0000 1 0101 0001 2 0101 0010 A 0100 0001 B 0100 0010 C 0100 0011 In 8-bit ASCII code: 01001000 01100101 01101100 01101100 01101111 8 bits: one byte (one character): logical 8 bulbs: stores one byte: physical Hello In the box (memory or storage): 17
Other codes Unicode: 16-bit code (65,536 bit patterns) Internat’l Standards Org: 32-bit code (>4 billion bit patterns) Representing other information types… pictures, sounds Quotable...
Important digression: Data can travel and be stored in the form of a signal. Signal: anything that changes with time or space. 0 time 0 time • Different types of signals: • Analog: continuous values (measurable) • Most of what we see/hear is in ANALOG form: sound, light, water, electricity, temperature, wind: can be plotted as a continuous, undulating line or wave. • Digital: discrete values (countable, like numbers)
Converting analog info to digital form: • Most natural forms of information (pictures, sounds) are in analog form--continuous values • E.g.: Sound: how loud?How high? (pitch) • E.g.: Color: GRAY . But how GRAY is it? • No precise way in analog world to determine this perfectly and the same each time.GG GG • Computers: designed to store and process (and transmit) discrete, on/off signals. • So with digital computers, we’ll have to change analog signals with infinite precision into digital signals with finite precision. • That process is called “digitizing” (or “sampling”).
Advantages of digital (over analog) 0 1 2 3 4 5 6 7 100 101 110 111 001 010 011 000 • Digital signals offer the following, and more… • Known Precision • Ordinality (built-in order of numbers) • Shades from darkest to lightest are expressed as numbers, from smallest to largest. • Example: Eight shades to work with, from black to white: • Absolute perfect replication • Analog: Copy of a copy of a copy…..last as good as original? • Content analysis much easier • Compression techniques work well (later!!)
Images; graphics Computer images: formed by collections of dots; each dot is a picture element: pixel. How image is represented&stored inside the computer (logical structure) can be radically different. Representing visual info • Bitmapped: Also called Raster • Object-oriented: Also called Vector • Each has its own advantages, disadvantages, and particular uses.
100 101 110 111 001 010 011 000 Phys’l: Log’l: Binary Dec’l 0 1 2 3 4 5 6 7 • Bitmap graphics • Image is represented by bits. • Each bit pattern defines one pixel. • Good illustration: SCANNER • Regular photograph. What kind of information is it? • What kind of information can be stored and manipulated inside a digital computer? • Essentially, then, what does your SCANNER have to do? • In laymen’s terms, how? 23
B&W Image Bitmap • Stored representation of such a picture: “bitmap” or “pixmap” • Stored bits are like a map of image being represented. Physical representation of bits are actually stored in memory. • Program? Knows nothing about shapes of objects; only which pixels are what color value (more shortly…) 24
0 1 • Monochrome (Black&White). • If a single pixel canbe either black orwhite, then how manybits are needed torepresent one pixel?Why? 25
Grayscale What if we want to represent more? Say, shades of gray. What has to happen to the bits stored in memory in order to represent more different values (shades) on the screen? Intuitively:LESS or MORE bits/pixel than with B&W? • ILLUSTRATION: If a single pixel can be anyone of eight shades, what minimum # of storedbits is needed to represent that one pixel? (Length of coding scheme?) 0 1 2 3 4 5 6 7 00 01 10 11 ? ? 000 001 010 011 100 101 110 111 OK, what about binary bits? Are two bits enough? 2? = 8 unique “shades” (or values of gray) 2? = 256 unique “shades” (or values of gray) 26
Number of shades possible REMEMBER BACK? Bit pattern length Base# of bits used=number of uniqueconcepts/values the coding scheme can represent Bit pattern length Base# of bits used=number of uniqueshades/colors the coding scheme can represent NOTICE a PATTERN HERE ? 28
The additive reproduction process mixes various amounts of R, G and B light to produce other colors. Representing color • ColorPrimary colors for computer graphics:RGB • Digression: Why RGB? For more information: Primary colors http://www.beer.org/~tpark/color.html How colors work: http://www.rgbworld.com/color.html 29
8 bits 8 bits 8 bits “True” color uses a 24 bit code to represent each color value: (photographic quality) • 8 bits for red (28 = 256 shades of red) • 8 bits for green (28 = 256 shades of green) • 8 bits for blue (28 = 256 shades of blue) Combine various shades to make various color combinations (provides lots of bit patterns). • SO: If onepixel is represented by a 24-bit code, how many differentCOLOR VALUES can a singlepixel display? 224 = ? ~16.7 million unique color values. 30
= All OFF = 111111111111111111111111 = WHITE All ON LOOKING IN THE BOX: 24 bits stored for EACH PIXEL! 000000000000000000000000 = BLACK 000000000000000000000001 000000000000000000000010 Again, imagine an advancing odometer that would show all of the color values betweenblack and white …! 000000000000000000000011 000000000000000000000100 000000000000000000000101 000000000000000000000110 000000000000000000000111 000000000000000000001000 AND LOTS MORE!
File format : How information is encoded & stored Different software apps understand different graphics file formats (encoding systems). TIFF, GIF, JPEG, BMP,... Some better for certain purposes... Beyond the scope of COMP 4. When saving an image file one can usually choose a file format from a selection. PowerPoint, for example, recognizes a number of graphics file formats, but not all. However, utilities (filters) can interpret and convert one file format to another. Software often comes w/filters (or can download from software vendor’s Web site). File formats for bitmap graphics
Same image scaled up Original bitmapped graphic • Advantages, disadvantages, applications: • Photo realism. • Software: Photo editing, and Paint. • Can work at pixellevel. • HUGE files without compression! • Storage and download time! • Images do not scale up well: • Image resolution is important
Vector graphics • Uses instructions to draw lines, fill shapes (rather than tracking and storing bits for each pixel)…. In English: “Draw a circle at the point that is 100 pixels to the right and 140 pixels down from the top-left corner of the screen with the radius of 25 pixels.” • Software: Drawing. • Shapes are known to the program. Does not work at pixel level, but rather at object-level. • Scalable, no jaggies. • Files relatively small • Layering: “2 ½ dimensions” • Seeing more vector graphics for the Web: .sfv, .cmg
another important means of conveying information. Representing sound • Produced by vibration; transmitted over a medium. • Sound travels in analog wave patterns. • Wavecharacteristics: amplitude (loudness) and frequency (pitch) can be measured & sampled over time, and stored as a sequence of binary numbers. • Called? “Digitizing” or “sampling” • Much like scanning an analog photograph spatially creates a digital bitmap. • The higher the sampling rate, the better the quality of the digital signal!
Analog to digital audio dB Samples 0 time Sampling rate Analog sounds can be: • Captured in analog form by an analog microphone • Converted to digital form by an ADC (audio to digital converter) • Stored as file on a digital storage device (CD or hard drive). Then, for playback to human ears: • Converted to analogform by a DAC (digital to analog converter) • Playedback by analog speakers.
These days, we can get Digital capture and player devices for both audio and video. Digital cameras Digital camcorders Digital microphones So, for that data, the computer does not need ADC or DAC converters: captured and played all in the same digital mode. MP3 files: file format that squeezes digital sound into small files through sophisticated compression adapted to the human ear (more later). Fast to download; less to store.
SUMMARY! We can use bit patterns of zeroes and ones to represent: Numeric values Alphanumeric text Pictures (bitmaps) Sounds and Instructions Vector graphics; MIDI (music); General programming (coming) • RECAP:SOFTWARE determines if a stored bit pattern represents a numericvalue, or alphanumerictext, or part of a sound, or part of a picture, or part of an instruction..... all bits look the same to the CPU!