Considered these greyscale image. Now this image is made of pixels.
This particular one has three by five so it has 15 pixels so it's quite a small image.
Now each pixel has a value and that's what defines the intensity of the gray color for each pixel.
So in reality these are numbers but our computer display shows them in a color format which is easy
readable by us humans.
Where I'm trying to get is that programs use numbers to store images then the computer display or so
the screen converts these numbers to colors.
Python can also do image processing just like Photoshop does.
Probably it cannot do all the cool stuff that you can do with Photoshop but you can make use of Python
to automate things for instance we'll be using the image processing capabilities of Python to detect faces
from photos, from images and also detect moving objects in videos as well.
So videos are made of images.
So it's the same thing basically.
And Python stores and reads images using arrays of numbers.
For instance this image could be represented as you know a list of three other lists.
So three lists because we have 3 rows in there with pixels and than in each of these you would have like
five numbers and so on and so one and the fifth and the same for the other two lists.
We've got five numbers because we have five columns so five pixels for each row.
That's an image for Python.
And here is where Numpy comes in handy.
So while you can represent images with lists as we did here this is not very efficient because
for big images
lists occupy a lot of memory and therefore they slow down operations on them.
So this is solved by Numpy which is a library, a Python library that provides a multi dimensional
array object.
So let me go ahead and create this array object.
First of all you what you need to do is you need to import Numpy.
And if you have installed Pandas, Numpy should have been installed with Pandas because Pandas is based
on Numpy.
If you haven't installed Numpy just yet just yet, just go had and pip install Numpy.
Ad if for some reason you have some problems on Windows then just go
ahead as I've showed you
and find the precompiled Python libraries.
Go to this site and search for Numpy and then figure out if you are on a 3.5 version of Python then
just get that version and you pointed to this file with pip install and the name of the file.
Great. Now I have Numpy installed so I'll create this multi dimensional object and store it in the N variable.
Let it be numpy.arange and let's say 27.
Execute that.
And print out N.
So this is a Numpy array. That's how it is called.
This particular one is not exactly a multi dimensional array because it only has one dimension so it's
a plane
It's like a plane list.
A Python list.
But still it's not exactly a list.
Type. Sorry.
So it's a Numpy N dimensional array.
It can have one dimensional two or three.
So we have one, two, three and I'll show all these scenarios. So that was the one dimensional array.
And if you want to print it in a nice form that'd be the array.
Now I'm just creating
a Numpy array using numbers on the fly here but normally you'd have to create arrays from images.
I will do that in just a bit so for now
let's create some arrays manually.
Now let's see what two dimensional arrays Reshape three by nine.
So we already have this one dimensional array and we want to convert it to a two dimensional array.
If you execute that you get a two dimensional array.
So that's a two dimensional array because it has two dimensions.
So think of it as this image file.
We have two dimensions vertical and horizontal.
Now what is a three dimensional array? Even though a three dimensional arrays are less frequently used
is still good to know them.
And yeah, let me create a three dimensional array.
I could say three by three by three because you know you have 27 elements so three by three by three
gives you twenty seven and yup.
That's a three dimensional rate.
Think of that as a cube that has three dimensions.
So three by three with me and practically you'll see that in just a bit
in this lecture where do we deal with three dimensional array.
So bear with me and you are you able to see the similarities between a Numpy array and a plain Python list
of lists.
So this here would be like a two dimensional array if you like to call it like that. The structure
in the lower level is different between Python lists and Numpy arrays and also Numpy arrays allow you to make
some more efficient operations such as iteration between the array items and so on.
And you can also create a Numpy array out of Python lists. For instance I'll get this list here and I'll create
a new object and then point to Numpy and to covert a list to a Numpy array
you'd want to use Asarray method and then between the brackets goes the object that you want to convert.
And that's an array which is almost exactly like this on in here.
And if you print that you wouldn't be able to see the difference.
You know they look exactly the same but they are not.
Because this is the least of this is a Numpy array.
Great.
Let's move on.
So that's Numpy.
And as I mentioned earlier Numpy is a base library for all the libraries.
Such as Pandas and also OpenCV which is an image processing library.
So Pandas data frames are based on Numpy arrays and OpenCV objects are based on Numpy arrays.
So Pandas, what Pandas does it just adds some cool features in there such as it adds,
it gets capabilities for having table headers and indexes which you can't have in Numpy because Numpy
is meant to be more simple and in a more low level of storing objects and doing operations.
So Numpy is a requirement for many libraries.
And yeah, let's stop this lecture in here and in the next lecture we'll go straight ahead and create
a Numpy array out of our image should be in here.
So this image. Ok, see with there.