Chapter 3 Data Representation

Source: Internet
Author: User
Tags bmp image color representation
1. Relationship between data and computer data

A computer is used to manage data.

Differences between data and information

Data: basic value.

Information: meaningful data after organization or processing.

Data that can be stored and expressed by a computer includes
  1. Number
  2. Text
  3. Audio
  4. Images and graphics
  5. Video

The above data is eventually stored as binary numbers, expressed simply by 0 and 1.

Data Compression 2 analog data and digital data

Most of the tasks are continuous and unlimited. Computers are limited. The computer memory and other hardware devices are used to store and operate a certain amount of data space.

There are two methods to represent data: analog and digital.

Simulated Data is a continuous representation that simulates the real information it represents.

Digital Data is a discrete representation that splits information into independent elements.

Binary unit conversion

Bit: Bit, byte: byte, M: MB, 1G: 1g.

1 byte = 8bit

1kb = 1024 bytes

1 MB = 1024kb

1G = 1024 MB

1 TB = 1024 GB

Why do we use binary instead of decimal or other digit systems?
  1. Binary data is physically easy to implement. For example, you can use either a high or a low level to represent "1" and "0", or use either the pulse or the positive or negative polarity of the pulse to represent them.
  2. The encoding, counting, and addition/subtraction rules of binary numbers are simple.
  3. The two symbols "1" and "0" of the binary number correspond exactly to the two values of the logical proposition "yes" and "no" or "true" and "false, it provides convenient conditions for computers to implement logical operations and logical judgment in programs.
3. Numeric data notation integer notation negative notation hexadecimal Complement

Data Overflow

Real number representation

4 text Representation

The number of characters is limited, so as long as a binary string is assigned to all characters, we can call these character sets a character set.

Different languages use different numbers of characters, so many character sets appear in today's computer systems.

ASCII character set

American Standard Code for information interchange ). In the past, the ASCII character set used 7 characters to indicate each character, which can represent 128 different characters. The current ASCII character set uses 8 characters to represent each character, which can be 256 characters.

 

Unicode Character Set

The Unicode Character Set is called a unified code. It uses 16-bit (dual-byte) characters to represent each character and can represent more than 60 thousand characters.

Text compression

To reduce the storage space occupied by text and effectively transfer text between two computers, the text compression function is usually used.

Keyword Encoding

Simply put, replace multiple characters that are frequently used with one character. For example '! 'Corresponds. This method has limitations. The characters encoded with keywords cannot appear in the original text.

Travel Length Code

In short, the continuous characters are represented by numbers and characters. For example, aaaaaaa is represented by * A7, * is a special sign, A is a recurring character, and 7 is the number of times the character appears.

Heman Encoding

To put it simply, a variable binary string is used to represent characters, so that common characters can be encoded in a short manner.

For example:

Heman Encoding

Character

Heman Encoding

Character

00

A

111

R

01

E

1010

B

100

L

1011

D

110

O

   

The binary code of the word doorbell is as follows:

1011 110 110 111 1010 01 100 100

The binary encoding Based on the ASCII character set is as follows:

01000100 01001111 01001111 01010010 01000010 01000101 01001100

5 Audio Information Representation

Computers can record, store, and play sounds (such as pronunciation and music ). Sound or audio data is represented in two different ways: Waveform or m I music. The difference between the two is similar to that between tape recording and piano performance.

Waveform audio

Waveform audio is a digital representation of sound. For audio digital records, audio waveforms are periodically sampled and stored as digital data. Music, pronunciation, and sound can all be stored in waveforms.

 

The sampling rate refers to the number of audio measurements per second during the recording process. The sampling rate is in the unit of H z. Sampling 1 0 0 0 times per second is 1 0 0 0 0 h Z or 1 k h z. The sound must be 88 200 bytes per second. Stereo requires twice the storage space, because two records need to be recorded to achieve the effect of stereo. However, when the sampling rate is 4. 1 k h z, only 8 seconds of music can be stored on a 1. 4 4 m B floppy disk. A typical rock roll (4 5 minutes) requires 4 7 5 m B.

Example of waveform file Calculation

Sound Card processing quality can be measured by three basic parameters, namely the sampling frequency, number of sampling digits, and number of sound channels. Sampling frequency refers to the number of samples per unit time. The larger the sampling frequency, the smaller the interval between sampling points, and the more lifelike the sound produced after digitization, the larger the data volume. Sound cards generally provide different sampling frequencies, such as 11.025 kHz, 22.05khz, and 44.1khz.

The number of sampling digits is the number of digits that record the value of each sample. The number of sampling digits is usually 8 bits or 16 bits. The larger the number of sampling digits, the more delicate the sound change can be recorded, and the larger the corresponding data volume.

The number of channels sampled indicates whether the processed sound is a single channel or a stereo sound. A single channel only has a single data stream in the sound processing process, while a stereo system requires two data streams for the left and right channels. Obviously, the effect of stereo sound is better, but the corresponding data volume is more than that of single channel.

The formula for calculating the volume of sound data without compression is as follows:

Data Volume (byte/second) = (sampling frequency (HZ) * Number of sampling digits (BIT )*? Audio Channels)/8, where the number of single-channel channels is 1, and the number of stereo channels is 2.

Application Example

[Example 1] What is the amount of data that is not compressed for 5-minute dual-channel, 16-bit sampling digits, and 44.1khz sampling frequency sounds?

Solution:

According to the formula:

Data volume = (sampling frequency × number of sampling digits × number of channels × time)/8

Data size = [44.1x1000x16x2 x (5x60)]/(8x1024x1024)

= 50.47 MB

Therefore, the volume of sound data not compressed is about 50.47 MB.

Pay attention to the conversion details of several units during calculation:

Time unit conversion: 1 minute = 60 seconds

Sample frequency unit conversion: 1 kHz = 1000Hz

Data Volume unit conversion: 1 MB = 1024x1024 = 1048576b

 

6. Representation of images and Images

The bitmap image and vector image encoding methods are different, which affect the image quality, the size of the storage image space, the image transfer time, and the difficulty of modifying the image.

Color Representation

Color is our feeling of light at various frequencies that reach the retina. Our retina has three color photosensitive cone cells that receive light at different frequencies. These sensors correspond to three colors: Red, green, and blue. Other colors that human eyes can perceive are mixed by these three colors.

In computer systems, colors are usually represented by red-green-Blue values, which are actually three numbers indicating the relative proportions of each primary color.

Digital representation bitmap image

A computer stores bitmap images by specifying the position of each independent vertex (or pixel) on the screen.

Pixels

The display screen consists of rows or columns of pixels (points). For example, the display resolution is 1024*768 pixels, indicating that each row has 1024 pixels, each column has 768 pixels.

Binary representation of bitmap images

The simplest bitmap image is a monochrome image. A monochrome image only contains two colors: black and white, that is, each pixel is only black and white. A pixel has two colors, so we can use 1 bit to represent a pixel. If there is a 1024*768 monochrome image, the file size is: 1024*768*1 = 786432bit, that is, about 98kb. Let's continue with the estimation. assume there is a 256-color image, so we know that a pixel has 256 colors, and we need to use 8 bits to represent a pixel. The file size is: 1024*768*8 = 6291456bit, that is, about 786kb.

Bitmap image file format

Bitmap images are usually used for real-world images, such as scanned images. The file extension is. B m p,. p c x,. t I f,. j p g and. g I f. Note that apart from BMP image files that are not compressed, other file formats are compressed to save space. Therefore, image files should be saved in BMP format during testing.

Bitmap image Modification

Because bitmap files use a series of bits to represent pixels, you can modify or edit a single pixel, or modify the pixels of a region at the same time.

Graphical vector Representation

A vector image consists of a stringCommand. When creating a vector image, you can draw lines and images in different colors. The computer then converts the line and image into instructions that can reconstruct the image. Computers only store these commands, not real images. The vector image does not seem to have a bitmap image.

Simply putSave the command for image painting, not the image itself.

Advantages of vector Images

Small storage space and convenient modification (you can modify part of the vector image as a separate object ).

Vector Image File Format

Files that contain vector images have the following extensions:. w m f,. d x F,. m g x, and. c g m.

7 relationship between videos and Images

A video consists of a series of frames, each of which is a static image, and the image is also represented in a bitmap file. However, a video needs to display 3 0 frames per second (generally, the video requires at least 24 frames to be stuck), which means that the video requires a huge storage space.

Example

A full screen, 6 4 0x4 8 0 2 5 6 color image with 307 200 pixels. Therefore, the space required for a second video is 3 0 multiplied by this number, that is, 9 216 000 bytes, about 9 MB (1 0-1 7 ). Two-hour movies require 66 355200 bytes, exceeding 6 6G bytes! It's still a low-quality video --! In this case, if we want to process video data of nearly 10 MB per second, our broken computer will definitely crash.

Video Compression

However, a two-hour high-definition movie is about 4 GB to 6 GB. Why did it cause the file to shrink significantly?

This is because the video has been compressed by the video encoder, mainly using time compression and space compression methods.Time CompressionSearches for the differences between consecutive frames. If most of the images in two frames are not changed, the same part will not need to be stored, and the amount of information will naturally decrease.Space CompressionThe redundant information in a frame is deleted, and pixels of the same color (such as blue sky) are gathered in blocks (rectangular areas), storing information not for each pixel, it is the color and coordinate of the block. Space compression is actually used to compress each image, so it is also one of the image compression methods.

Chapter 3 Data Representation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.