Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:03,220 --> 00:00:09,180
Considered these greyscale image. Now this image is made of pixels.
2
00:00:09,270 --> 00:00:16,500
This particular one has three by five so it has 15 pixels so it's quite a small image.
3
00:00:16,500 --> 00:00:24,330
Now each pixel has a value and that's what defines the intensity of the gray color for each pixel.
4
00:00:24,330 --> 00:00:33,030
So in reality these are numbers but our computer display shows them in a color format which is easy
5
00:00:33,030 --> 00:00:35,120
readable by us humans.
6
00:00:35,130 --> 00:00:42,900
Where I'm trying to get is that programs use numbers to store images then the computer display or so
7
00:00:42,900 --> 00:00:46,890
the screen converts these numbers to colors.
8
00:00:46,960 --> 00:00:52,150
Python can also do image processing just like Photoshop does.
9
00:00:52,230 --> 00:00:58,740
Probably it cannot do all the cool stuff that you can do with Photoshop but you can make use of Python
10
00:00:58,740 --> 00:01:06,220
to automate things for instance we'll be using the image processing capabilities of Python to detect faces
11
00:01:06,270 --> 00:01:12,640
from photos, from images and also detect moving objects in videos as well.
12
00:01:12,840 --> 00:01:15,040
So videos are made of images.
13
00:01:15,180 --> 00:01:16,720
So it's the same thing basically.
14
00:01:17,040 --> 00:01:22,600
And Python stores and reads images using arrays of numbers.
15
00:01:22,800 --> 00:01:31,800
For instance this image could be represented as you know a list of three other lists.
16
00:01:34,440 --> 00:01:42,180
So three lists because we have 3 rows in there with pixels and than in each of these you would have like
17
00:01:42,480 --> 00:01:50,950
five numbers and so on and so one and the fifth and the same for the other two lists.
18
00:01:51,060 --> 00:01:57,320
We've got five numbers because we have five columns so five pixels for each row.
19
00:01:57,570 --> 00:01:59,730
That's an image for Python.
20
00:01:59,820 --> 00:02:03,840
And here is where Numpy comes in handy.
21
00:02:03,840 --> 00:02:12,980
So while you can represent images with lists as we did here this is not very efficient because
22
00:02:13,110 --> 00:02:14,150
for big images
23
00:02:14,150 --> 00:02:19,590
lists occupy a lot of memory and therefore they slow down operations on them.
24
00:02:19,690 --> 00:02:27,000
So this is solved by Numpy which is a library, a Python library that provides a multi dimensional
25
00:02:27,000 --> 00:02:28,560
array object.
26
00:02:28,590 --> 00:02:33,980
So let me go ahead and create this array object.
27
00:02:34,320 --> 00:02:37,950
First of all you what you need to do is you need to import Numpy.
28
00:02:38,350 --> 00:02:44,610
And if you have installed Pandas, Numpy should have been installed with Pandas because Pandas is based
29
00:02:44,610 --> 00:02:46,130
on Numpy.
30
00:02:46,770 --> 00:02:51,550
If you haven't installed Numpy just yet just yet, just go had and pip install Numpy.
31
00:02:51,760 --> 00:02:55,990
Ad if for some reason you have some problems on Windows then just go
32
00:02:56,220 --> 00:02:57,570
ahead as I've showed you
33
00:02:57,660 --> 00:02:59,690
and find the precompiled Python libraries.
34
00:02:59,760 --> 00:03:07,720
Go to this site and search for Numpy and then figure out if you are on a 3.5 version of Python then
35
00:03:07,720 --> 00:03:14,320
just get that version and you pointed to this file with pip install and the name of the file.
36
00:03:14,340 --> 00:03:25,020
Great. Now I have Numpy installed so I'll create this multi dimensional object and store it in the N variable.
37
00:03:25,060 --> 00:03:25,750
38
00:03:26,070 --> 00:03:33,020
Let it be numpy.arange and let's say 27.
39
00:03:33,050 --> 00:03:34,820
Execute that.
40
00:03:34,910 --> 00:03:39,390
And print out N.
41
00:03:39,480 --> 00:03:41,650
So this is a Numpy array. That's how it is called.
42
00:03:41,670 --> 00:03:49,370
This particular one is not exactly a multi dimensional array because it only has one dimension so it's
43
00:03:49,580 --> 00:03:50,340
a plane�
44
00:03:50,340 --> 00:03:51,280
It's like a plane list.
45
00:03:51,380 --> 00:03:52,560
A Python list.
46
00:03:52,590 --> 00:03:59,680
But still it's not exactly a list.
47
00:03:59,760 --> 00:04:00,600
Type. Sorry.
48
00:04:01,140 --> 00:04:04,970
So it's a Numpy N dimensional array.
49
00:04:05,130 --> 00:04:09,380
It can have one dimensional two or three.
50
00:04:09,390 --> 00:04:16,370
So we have one, two, three and I'll show all these scenarios. So that was the one dimensional array.
51
00:04:16,380 --> 00:04:23,330
And if you want to print it in a nice form that'd be the array.
52
00:04:23,770 --> 00:04:27,220
Now I'm just creating
53
00:04:27,420 --> 00:04:35,720
a Numpy array using numbers on the fly here but normally you'd have to create arrays from images.
54
00:04:35,880 --> 00:04:38,240
I will do that in just a bit so for now
55
00:04:38,250 --> 00:04:40,610
let's create some arrays manually.
56
00:04:40,790 --> 00:04:47,420
Now let's see what two dimensional arrays� Reshape three by nine.
57
00:04:47,430 --> 00:04:53,550
So we already have this one dimensional array and we want to convert it to a two dimensional array.
58
00:04:53,910 --> 00:04:56,750
If you execute that you get a two dimensional array.
59
00:04:56,850 --> 00:05:00,350
So that's a two dimensional array because it has two dimensions.
60
00:05:00,360 --> 00:05:04,690
So think of it as this image file.
61
00:05:04,800 --> 00:05:08,930
We have two dimensions vertical and horizontal.
62
00:05:08,940 --> 00:05:15,450
Now what is a three dimensional array? Even though a three dimensional arrays are less frequently used
63
00:05:15,450 --> 00:05:15,680
64
00:05:15,830 --> 00:05:17,780
is still good to know them.
65
00:05:17,970 --> 00:05:20,540
And yeah, let me create a three dimensional array.
66
00:05:20,610 --> 00:05:27,810
I could say three by three by three because you know you have 27 elements so three by three by three
67
00:05:27,990 --> 00:05:31,220
gives you twenty seven and yup.
68
00:05:31,280 --> 00:05:33,250
That's a three dimensional rate.
69
00:05:33,360 --> 00:05:36,110
Think of that as a cube that has three dimensions.
70
00:05:36,160 --> 00:05:40,050
So three by three with me and practically you'll see that in just a bit
71
00:05:40,050 --> 00:05:44,880
in this lecture where do we deal with three dimensional array.
72
00:05:45,390 --> 00:05:54,170
So bear with me and you are you able to see the similarities between a Numpy array and a plain Python list
73
00:05:54,170 --> 00:05:55,080
of lists.
74
00:05:55,230 --> 00:06:03,600
So this here would be like a two dimensional array if you like to call it like that. The structure
75
00:06:03,690 --> 00:06:10,800
in the lower level is different between Python lists and Numpy arrays and also Numpy arrays allow you to make
76
00:06:10,810 --> 00:06:16,690
some more efficient operations such as iteration between the array items and so on.
77
00:06:16,800 --> 00:06:25,490
And you can also create a Numpy array out of Python lists. For instance I'll get this list here and I'll create
78
00:06:26,490 --> 00:06:33,930
a new object and then point to Numpy and to covert a list to a Numpy array
79
00:06:34,200 --> 00:06:42,360
you'd want to use Asarray method and then between the brackets goes the object that you want to convert.
80
00:06:43,180 --> 00:06:44,230
81
00:06:44,910 --> 00:06:52,520
And that's an array which is almost exactly like this on in here.
82
00:06:53,070 --> 00:06:56,170
And if you print that you wouldn't be able to see the difference.
83
00:06:56,910 --> 00:07:01,430
You know they look exactly the same but they are not.
84
00:07:01,430 --> 00:07:05,170
Because this is the least of this is a Numpy array.
85
00:07:05,430 --> 00:07:07,050
Great.
86
00:07:07,210 --> 00:07:08,440
Let's move on.
87
00:07:08,880 --> 00:07:09,810
So that's Numpy.
88
00:07:09,810 --> 00:07:14,710
And as I mentioned earlier Numpy is a base library for all the libraries.
89
00:07:15,030 --> 00:07:20,460
Such as Pandas and also OpenCV which is an image processing library.
90
00:07:20,460 --> 00:07:26,910
So Pandas data frames are based on Numpy arrays and OpenCV objects are based on Numpy arrays.
91
00:07:26,910 --> 00:07:27,170
92
00:07:27,210 --> 00:07:34,560
So Pandas, what Pandas does it just adds some cool features in there such as it adds,
93
00:07:34,600 --> 00:07:42,700
it gets capabilities for having table headers and indexes which you can't have in Numpy because Numpy
94
00:07:42,720 --> 00:07:51,150
is meant to be more simple and in a more low level of storing objects and doing operations.
95
00:07:51,240 --> 00:07:54,220
So Numpy is a requirement for many libraries.
96
00:07:54,390 --> 00:07:59,610
And yeah, let's stop this lecture in here and in the next lecture we'll go straight ahead and create
97
00:07:59,670 --> 00:08:03,770
a Numpy array out of our image should be in here.
98
00:08:04,230 --> 00:08:06,640
So this image. Ok, see with there.
9970
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.