260 likes | 419 Views
Welcome to the Computer Science Department Dr. Ben Schafer. So what does this have to do with computer science?. The news story talks about terrorists using a technique called “stegonography” which involves hiding text messages inside of other things.
E N D
So what does this have to do with computer science? • The news story talks about terrorists using a technique called “stegonography” which involves hiding text messages inside of other things. • A process easily easily done with a computer
But let’s start with a “magic” trick • Pick a number from 1-31 • Tell me which of the following cards this number appears on
Explaining the “magic” trick • Suppose you picked 25. • You would tell me that your number was on cards 1, 2, and 5 • I just add up the numbers from the upper left hand corners of those cards 16 + 8 + 1 = 25
The concept of Binary • In the decimal system (base ten) each position in a number can hold one of ten digits • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 • In the binary system (base two) each position in a number can hold one of two digits • 0, 1
The concept of Binary • In the decimal system (base ten) we treat positions as powers of ten • 1’s place, 10’s place, 100’s place, etc. • which is 100 place, 101 place, 102 place, etc. • In the binary system (base two) we treat positions as powers of two • 1’s place, 2’s place, 4’s place, 8’s place… • which is 20 place, 21 place, 22 place, 23 place, etc.
The concept of Binary • In decimal, when we get to 9, we’ve run out of digits • next number is 10 • after 9999 is 10000 • In binary, when we get to 1, we’ve run out of digits • next number is 10 • after 1111 is 10000
The concept of Binary 0 00000000 (8-bit) 1 00000001 (8-bit) 2 00000010 (8-bit) 3 00000011 (8-bit) (1 + 2) 4 00000100 (8-bit) 127 01111111 (8-bit) (1 + 2 + 4 + 8 + 16 + 32 + 64)
Your turn • What decimal numbers are represented by the following binary numbers? Example: 0101 = 5 0100 1101 110011 • Answers [4, 13, 51]
How big is a byte? • The standard unit of a computer is a Byte which is 8 bits • How big is that? • How many different numbers are stored in a byte? 2x2x2x2x2x2x2x2 = 28 = 256 possible combinations
So then how do we store letters? ASCII code - A simple conversion of the common American characters and computer commands to numbers. ‘A’ = 65 ‘a’ = 97 ‘1’ = 49 See www.asciitable.com for more information
How Does Color Vision Work? • Our eyes and brain work together to make sense of what we see • The cones in our eyes are what allow us to see in color • The rods allow us to see black, white, and shades of gray • Our cones are sensitive to red, green, and blue light • All other colors are combinations of these
Red, Green and Blue Light • Black is the absence of all light • No red, green or blue light • White light is a combination of red, green, and blue • Full intensity red, green, and blue combined • All other colors are combinations • Of red, green, and blue • Of different intensities
Color Exercise • Type pickAColor() • Select the RGB tab • Use the Red, Green and Blue slider/boxes to create some colors such as white, black, red, blue, green, yellow, violet, and orange
Pictures are made up of Pixels • Digital cameras record light at pixels • Monitors display pictures using pixels • Our limited vision acuity helps us to see the discrete pixels as a smooth picture • If we blow up the picture we can see the pixels
Digital Pictures • Capture the intensity of the red, green, and blue colors at each pixel • Stored as a bunch of numbers • 8 bits for red, 8 bits for green, 8 bits for blue • Need nearly 1 million bytes to store a 640 x 480 picture • Need 3 million bytes to store an image from a 1 megapixel (million pixel) camera • Displayed as red, green, and blue colors on the computer display • Lots of them close together • Our brain sees a smooth color image
So how would we store a message inside of a picture? • The “easy” way • To store a message n characters long, change the red bit of each of the first n pixels to store the ASCII value of one of the characters. • [Demo simpleEncode() for both message.txt and hamlet.txt] • Unfortunately, this looks pretty obvious if the message is long
So how would we store a message inside of a picture? • Pixel[0,0] = (255,30,30) • Pixel[1,0] = (30,30,255) • Pixel[2,0] = (30,255,30) • Pixel[3,0] = (0,0,0) • Pixel[4,0] = (255,128,128) • …
So how would we store a message inside of a picture? • Char#1 = H = 072 • Char#2 = e = 101 • Char#3 = l = 108 • Char#4 = l = 108 • Char#5 = o = 111 • Pixel[0,0] = (255,30,30) • Pixel[1,0] = (30,30,255) • Pixel[2,0] = (30,255,30) • Pixel[3,0] = (0,0,0) • Pixel[4,0] = (255,128,128) • …
So how would we store a message inside of a picture? • Char#1 = H = 072 • Char#2 = e = 101 • Char#3 = l = 108 • Char#4 = l = 108 • Char#5 = o = 111 • Pixel[0,0] = (072,30,30) • Pixel[1,0] = (101,30,255) • Pixel[2,0] = (108,255,30) • Pixel[3,0] = (108,0,0) • Pixel[4,0] = (111,128,128) • …
So how would we store a message inside of a picture? • The “easy” way • To store a message n characters long, change the red bit of each of the first n pixels to store the ASCII value of one of the characters. • [Demo simpleEncode() for both message.txt and hamlet.txt] • Unfortunately, this looks pretty obvious if the message is long
So how would we store a message inside of a picture? • The “harder” way • To store a message n characters long, split the ASCII value of each character into three pieces and change the “ones” part of the red, green, and blue bits to store one of these pieces. • fancyEncode()
So how would we store a message inside of a picture? • Char#1 = H = 072 • Char#2 = e = 101 • Char#3 = l = 108 • Char#4 = l = 108 • Char#5 = o = 111 • Pixel[0,0] = (255,30,30) • Pixel[1,0] = (30,30,255) • Pixel[2,0] = (30,255,30) • Pixel[3,0] = (0,0,0) • Pixel[4,0] = (255,128,128) • …
So how would we store a message inside of a picture? • Char#1 = H = 072 • Char#2 = e = 101 • Char#3 = l = 108 • Char#4 = l = 108 • Char#5 = o = 111 • Pixel[0,0] = (255,30,30) • Pixel[1,0] = (30,30,255) • Pixel[2,0] = (30,255,30) • Pixel[3,0] = (0,0,0) • Pixel[4,0] = (255,128,128) • …
So how would we store a message inside of a picture? • Char#1 = H = 072 • Char#2 = e = 101 • Char#3 = l = 108 • Char#4 = l = 108 • Char#5 = o = 111 • Pixel[0,0] = (250,37,32) • Pixel[1,0] = (31,30,251) • Pixel[2,0] = (31,250,38) • Pixel[3,0] = (1, 0, 8) • Pixel[4,0] = (251,120,121) • …