# Data Representation

A network is a collection of different devices connected and capable of communicating. For example, a company's local network connects employees' computers and devices like printers and scanners. Employees will be able to share information using the network and also use the common printer/ scanner via the network. Data to be transferred or communicated from one device to another comes in various formats like audio, video, etc. This tutorial explains how different data types are represented in a computer and transferred in a network.

Different Data types in a computer network:

1. Texts
2. Numbers
3. Images
4. Videos
5. Audios

### Textual data:

Data in text format is represented using bit patterns (combinations of two binary bits - 0 and 1). Textual data is nothing but a string, and a string is a collection of characters. Each character is given a specific number according to an international standard called Unicode. The process of allocating numbers to characters is called "Coding," and these numbers are called "codes". Now, these codes are converted into binary bits to represent the textual data in a pattern of bits, and these bits are transferred as a stream via the network to other devices.

Unicode:

It is the universal standard of character encoding. It gives a unique code to almost all the characters in every language spoken in the world. It defines more than 1 40 000 characters. It even defined codes for emojis. The first 128 characters of Unicode point to ASCII characters. ASCII is yet another character encoding format, but it has only 128 codes to 128 characters. Hence, ASCII is a subset of Unicode.

File extensions:

.doc, .docx, .pdf, .txt, etc.

For example:

Word: H

Unicode representation: U+0048

### 2. Numerical data

Numbers are directly converted into binary patterns by dividing by 2 without any encoding. The numbers we want to transfer generally will be of the decimal number system- ( )10. We need to convert the numbers from ( )10 to a binary number system - ( )2 to get a bit stream.

Number formats:

Integers

Date

Boolean

Decimal

Fixed point

Floating point

Example:

Number: 780

Binary representation: 1100001100

### 3. Image

Image data is also transferred as a stream of bits like textual data. An image, also called a picture, is a collection of little elements called "Pixels". A single pixel is the smallest addressable element of a picture, and it is like a dot with a size of 1/96 inch/ 0.26 mm. The dimensions of an image are given by the number of pixels along the height of the image X Number of pixels along the width of the image.

Representation in a computer:

Grayscale images:

A black-and-white/ Grayscale image consists of white, black, and all the shades in between. It can be considered as just the varying intensity of the White color. The intensity of the white color in a pixel is given by numbers called "Pixel values". The pixel value in a Grayscale image can be in the range of 0 to 255, where 0 represents Black and 255 represents White, and all the numbers in the interval represent different shades. A matrix is created for the image with pixel values of all the pixels in the image. This matrix is called a "Channel".

Colored images:

Each pixel comprises three transistors representing three standard colors: Red, Green, and Blue (RGB), Yellow, Cyan, and Magenta (YCM). Any color known can be generated by using these three colors. Based on the intensity of a color in the pixel, three matrices/ channels for each color are generated.

Suppose there is a colored image, and three matrices are created for Red, Green, and Blue colors in each pixel in the image:

The first pixel's intensities of Red, Green and Blue colors are [141, 35, 31]. In this way, every pixel is analyzed and converted into binary bits

, and this bit stream is transferred to any other device in the network to communicate the image. N-bit streams are used to represent 2N possible colors. From 0 to 255, we can represent 256 shades of color with different 8-bit patterns.

For example, an image consists of only either black or white colors, only one bit will be enough to represent the pixels:

White - 1

Black - 0

File extensions:

.jpg, jpeg, .png, etc.

### 4. Audios

Transferring an audio signal is different from other formats. Audio is broadcasting recorded sound or music. An audio signal is generated as an analog wave, converted into digital format to be stored in a computer by representing the wave amplitude at moments in bits. Another parameter is the sample rate. It represents the number of samples or, in other words, samples saved.

The audio quality depends on the sampling rate and the bit rate. If more bits are used to represent the amplitudes in moments and more moments are captured accurately, we can save the audio with every detail accurately.

File extensions:

.mp3, .m4a, .WAV, .AAC, etc.

### 5. Videos

A video is a collection of frames; each frame is a picture with the same or different dimensions. These frames/ images are represented as matrices, as we discussed above. All the frames/ images are displayed continuously, one after the other, to show a video in movement. To represent a video, The computer will analyze data about the video like:

1. FPS (Frames per second)
2. Duration of the video
3. Image resolution (Number of pixels Horizontally X Vertically)
4. Bit depth (Number of bits required to represent a pixel -> number of colors)

A video is mostly combined with an audio component, like a film or a video game.

File extensions:

.mp4, .MOV, .AVI, etc.