Welcome back.
Now that we understand how to work with the basics of dumpsite arrays Let's quickly talk about what
an image actually is.
So before we talk about how to use pi specifically if image files Let's first discuss how computers
themselves handle images.
Let's imagine that we want to build software that could sort out mail based on the zip code of the address
written on the envelope often mail is handwritten which means we would somehow need to begin to understand
how to use computer vision to actually read in image data of these handwritten digits.
So most likely we're going to be working with an image such as a photograph of the envelope like a TNG
or jpeg.
And we want to understand how does a computer actually represent image data.
Let's imagine we have a simple image of a handwritten number.
So here we have images of numbers 1 2 and 3.
And these are either jpeg or PNB files.
Each single digit image can be actually represented as an array.
So here we have the numbers zero through 9 and these are all being represented as an array.
So for example here is a number represented by 28 by 28 pixels.
You can imagine that as we get more and more pixels we'll have finer and finer resolution.
You'll also notice that the image on the left is grayscale meaning it's only black or white or some
color of gray and it's being represented as an array with values ranging from 0 to 1.
So how dark a pixel should be can be represented as those values between 0 and 1.
So you'll notice here we have a number one as the hand-written digit and where it's Darcus it's represented
as a single digit one in or it's completely white.
It's represented as 0.
Now often default images when you actually read them in they have values between 0 and 255 where 255
is the highest or brightest value and zero is the darkest.
The range 0 to 255 that actually has to do with how computer store 8 bit numbers that's a bit outside
the scope of this course and we really don't need to understand it but at the end I'll show you a couple
links that you can check out for more information.
Now if you ever wanted to get those values between 0 0 and 255 to be between 0 and 1 all you would need
to do is divide by the max value to 5.
In order to normalize to between 0 and 1.
And later on in the course we'll see some examples of doing that.
So we've understood how grayscale images can be represented as arrays.
But what about color images color images can be represented as a combination of red green and blue additive
color mixing allows us to represent a wide variety of colors by simply combining different amounts of
our GP or red green blue and our GP allows us to produce a range of colors and here we can see the entire
dynamic range that just red green and blue allows you to create this sort of image is known as a color
triangle and Biscoe what that means is only colors within this triangle can be reproduced by mixing
the primary colors that is red green and blue colors outside the color triangle are therefore shown
here is gray and the primaries and the D6 five that point in the middle that's the white point and basically
shows you the edges of what's producible and keep in mind that humans themselves have limits as far
as what colors they can see but obviously red green and blue allows for quite a wide range later on
in the course we're going to be learning about alternative color mappings that can be applied to images
that go beyond just red green and blue.
But for now red green and blue will be more than enough for us.
So each color channel will have intensity values and you have already seen this sort of representation
in other software.
RG backsliders In fact you can just Google R.G. Boxleitner to play around these sort of values.
So here you can play around the valleys of red green and blue to produce different colors all the way
values from 0 to 255.
So what does that actually mean when you've read in a color image with python and a computer in general.
So what happens is when you read in an image it's going to actually have three dimensions a height that
mention it with dimension and then through them actions for these color channels red green and blue.
So this means that you're reading in the image and if you're a check it's shape.
If you read it as an umpire.
The shape is going to be something like 12 A.D. by 720 by three.
So that would be the pixel with the pixel height and then the actual three color channels.
So if we were to actually visualize this basically you have a three dimensional array where we have
the typical to them mentions except now you have three of those.
One for each major color.
Keep in mind the computer itself won't know that a channel is red.
It just knows that there are now three intensity channels essentially three sort of grayscale channels
representing a color.
So notice that when the computer actually reads it in it gets something that looks like this last column
here black and white.
It's up to whatever software are using to actually represent those as color in order to combine them
to get that left image all the way on the left.
Or we have the parrot.
So keep in mind we're still getting values peine 0 and 255.
It's just now we have three of those mappings one for red one for green and one for blue.
So the user needs to dictate which channel is for which color each channel alone is essentially the
same as a single greyscale image.
So let's explore this further if some pie in Python.
I also highly encourage you to check out the Wikipedia article on R.G. color channeling.
It's called RGV color model and has a lot of interesting details as well as the history of our G-B color
model and a couple of more fun things to play around with.
OK.
So let's move on and explore this further with non-high in Python.
I'll see you at the next lecture.