1
00:00:00,900 --> 00:00:02,940
So now let's move on to the third lesson.

2
00:00:03,210 --> 00:00:07,850
This is called color spaces, so let's take a look at this pie python notebook.

3
00:00:11,370 --> 00:00:16,830
So there we go, so it's fully loaded now, so you can see we're taking a look at three main things

4
00:00:16,830 --> 00:00:18,960
in this chapter in this section.

5
00:00:19,650 --> 00:00:25,380
We're looking at how to what the individual channels of an RG B image look like, how to manipulate

6
00:00:25,380 --> 00:00:29,040
color spaces and what HSV color spaces.

7
00:00:29,670 --> 00:00:34,410
So what we're going to do, we're going to at our functions and libraries, like with the previously

8
00:00:34,410 --> 00:00:40,440
and downloadable images, all in one could boxes just quite convenient to setup, and it takes a few

9
00:00:40,440 --> 00:00:41,310
seconds to run.

10
00:00:43,560 --> 00:00:49,080
Actually, some of the time here it actually spends connecting to a color machine in the back end.

11
00:00:49,740 --> 00:00:52,320
So we've got a machine and everything is running fine now.

12
00:00:53,490 --> 00:00:59,940
So now let's load our image, the customary image here, storing it as the image variable and what we're

13
00:00:59,940 --> 00:01:00,480
going to do.

14
00:01:00,540 --> 00:01:03,570
We're going to use this function called CB2 Dot Split.

15
00:01:04,170 --> 00:01:10,290
Now what's key to that split does it actually separates the image, which channels an image into that,

16
00:01:10,530 --> 00:01:15,540
and it separates the tunnels into the tree components to blue, to green and red.

17
00:01:16,140 --> 00:01:21,630
So you can actually see that the shape here is one that is two dimensional, not three-dimensional anymore,

18
00:01:21,780 --> 00:01:23,610
because it's no cometary at the end.

19
00:01:24,210 --> 00:01:27,870
So you can see effectively each one of them is a grayscale image.

20
00:01:28,320 --> 00:01:34,440
And if you if you look at it here, the blue channel only it looks like a grayscale image because it's

21
00:01:34,440 --> 00:01:35,790
only one dimension.

22
00:01:36,270 --> 00:01:40,440
It's just the intensities in degree of the blue color component.

23
00:01:41,250 --> 00:01:43,560
Now it's a bit confusing, but what we'll do?

24
00:01:44,310 --> 00:01:51,420
So what we're going to do, we're going to create basically the tree, the tree dimension image.

25
00:01:52,000 --> 00:01:53,190
It will trickle adepts.

26
00:01:53,190 --> 00:01:54,630
That's red greens and blues.

27
00:01:54,990 --> 00:01:56,610
We're going to create all of them there.

28
00:01:56,880 --> 00:02:01,770
However, we're going to make all of the other colored components except the one we want to visualize.

29
00:02:01,920 --> 00:02:02,400
Zero.

30
00:02:02,790 --> 00:02:08,760
And to do that, we as create this basically this array called using zeros here.

31
00:02:09,420 --> 00:02:13,050
This is in the image shape, dimensions here and image type.

32
00:02:13,530 --> 00:02:19,800
So what this does is basically we create a blank matrix right here of this of this size.

33
00:02:20,010 --> 00:02:21,570
This year I buy it.

34
00:02:21,930 --> 00:02:24,390
That's it gets lost to them in two dimensions here.

35
00:02:25,350 --> 00:02:31,320
And this basically forms this twelve eighty by nineteen sixty, I believe image.

36
00:02:31,800 --> 00:02:33,830
So we have the zeros here, zeros here.

37
00:02:33,840 --> 00:02:39,210
So when looking to read component here and likewise for the green and blue components, so let's run

38
00:02:39,210 --> 00:02:39,600
this.

39
00:02:42,350 --> 00:02:46,640
And you can see this is what each color component of that image, original image looks like.

40
00:02:47,270 --> 00:02:53,390
So is this is this is more focused on just how to understand the color spaces of what goes into the

41
00:02:53,390 --> 00:02:53,690
image.

42
00:02:54,200 --> 00:02:58,760
There's not really much of a use case for these types of things unless you want to do some sort of filtering.

43
00:02:59,270 --> 00:03:03,320
I'm not sure why, but it would probably have some weird applications where you may want to do it.

44
00:03:04,010 --> 00:03:05,900
So this is good to know.

45
00:03:06,110 --> 00:03:08,480
So, no, let's see if we can.

46
00:03:08,480 --> 00:03:10,130
We can actually use this function here.

47
00:03:10,820 --> 00:03:12,740
I think we split it up into the color components here.

48
00:03:13,220 --> 00:03:16,040
We can remove it here and remake the original image.

49
00:03:16,580 --> 00:03:21,120
So that gives us we just moved all of these back together inside of an array like this.

50
00:03:22,040 --> 00:03:24,470
Remember to put the square brackets to get it back into the array?

51
00:03:25,440 --> 00:03:32,600
Alice, I should say, and we get this merged copy here back of that, which is which is basically the

52
00:03:32,600 --> 00:03:33,770
original image.

53
00:03:34,640 --> 00:03:40,370
So let's amplify something this this the blue color and see what that looks like.

54
00:03:41,180 --> 00:03:42,590
So you can see this looks quite weird.

55
00:03:42,710 --> 00:03:44,240
Why didn't it has a lot of blue?

56
00:03:44,250 --> 00:03:47,660
Yes, but has some green room somewhere reason than to be yellow?

57
00:03:48,710 --> 00:03:51,950
And that's because of how we actually increased the color here.

58
00:03:52,610 --> 00:03:54,920
I'll explain it to you shortly, but this is from this.

59
00:03:55,400 --> 00:04:00,050
So what happens here is that we've added 100 to all of the blue dimensions here.

60
00:04:00,590 --> 00:04:02,810
However, I remember some of these were quite dark.

61
00:04:02,810 --> 00:04:08,030
So when S.A. merged with the red in the green, it gives you some really, really weird colors right

62
00:04:08,030 --> 00:04:08,270
now.

63
00:04:08,300 --> 00:04:13,010
Oh, I should see different colors, as you probably wouldn't have expected so much yellow to be formed

64
00:04:13,010 --> 00:04:13,250
here.

65
00:04:13,940 --> 00:04:19,790
So that's how these this this works, these color combinations, because if you ever wanted to interfere

66
00:04:19,790 --> 00:04:24,140
what she and one of the individual color components here, you know how to do it.

67
00:04:24,140 --> 00:04:24,980
You just split.

68
00:04:25,520 --> 00:04:27,500
You could edit it and you can move it back.

69
00:04:27,500 --> 00:04:29,570
And then you have this new image right here.

70
00:04:30,440 --> 00:04:34,130
So now let's take a look at the HSV color color space.

71
00:04:34,130 --> 00:04:41,150
So I took this image from Wikipedia because it actually shows you quite nicely how the HSV color closeby

72
00:04:41,150 --> 00:04:42,290
is a colorful networks.

73
00:04:42,800 --> 00:04:50,360
So now, instead of using red, green and blue, a combination of those to get colors, what it looks

74
00:04:50,360 --> 00:04:53,090
at is basically it has a color map called Hue.

75
00:04:53,570 --> 00:05:00,350
Hue ranges from this blue here all the way to the screen, and you have something called value, which

76
00:05:00,350 --> 00:05:07,400
is intensity here, which is the brightness, so it can see darker colors here right up here and saturation,

77
00:05:07,790 --> 00:05:13,460
which basically tells you the conflicts feed at appeal, but then it gets richer and deeper as you go

78
00:05:13,460 --> 00:05:16,520
to the outskirts here, so that value controls that.

79
00:05:16,640 --> 00:05:22,910
So using this color scheme here is a different way to represent colors, different color space, and

80
00:05:22,910 --> 00:05:25,310
there's actually many more color spaces as well.

81
00:05:25,310 --> 00:05:27,050
But these are the main ones we'll take a look at.

82
00:05:27,590 --> 00:05:29,120
So you can see this is orange here.

83
00:05:29,160 --> 00:05:31,070
Hugo is from zero to 179.

84
00:05:31,520 --> 00:05:39,590
Saturation goes to zero to 255, just like in the RGV range before and similarly for value zero to 255.

85
00:05:40,670 --> 00:05:44,420
So we're going to look our familiar image again and what we're going to do.

86
00:05:44,780 --> 00:05:51,110
We're going to use that same color function that we've used previously to convert to gray and to convert

87
00:05:51,110 --> 00:05:52,940
to from BGR to our TV.

88
00:05:53,600 --> 00:05:55,400
We're going to use that to convert to HSV.

89
00:05:55,460 --> 00:05:57,860
So you can see BGR two HSV here.

90
00:05:58,940 --> 00:06:00,410
And let's just play it here.

91
00:06:00,680 --> 00:06:04,640
And you can see this looks like a psychedelic, weird mess.

92
00:06:05,240 --> 00:06:08,430
Pretty artistic, to be honest, but it's very weird.

93
00:06:08,660 --> 00:06:09,770
And why is that?

94
00:06:09,950 --> 00:06:16,550
And that's because this initial function here, that Plot Lab's function, it's only designed to represent

95
00:06:16,550 --> 00:06:19,400
RGV images, not HSV images.

96
00:06:19,820 --> 00:06:27,970
So it's interpreting each of the S and the colors dimension space as rugby, which gives us that image.

97
00:06:28,040 --> 00:06:29,230
So you don't want to use that.

98
00:06:29,240 --> 00:06:35,510
So to get it back to what we saw before, we're going to have to use this function here.

99
00:06:36,510 --> 00:06:43,520
Just just be back to RGV to convert it back to a function, to an image type that can be displayed by

100
00:06:44,270 --> 00:06:44,990
MATLAB.

101
00:06:45,740 --> 00:06:49,250
So we can do this here and we get our image still.

102
00:06:50,090 --> 00:06:57,680
So let's view what each I type in HSV color image looks like and the representation so you can just.

103
00:06:57,740 --> 00:07:04,040
This is a way to actually depict more deeply understand how to hue, how to saturation, how it's tied

104
00:07:04,040 --> 00:07:04,820
together to an image.

105
00:07:05,390 --> 00:07:14,240
So by just doing this here, this what we're doing here is we're just trying to obtain only the H values

106
00:07:14,240 --> 00:07:14,570
here.

107
00:07:15,170 --> 00:07:15,500
All right.

108
00:07:16,520 --> 00:07:18,260
So similarly for the other ones here.

109
00:07:18,620 --> 00:07:20,250
So it's this hues saturation.

110
00:07:20,260 --> 00:07:28,820
This is value and we're using the indexing in Python to extract only those values from its here.

111
00:07:29,270 --> 00:07:31,250
So that's high way why we're doing this.

112
00:07:31,970 --> 00:07:37,190
So let's run this function and we get the tree color spaces here.

113
00:07:37,850 --> 00:07:40,700
So let's move up to the top and you can see.

114
00:07:41,630 --> 00:07:48,020
You remember, Hugh is actually the color orange, so you can see the sand in the water and the trees

115
00:07:48,020 --> 00:07:53,030
all look a little bit different, but you remember we're visual visual like visualizing this as a great

116
00:07:53,030 --> 00:07:54,530
skill level of intensity.

117
00:07:54,540 --> 00:08:01,670
So it may not tell you that much better than how well your brain can interpret this information saturation.

118
00:08:01,850 --> 00:08:09,530
You can see where see where the brighter a whiter areas and more saturated because it's a higher value

119
00:08:10,790 --> 00:08:12,620
and a value as well.

120
00:08:12,650 --> 00:08:17,480
You can see from a value, it really adds to the intensity of brightness of the color.

121
00:08:17,900 --> 00:08:23,750
So again, it should take look similar to this, which it doesn't, but it is what it is.

122
00:08:24,410 --> 00:08:29,210
So you can see this is how we can look at the individual components of an HSV image.

123
00:08:29,750 --> 00:08:32,360
So that concludes this lesson and color spaces.

124
00:08:32,870 --> 00:08:37,370
Now let's move on to the fourth lesson here, which is drawing on images.

125
00:08:37,580 --> 00:08:38,030
Thank you.
