650 likes | 868 Vues
Data Representation. CT101 – Computing Systems. Clickers Test. Are you there? Yes No. Computing Systems Data. Usually the computing systems are complex devices, dealing with a vast array of information categories The computing systems store, present, and help us modify: Text Audio
E N D
Data Representation CT101 – Computing Systems
Clickers Test Are you there? • Yes • No
Computing Systems Data • Usually the computing systems are complex devices, dealing with a vast array of information categories • The computing systems store, present, and help us modify: • Text • Audio • Images and graphics • Video
Digital vs. Analog (1) • Computing systems are finite machines. They store a limited amount of information, even if the limit is very big. • The goal, is to represent enough of the world to satisfy our computational needs and our senses of sight and sound. • The information can be represented in one or two ways: analog or digital. • Analog data is a continuous representation, analogous to the actual information it represents. • In example, a mercury thermometer is an analog device. The mercury rises in a continuous flow in the tube in direct proportion to the temperature. • Digital data is a discrete representation, breaking the information up into separate (discrete) elements. • Computers can’t work with analog information, so a need do digitize the analog information arise. • This is done by breaking the analog information into pieces and representing those pieces using binary digits
Digital vs. Analog (2) • Why digital signal? • Both electronic signals (analog and digital) degrade as they move down a line. The voltage of the signal fluctuates due to environmental effects. • As soon as an analog signal degrades, information is lost. Since any voltage level within the range is valid, it is impossible to know that the original signal was even changed • Digital signals jump sharply between two extremes (high and low state). A digital signal can degrade quite a bit until the information is lost, because any value over a certain threshold is considered high value and bellow the threshold is considered low value • Answer: Signal Integrity can be maintained!
Digital vs. Analog (3) • You can still retrieve the information from a reasonably degraded digital signal • Periodically a digital signal is reclocked to regain its original shape. As long as it is reclocked before too much degradation, no info is lost.
Binary Representation (1) • Why binary representation (as suppose to decimal or octal, etc..)? • Because the devices that store and manage the digital data are far less expensive and complex for binary representation. • They are also far more reliable when they have to represent one out of two possible values. • Because the electronic signals are easier to maintain if they carry only binary data.
Binary Representation (2) • One bit can be either 0 or 1. Therefore, one bit can represent only two things. • To represent more than two things, we need multiple bits. Two bits can represent four things because there are four combinations of 0 and 1 that can be made from two bits: 00, 01, 10,11. • In general, n bits can represent 2n things because there are 2n combinations of 0 and 1 that can be made from n bits. Note that every time we increase the number of bits by 1, we double the number of things we can represent.
Review Question 1 • Why digital signal is better than analogue signal in computing systems • Signal integrity can be maintained relatively easy • Information is never lost • Digital signal is more precise • I don’t know …
Review Question 2 How many things can a bit represent ? • One • Two • Ten • I don’t know …
Review Question 3 How many things a byte can represent ? • One • Two • 256 • I don’t know
Data Formats - How to Interpret Data • Meaning of internal representation must be appropriate for the type of processing to take place: • i.e. Images & sound: have to be digitized • Images – need detailed description of the data, how color is represented at each data point • Sound – need sampling rate • Proprietary formats • Unique to a product or company • E.g., Microsoft Word, Corel Word Perfect, IBM Lotus Notes • Standards • Evolve two ways: • Proprietary formats become de facto standards (e.g., Adobe PostScript, Apple Quick Time) • Committee is struck to solve a problem (Motion Pictures Experts Group, MPEG)
Why Standards? • They exist because they are: • Convenient – sometimes the time to market is very important whenever trying to finish a product, therefore existing standards may be used to save time elaborating own protocols and interfaces • Efficient – most of the standards are put together by committees with a wide experience in the specific area • Flexible – usually the standards allow for manufacturer or OEM specific extensions • Appropriate – address a specific problem in a specific domain • Allow communication and sharing of information • Allow computing systems and software to interoperate (at both hardware and software levels) • Sometimes standards are arbitrary and have some “blast from the past” (due to historical evolution)
Standards Organizations • ISO – International Standards Organization • IEEE – Institute for Electrical and Electronics Engineers • CSA – Canadian Standards Association • ANSI – American National Standards Institute • NSAI – National Standards Authority of Ireland
Alphanumeric Data • Three standards for representing letters (alpha) and numbers • ASCII – American Standard Code for Information Interchange • EBCDIC – Extended Binary-Coded Decimal Interchange Code (not used anymore, used to be used in IBM mainframes) • Unicode
Codes and Characters • The problem: • Representing text strings, such as “Hello, world”,in a computer • Each character is coded as a byte ( = 8 bits) • Most common coding system is ASCII • ASCII = American National Standard Code for Information Interchange • Defined in ANSI document X3.4-1977
ASCII Features • 7-bit code • 8th bit is unused (or used for a parity bit) • 27 = 128 codes • Two general types of codes: • 95 are “Graphic” codes (displayable on a console) • 33 are “Control” codes (control features of the console or communications channel)
Most significant bit Least significant bit
Binary 01001000 01100101 01101100 01101100 01101111 00101100 00100000 01110111 01101111 01110010 01101100 01100100 Hexadecimal 48 65 6C 6C 6F 2C 20 77 6F 72 6C 64 Decimal 72 101 108 108 111 44 32 119 111 114 108 100 H e l l o , w o r l d = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Note: 12 characters – requires 12 bytes Each character requires 1 byte “Hello, world” Example
“4+15” Example Binary 00110100 00101011 00110001 00110101 = = = = Hexadecimal 34 2B 31 35 = = = = Decimal 52 43 49 53 = = = = 4 + l 5 “4+15” is represented as “00110100 00101011 00110001 00110101” or “34162B1631163516”
Common Control Codes • CR 0D carriage return • LF 0A line feed • HT 09 horizontal tab • DEL 7F delete • NULL 00 null
ESC [ 1B16 5B16 Escape Sequences • Extend the capability of the ASCII code set • For controlling terminals and formatting output • Defined by ANSI in documents X3.41-1974 and X3.64-1977 • The escape code is ESC = 1B16 • An escape sequence begins with two codes: • Example: • Erase display: ESC [ 2 J • Erase line: ESC [ K
Unicode (1) • The extended version of the ASCII character set is not enough for international use. • The Unicode character set uses 16 bits per character. Therefore, the Unicode character set can represent 216, or over 65 thousand, characters. • Unicode was designed to be a superset of ASCII. That is, the first 256 characters in the Unicode character set correspond exactly to the extended ASCII character set.
Unicode (2) • Version 2.1 • 1998 • Improves on version 2.0 • Includes the Euro sign (20AC16 = ) • From the standard: • …contains 38,887 distinct coded characters derived from the supported scripts. These characters cover the principal written languages of the Americas, Europe, the Middle East, Africa, India, Asia, and Pacifica. • Latest version of Unicode is 4.0 http://www.unicode.org
Review Question 4 How many codes can be represented using ASCI standard? • Two • 128 • 256 • 512 • I Don’t know …
Review Question 5 Why is Unicode adopted and widely used? • Because it is using 16 bit per character and thus has a huge character code space (216 = 65536) • Because it is a super-set of ASCII and thus is easily adopt-able by adopters of ASCII • Because the ASCII (or extended ASCII) character set is not enough for international use • I don’t know …
Audio Information Representation (1) • Sound is perceived when a series of air compressions vibrate a membrane in our ear, which sends signals to our brain • A stereo sends an electrical signal to a speaker to produce sound. This signal is an analog representation of the sound wave. The voltage in the signal varies in direct proportion to the sound wave • To digitize the signal we periodically measure the voltage of the signal and record the appropriate numeric value. The process is called sampling • In general, a sampling rate of around 40,000 times per second is enough to create a very good high quality sound reproduction
Audio Information Representation (2) Sampling an audio signal
Audio Formats • Several popular formats are: WAV, AU, AIFF, VQF, and MP3. Currently, the dominant format for compressing audio data is MP3. • MP3 is short for MPEG-2, audio layer 3 file. • Compressed formats usually employ both lossy and lossless compression. • Analyzes the frequency spread and compares it to mathematical models of human psychoacoustics (the study of the interrelation between the ear and the brain) and it discards information that can’t be heard by humans. • Then the bit stream is compressed using a form of Huffman encoding to achieve additional compression.
Representing Images and Graphics (1) • Color is our perception of the various frequencies of light that reach the retinas of our eyes • Our retinas have three types of color photoreceptor cone cells that respond to different sets of frequencies. • These photoreceptor categories correspond to the colors of red, green, and blue • Color is often expressed in a computer as an RGB (red-green-blue) value, which is actually three numbers that indicate the relative contribution of each of these three primary colors • For example, an RGB value of (255, 255, 0) maximizes the contribution of red and green, and minimizes the contribution of blue, which results in a bright yellow
Representing Images and Graphics (2) Three-dimensional color space
Representing Images and Graphics (3) • The amount of data that is used to represent a color is called the color depth. • HiColor is a term that indicates a 16-bit color depth. • Five bits are used for representing the R and B components. • Six bits are used for representing the G component, because the human eye is more sensitive to G; • TrueColor indicates a 24-bit color depth. Therefore, each number in an RGB value is represented using eight bits.
Digitized Images and Graphics • Digitizing a picture is the act of representing it as a collection of individual dots called pixels. • The number of pixels used to represent a picture is called the resolution. • The storage of image information on a pixel-by-pixel basis is called a raster-graphics format. • Several popular raster file formats including bitmap (BMP), GIF, and JPEG.
BMP Raster Image Example • The smiley face in the top left corner is a bitmap image. • When enlarged, individual pixels appear as squares. • Each pixel is described by a value for red, green and blue.
Vector Graphics • Instead of assigning colors to pixels as we do in raster graphics, a vector-graphics format describe an image in terms of lines and geometric shapes. • A vector graphic is a series of commands that describe a line’s direction, thickness, and color. The file size for these formats tend to be small because every pixel does not have to be accounted for. • Vector graphics can be resized mathematically, and these changes can be calculated dynamically as needed. • However, vector graphics is not good for representing real-world images.
Example of Vector Image • Effect of vector graphics versus raster graphics. • Magnification of 7x as a vector image vs same magnification as a bitmap image. • Examples of vector image formats: SVG (Scalable Vector Graphics), EPS (Encapsulated Post Script), etc..
Video • What is video? • is the technology of electronically capturing, recording, processing, storing, transmitting and reconstruction a sequence of still images representing scenes in motion • It is a collection of still images • How does video camera work? • lens of the camera focuses an image onto a sensor, and the sensor converts the image into an electronic signal that is stored on tape, disc, hard-drive, or memory card (in a compressed or raw format). • What about sound? • Video cameras usually record sound along with images. Almost all video cameras have microphones, but even though images and sound are usually recorded to the same tape, disc, or card they are two different types of information - so sometimes it helps to think of them separately. • You might record a beautiful visual scene with terrible noise, but you know that you won’t use the sound. Or you might record some beautiful sound with your video camera while the lens cap is on because you just want the sound.
Representing Video • Frame rate: the number of still images (or frames) recorded every second. • Usually frame rate is expressed in frames per second (fps) and most video cameras record at 30 fps. • Resolution: how many pixels the image has. • Resolution is usually expressed by numbers for horizontal and vertical: 640 by 480 means 640 pixels wide, by 480 pixels tall. • Multiply the numbers and you get the total number of pixels. In this case 640x480 = 307,200. • Aspect Ratio: what defines the width and height of your images. • The most common aspect ratios are 3:2, 4:3, and 16:9. • Compression and Format: to save space the movie gets compressed to make it smaller. • The way a camera compresses the image data and records it is the recording format.
Representing Video • A video codec Compressor/De-compressor refers to the methods used to shrink the size of a movie • Almost all video codecs use lossy compression to minimize the huge amounts of data associated with video. • Two types of compression: temporal and spatial. • Temporal compression looks for differences between consecutive frames. If most of an image in two frames hasn’t changed, why should we waste space to duplicate all of the similar information? • Spatial compression removes redundant information within a frame. • For instance, a line compression algorithm, instead of representing a white line as a series of dots with individual color info, it can represent it as how many dots of white color (saving storage space) • This problem is essentially the same as that faced when compressing still images.
Video Formats • There are different layers of video transmission and storage, each with its own set of formats to choose from. • Video gets transported via a physical connector and signal protocol ("video connection standard“) • A given physical link can carry certain "display standards" which specify a particular refresh rate, display resolution and colour space (digital and analogue television and computer display standards). • There are a number of standards for storage: • analogue and digital tape formats • digital video files can also be stored on a computer file system (with its own standards/formats) on different media (optical – DVD, Blue-ray or magnetic - HDD). • In addition to the physical format used by the storage or transmission medium, the stream of ones and zeros that is sent must be in a particular digital video "encoding“ format (MPEG-2, MPEG-4, etc..)
Review Question 6 Given a raster image with a 16x12 resolution, what would be the number of pixels: • 192 pixels • 256 pixels • 512 pixels • I don’t know …