﻿1
00:00:05,480 --> 00:00:06,680
Welcome back.

2
00:00:06,710 --> 00:00:11,480
Now that we understand how to work with the basics of dumpsite arrays Let's quickly talk about what

3
00:00:11,480 --> 00:00:14,140
an image actually is.

4
00:00:14,140 --> 00:00:19,450
So before we talk about how to use pi specifically if image files Let's first discuss how computers

5
00:00:19,450 --> 00:00:21,460
themselves handle images.

6
00:00:21,460 --> 00:00:26,620
Let's imagine that we want to build software that could sort out mail based on the zip code of the address

7
00:00:26,920 --> 00:00:33,020
written on the envelope often mail is handwritten which means we would somehow need to begin to understand

8
00:00:33,290 --> 00:00:38,100
how to use computer vision to actually read in image data of these handwritten digits.

9
00:00:38,120 --> 00:00:43,130
So most likely we're going to be working with an image such as a photograph of the envelope like a TNG

10
00:00:43,160 --> 00:00:43,930
or jpeg.

11
00:00:44,000 --> 00:00:47,850
And we want to understand how does a computer actually represent image data.

12
00:00:47,870 --> 00:00:50,980
Let's imagine we have a simple image of a handwritten number.

13
00:00:50,990 --> 00:00:54,410
So here we have images of numbers 1 2 and 3.

14
00:00:54,470 --> 00:00:57,100
And these are either jpeg or PNB files.

15
00:00:58,020 --> 00:01:01,770
Each single digit image can be actually represented as an array.

16
00:01:01,800 --> 00:01:07,600
So here we have the numbers zero through 9 and these are all being represented as an array.

17
00:01:07,600 --> 00:01:12,880
So for example here is a number represented by 28 by 28 pixels.

18
00:01:12,880 --> 00:01:17,620
You can imagine that as we get more and more pixels we'll have finer and finer resolution.

19
00:01:17,620 --> 00:01:23,110
You'll also notice that the image on the left is grayscale meaning it's only black or white or some

20
00:01:23,110 --> 00:01:29,220
color of gray and it's being represented as an array with values ranging from 0 to 1.

21
00:01:29,440 --> 00:01:34,550
So how dark a pixel should be can be represented as those values between 0 and 1.

22
00:01:34,600 --> 00:01:40,180
So you'll notice here we have a number one as the hand-written digit and where it's Darcus it's represented

23
00:01:40,270 --> 00:01:42,850
as a single digit one in or it's completely white.

24
00:01:42,880 --> 00:01:44,890
It's represented as 0.

25
00:01:44,890 --> 00:01:52,630
Now often default images when you actually read them in they have values between 0 and 255 where 255

26
00:01:52,690 --> 00:01:56,700
is the highest or brightest value and zero is the darkest.

27
00:01:56,940 --> 00:02:02,910
The range 0 to 255 that actually has to do with how computer store 8 bit numbers that's a bit outside

28
00:02:02,910 --> 00:02:06,990
the scope of this course and we really don't need to understand it but at the end I'll show you a couple

29
00:02:07,020 --> 00:02:09,540
links that you can check out for more information.

30
00:02:10,780 --> 00:02:16,900
Now if you ever wanted to get those values between 0 0 and 255 to be between 0 and 1 all you would need

31
00:02:16,900 --> 00:02:19,430
to do is divide by the max value to 5.

32
00:02:19,600 --> 00:02:22,210
In order to normalize to between 0 and 1.

33
00:02:22,210 --> 00:02:26,000
And later on in the course we'll see some examples of doing that.

34
00:02:26,290 --> 00:02:30,150
So we've understood how grayscale images can be represented as arrays.

35
00:02:30,280 --> 00:02:38,090
But what about color images color images can be represented as a combination of red green and blue additive

36
00:02:38,090 --> 00:02:43,670
color mixing allows us to represent a wide variety of colors by simply combining different amounts of

37
00:02:43,850 --> 00:02:52,160
our GP or red green blue and our GP allows us to produce a range of colors and here we can see the entire

38
00:02:52,160 --> 00:02:58,790
dynamic range that just red green and blue allows you to create this sort of image is known as a color

39
00:02:58,790 --> 00:03:04,640
triangle and Biscoe what that means is only colors within this triangle can be reproduced by mixing

40
00:03:04,640 --> 00:03:10,400
the primary colors that is red green and blue colors outside the color triangle are therefore shown

41
00:03:10,400 --> 00:03:17,480
here is gray and the primaries and the D6 five that point in the middle that's the white point and basically

42
00:03:17,480 --> 00:03:23,450
shows you the edges of what's producible and keep in mind that humans themselves have limits as far

43
00:03:23,450 --> 00:03:29,420
as what colors they can see but obviously red green and blue allows for quite a wide range later on

44
00:03:29,420 --> 00:03:34,130
in the course we're going to be learning about alternative color mappings that can be applied to images

45
00:03:34,250 --> 00:03:36,410
that go beyond just red green and blue.

46
00:03:36,470 --> 00:03:40,600
But for now red green and blue will be more than enough for us.

47
00:03:40,670 --> 00:03:45,530
So each color channel will have intensity values and you have already seen this sort of representation

48
00:03:45,530 --> 00:03:46,480
in other software.

49
00:03:46,500 --> 00:03:51,590
RG backsliders In fact you can just Google R.G. Boxleitner to play around these sort of values.

50
00:03:51,620 --> 00:03:56,300
So here you can play around the valleys of red green and blue to produce different colors all the way

51
00:03:56,510 --> 00:03:58,900
values from 0 to 255.

52
00:04:00,830 --> 00:04:06,700
So what does that actually mean when you've read in a color image with python and a computer in general.

53
00:04:06,980 --> 00:04:11,690
So what happens is when you read in an image it's going to actually have three dimensions a height that

54
00:04:11,720 --> 00:04:18,870
mention it with dimension and then through them actions for these color channels red green and blue.

55
00:04:18,950 --> 00:04:22,330
So this means that you're reading in the image and if you're a check it's shape.

56
00:04:22,370 --> 00:04:23,970
If you read it as an umpire.

57
00:04:24,260 --> 00:04:28,940
The shape is going to be something like 12 A.D. by 720 by three.

58
00:04:28,940 --> 00:04:34,950
So that would be the pixel with the pixel height and then the actual three color channels.

59
00:04:34,970 --> 00:04:40,430
So if we were to actually visualize this basically you have a three dimensional array where we have

60
00:04:40,430 --> 00:04:43,480
the typical to them mentions except now you have three of those.

61
00:04:43,520 --> 00:04:46,560
One for each major color.

62
00:04:46,870 --> 00:04:51,060
Keep in mind the computer itself won't know that a channel is red.

63
00:04:51,130 --> 00:04:56,500
It just knows that there are now three intensity channels essentially three sort of grayscale channels

64
00:04:56,800 --> 00:04:58,730
representing a color.

65
00:04:58,750 --> 00:05:02,950
So notice that when the computer actually reads it in it gets something that looks like this last column

66
00:05:02,950 --> 00:05:04,540
here black and white.

67
00:05:04,540 --> 00:05:09,400
It's up to whatever software are using to actually represent those as color in order to combine them

68
00:05:09,430 --> 00:05:11,700
to get that left image all the way on the left.

69
00:05:11,820 --> 00:05:12,910
Or we have the parrot.

70
00:05:13,090 --> 00:05:16,500
So keep in mind we're still getting values peine 0 and 255.

71
00:05:16,620 --> 00:05:23,000
It's just now we have three of those mappings one for red one for green and one for blue.

72
00:05:23,030 --> 00:05:27,920
So the user needs to dictate which channel is for which color each channel alone is essentially the

73
00:05:27,920 --> 00:05:29,910
same as a single greyscale image.

74
00:05:31,370 --> 00:05:34,130
So let's explore this further if some pie in Python.

75
00:05:34,310 --> 00:05:38,830
I also highly encourage you to check out the Wikipedia article on R.G. color channeling.

76
00:05:38,870 --> 00:05:44,120
It's called RGV color model and has a lot of interesting details as well as the history of our G-B color

77
00:05:44,120 --> 00:05:47,620
model and a couple of more fun things to play around with.

78
00:05:47,630 --> 00:05:48,060
OK.

79
00:05:48,290 --> 00:05:51,290
So let's move on and explore this further with non-high in Python.

80
00:05:51,290 --> 00:05:52,260
I'll see you at the next lecture.


