So now let's move on to the third lesson.
This is called color spaces, so let's take a look at this pie python notebook.
So there we go, so it's fully loaded now, so you can see we're taking a look at three main things
in this chapter in this section.
We're looking at how to what the individual channels of an RG B image look like, how to manipulate
color spaces and what HSV color spaces.
So what we're going to do, we're going to at our functions and libraries, like with the previously
and downloadable images, all in one could boxes just quite convenient to setup, and it takes a few
seconds to run.
Actually, some of the time here it actually spends connecting to a color machine in the back end.
So we've got a machine and everything is running fine now.
So now let's load our image, the customary image here, storing it as the image variable and what we're
going to do.
We're going to use this function called CB2 Dot Split.
Now what's key to that split does it actually separates the image, which channels an image into that,
and it separates the tunnels into the tree components to blue, to green and red.
So you can actually see that the shape here is one that is two dimensional, not three-dimensional anymore,
because it's no cometary at the end.
So you can see effectively each one of them is a grayscale image.
And if you if you look at it here, the blue channel only it looks like a grayscale image because it's
only one dimension.
It's just the intensities in degree of the blue color component.
Now it's a bit confusing, but what we'll do?
So what we're going to do, we're going to create basically the tree, the tree dimension image.
It will trickle adepts.
That's red greens and blues.
We're going to create all of them there.
However, we're going to make all of the other colored components except the one we want to visualize.
Zero.
And to do that, we as create this basically this array called using zeros here.
This is in the image shape, dimensions here and image type.
So what this does is basically we create a blank matrix right here of this of this size.
This year I buy it.
That's it gets lost to them in two dimensions here.
And this basically forms this twelve eighty by nineteen sixty, I believe image.
So we have the zeros here, zeros here.
So when looking to read component here and likewise for the green and blue components, so let's run
this.
And you can see this is what each color component of that image, original image looks like.
So is this is this is more focused on just how to understand the color spaces of what goes into the
image.
There's not really much of a use case for these types of things unless you want to do some sort of filtering.
I'm not sure why, but it would probably have some weird applications where you may want to do it.
So this is good to know.
So, no, let's see if we can.
We can actually use this function here.
I think we split it up into the color components here.
We can remove it here and remake the original image.
So that gives us we just moved all of these back together inside of an array like this.
Remember to put the square brackets to get it back into the array?
Alice, I should say, and we get this merged copy here back of that, which is which is basically the
original image.
So let's amplify something this this the blue color and see what that looks like.
So you can see this looks quite weird.
Why didn't it has a lot of blue?
Yes, but has some green room somewhere reason than to be yellow?
And that's because of how we actually increased the color here.
I'll explain it to you shortly, but this is from this.
So what happens here is that we've added 100 to all of the blue dimensions here.
However, I remember some of these were quite dark.
So when S.A. merged with the red in the green, it gives you some really, really weird colors right
now.
Oh, I should see different colors, as you probably wouldn't have expected so much yellow to be formed
here.
So that's how these this this works, these color combinations, because if you ever wanted to interfere
what she and one of the individual color components here, you know how to do it.
You just split.
You could edit it and you can move it back.
And then you have this new image right here.
So now let's take a look at the HSV color color space.
So I took this image from Wikipedia because it actually shows you quite nicely how the HSV color closeby
is a colorful networks.
So now, instead of using red, green and blue, a combination of those to get colors, what it looks
at is basically it has a color map called Hue.
Hue ranges from this blue here all the way to the screen, and you have something called value, which
is intensity here, which is the brightness, so it can see darker colors here right up here and saturation,
which basically tells you the conflicts feed at appeal, but then it gets richer and deeper as you go
to the outskirts here, so that value controls that.
So using this color scheme here is a different way to represent colors, different color space, and
there's actually many more color spaces as well.
But these are the main ones we'll take a look at.
So you can see this is orange here.
Hugo is from zero to 179.
Saturation goes to zero to 255, just like in the RGV range before and similarly for value zero to 255.
So we're going to look our familiar image again and what we're going to do.
We're going to use that same color function that we've used previously to convert to gray and to convert
to from BGR to our TV.
We're going to use that to convert to HSV.
So you can see BGR two HSV here.
And let's just play it here.
And you can see this looks like a psychedelic, weird mess.
Pretty artistic, to be honest, but it's very weird.
And why is that?
And that's because this initial function here, that Plot Lab's function, it's only designed to represent
RGV images, not HSV images.
So it's interpreting each of the S and the colors dimension space as rugby, which gives us that image.
So you don't want to use that.
So to get it back to what we saw before, we're going to have to use this function here.
Just just be back to RGV to convert it back to a function, to an image type that can be displayed by
MATLAB.
So we can do this here and we get our image still.
So let's view what each I type in HSV color image looks like and the representation so you can just.
This is a way to actually depict more deeply understand how to hue, how to saturation, how it's tied
together to an image.
So by just doing this here, this what we're doing here is we're just trying to obtain only the H values
here.
All right.
So similarly for the other ones here.
So it's this hues saturation.
This is value and we're using the indexing in Python to extract only those values from its here.
So that's high way why we're doing this.
So let's run this function and we get the tree color spaces here.
So let's move up to the top and you can see.
You remember, Hugh is actually the color orange, so you can see the sand in the water and the trees
all look a little bit different, but you remember we're visual visual like visualizing this as a great
skill level of intensity.
So it may not tell you that much better than how well your brain can interpret this information saturation.
You can see where see where the brighter a whiter areas and more saturated because it's a higher value
and a value as well.
You can see from a value, it really adds to the intensity of brightness of the color.
So again, it should take look similar to this, which it doesn't, but it is what it is.
So you can see this is how we can look at the individual components of an HSV image.
So that concludes this lesson and color spaces.
Now let's move on to the fourth lesson here, which is drawing on images.
Thank you.