Colour and Number Representation. From Hex to Binary and Back. Colour and Number Representation. Colour and Number Representation

Similar documents
Objectives. Connecting with Computer Science 2

Level ISA3: Information Representation

15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2

COE 202- Digital Logic. Number Systems II. Dr. Abdulaziz Y. Barnawi COE Department KFUPM. January 23, Abdulaziz Barnawi. COE 202 Logic Design

Number Bases LESSON TWO. Computer Science. By John Owen

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

Example 1: Denary = 1. Answer: Binary = (1 * 1) = 1. Example 2: Denary = 3. Answer: Binary = (1 * 1) + (2 * 1) = 3

Data Representation From 0s and 1s to images CPSC 101

Module 1: Information Representation I -- Number Systems

OBJECTIVES After reading this chapter, the student should be able to:

COMP Overview of Tutorial #2

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

NUMERIC SYSTEMS USED IN NETWORKING

Unit 2 Digital Information. Chapter 1 Study Guide

ECE 461 Internetworking Fall Quiz 1

Numbers and their bases

CMPS 10 Introduction to Computer Science Lecture Notes

Tutorial for Chapter 3, 4

Chapter 4: Computer Codes. In this chapter you will learn about:

Octal & Hexadecimal Number Systems. Digital Electronics

Computer Number Systems Supplement

ITP 140 Mobile App Technologies. Colors

CS 100 Spring Lecture Notes 3/8/05 Review for Exam 2

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Unit 2: Data Storage CS 101, Fall 2018

Introduction to Computer Science (I1100) Data Storage

Number representations

2nd Paragraph should make a point (could be an advantage or disadvantage) and explain the point fully giving an example where necessary.

Administrative Notes February 9, 2017

CS & IT Conversions. Magnitude 10,000 1,

Computer Arithmetic. In this article we look at the way in which numbers are represented in binary form and manipulated in a computer.

Bits, bytes and digital information. Lecture 2 COMPSCI111/111G

Bits, bytes, binary numbers, and the representation of information

Mini-Project 1: Steganography. Lecture Barbara Jobstmann

Secure understanding of multiplication of whole numbers by 10, 100 or 1000.

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Switching Circuits and Logic Design Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Lesson 9: Decimal Expansions of Fractions, Part 1

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

Exam Review Lectures. Tim Capes. November 29, 2011

CDS Computing for Scientists. Midterm Exam Review. Midterm Exam on October 22, 2013

: Principles of Imperative Computation Victor Adamchik. Practice Exam - I

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Introduction to Informatics

Number Systems Using and Converting Between Decimal, Binary, Octal and Hexadecimal Number Systems

MACHINE LEVEL REPRESENTATION OF DATA

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

Lecture 2: Number Systems

Lesson Plan. Preparation

DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) COURSE / CODE NUMBER SYSTEM

umber Systems bit nibble byte word binary decimal

CMSC 2833 Lecture Memory Organization and Addressing

GCSE Computing. Revision Pack TWO. Data Representation Questions. Name: /113. Attempt One % Attempt Two % Attempt Three %

Math Circle Beginners Group October 18, 2015 Solutions

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

CHW 261: Logic Design

COMP 102: Computers and Computing

Machine Architecture and Number Systems

ITEC 1011 Introduction to Information Technologies

2. Define Instruction Set Architecture. What are its two main characteristics? Be precise!

Midterm Exam 2B Answer key

Conversion Between Number Bases

QUIZ: Generations of computer technology. Hardware:

Computer Principles and Components 1

6. Binary and Hexadecimal

Information Science 1

EE 8351 Digital Logic Circuits Ms. J.Jayaudhaya, ASP/EEE

CS 151 Final. (Last Name) (First Name)

Lesson 20: Every Line is a Graph of a Linear Equation

Lecture 1: What is a computer?

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

TOPICS. Other Number Systems. Other Number Systems 9/9/2017. Octal Hexadecimal Number conversion

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

1.1 Data representation

2a. Codes and number systems (continued) How to get the binary representation of an integer: special case of application of the inverse Horner scheme

Bits. Binary Digits. 0 or 1

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System

CMPSCI 105 Midterm Exam Solution Spring 2008 March 27, 2008 Professor William T. Verts

Slide Set 1. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Java Oriented Object Programming II Files II - Binary I/O Lesson 3

CSCI 2212: Intermediate Programming / C Chapter 15

CIS 580, Machine Perception, Spring 2015 Homework 1 Due: :59AM

Switching to AQA from OCR

Chapter 3 Data Representation

3 Data Storage 3.1. Foundations of Computer Science Cengage Learning

Multiplying and Dividing by Powers of 10

Adding CSS to your HTML

Machine Architecture and Number Systems CMSC104. Von Neumann Machine. Major Computer Components. Schematic Diagram of a Computer. First Computer?

EE292: Fundamentals of ECE

Chapter 2: Universal Building Blocks. CS105: Great Insights in Computer Science

Transcription of The Magic Picture" Lesson

Data Representation and Architecture Modeling Year 1 Exam preparation

Part 01: Logo, Typography & Colours. Brand Identity Guidelines 2015

What Is It? Instruction Register Address Register Data Register

255, 255, 0 0, 255, 255 XHTML:

Excerpt from "Art of Problem Solving Volume 1: the Basics" 2014 AoPS Inc.

Transcription:

Colour and Number Representation From Hex to Binary and Back summary: colour representation easy: replace each hexadecimal "digit" with the corresponding four binary digits using the conversion table examples: hex binary AC colours can be represented as RGB intensities three numbers HTML specifications express the RGB numbers in hexadecimal notation 10101100 01101001 example: <body bgcolor= #3A00FF > 11 FF 11100001 11111111 20 21 Colour and Number Representation Colour and Number Representation summary: number system calculations summary: number system calculations adding 1 to a binary number: replace the rightmost 0 by a 1 and any 1 s to the right of that by a 0 hex binary: replace each hexadecimal digit by the four corresponding binary digits in the conversion table binary hex: put extra 0 s at the left of the binary number as necessary so that the total number of digits is a multiple of 4, then reverse the hex binary conversion process example: 01011011 + 1 = 01011100 binary decimal: for each place i in the binary number, multiply the digit (0 or 1) in that place by the place value 2 i (see next slides) 22 23

From Binary to Decimal From Binary to Decimal first recall meaning of decimal notation adapt this meaning to binary notation 1 1 0 01 248 0 1s place multiply by 1 (10 ): 10s place multiply by 10 (10 1): 100s place multiply by 100 (10 2): 8 40 200 Total in decimal (add them up): 248 1s place multiply by 1 (2 0): 2s place multiply by 2 (2 1): 4s place multiply by 4 (2 2): 8s place multiply by 8 (2 3): 16s place multiply by 16 (2 4): Total in decimal (add them up): 24 From Decimal to Hex From Decimal to Hex (here only for numbers up to 256): Example: What is 33 (decimal) in hex? if the given number n <= 15: translate n directly into a hex digit (and add 0 to the left); else i := result of integer division of n by 16; j := n - 16*i; [this is the division remainder] look up the hex digits for i and j; the result of the conversion is i j; 1 0 0 8 16 25 25 n = 33 33/16 = 2 remainder 1 -> i = 2, j = 1 (33 = 2*16+1) 2 in hex = 2 1 in hex = 1 -> result = 21 (hex) (Check: 21 hex in decimal = 2*16+1*1 = 33) 26 27

From Decimal to Binary From Decimal to Binary Approach 1: Decimal -> hex -> binary Challenges: Approach 2: Direct conversion (here: 8-bit numbers only) 1.Rewrite Approach 2 as a function using for-loop. Hint: 128 = 2^7, 64 = 2^6, n < 128 -> 1st bit := 0; otherwise 1, n:=n-128; n < 64 -> 2nd bit := 0; otherwise 1; n:=n-64; n < 32 -> 3rd bit := 0; otherwise 1; n:=n-32; n < 2 -> 7th bit := 0; otherwise 1; n:=n-2; 8th bit = n; (at this point, n is either 0 or 1); 1.Extend Approach 2 so that it works for 16-bit binary numbers (numbers between 65535 and 0). 28 29 Clicker Exercise In your exam 1.You are expected to be able to do number conversions, without a calculator. The 8-bit binary representation of 57 is 00111001. What is the 8-bit binary representation of 58? 1.We will give you tables for hex digits and powers of 2. A. B. C. D. 1.We will keep the amount of calculation (divisions in particular) small. 01011110 00111111 00111010 00111000 1.If you find direct conversions decimal -> hex difficult, consider decimal -> binary -> hex. 30 31

Clicker Exercise Selected RQs: Binary notation has been used in computing for decades, due to the simplicity of implementing the physical circuitry (logic gates) required to process it. With advances in modern technology improving computer chip manufacturing abilities, is binary still the most efficient data structure on which to base a computing system? The 8-bit binary representation of 57 is 00111001. What is the 8-bit binary representation of 56? A. B. C. D. 01011110 00111111 00111010 00111000 32 Selected RQs: 33 Learning Goals [revisited] you should be able to In [photo processing] programs, there are often options to "boost" or "tint" the colours of the picture - how does the computer code this? Does it add a certain number to each of the RGB bytes? Or perhaps just one, depending on what colour it's tinting to? define the RGB colour specification, explain its basis, and convert from hexadecimal to decimal define bitmap image and pixel and explain how to construct a bitmap image representation define vector image and explain how to construct a vector image representation compare and contrast the suitability of bitmap and vector representations for different uses of images (submitted by Daria, 2011W1 Student) 34 35

Representing Images Bitmap Image Representation Exercise: How might you verbally describe the following images? Could someone accurately reproduce the images based on your description? (a) data rep scheme to (b) pixel (d) 36 Bitmap Image Representation (c) 37 Bitmap Image Representation data rep scheme to data repfully specify an image using to scheme to representation you need: bitmap width and height of the image number of rows and columns of the grid the pixels, i.e. colour intensity values of each grid cell zoom view of jpg file; grid of pixels apparent 38 39

Exercise (in groups) Compressing Bitmap Images How could you compress a bitmap image representation, i.e., reduce the number of bits required to store it? Hint: Think of the following images as examples: - A completely black image. - A night sky (mostly black). - An empty chess board (regular pattern of two colours) 40 Compressing Bitmap Images areas with similar colour can be modified to have the same colour "runs" of identical intensities can be collapsed 41 The second approach of compressing images is that "Areas with similar colour can be modified to have the same colour. This has the effect of increasing the lengths of runs with identical intensities, making the first approach more effective. But will this approach affect the quality of the compressed images since it considers areas with similar colour as ones with the same colour? data rep G = (9,33,25) scheme Y to = (221,192,127) Cells are ordered from top left to bottom right: [1,1],[1,2],,[1,6],[2,1],,[2,6] Ordered list of four maximum-length runs: (9,33,25) 1 (221,192,127) 3 (9,33,25) 4 (221,192,127) 4 Can the matrix be reconstructed from the list of runs alone? (A yes, B no) Selected RQs: collapsing runs: example two techniques used by.jpg files ((submitted by Qian Zeng) 42 43