So now let's move on to section four, where we take a look at drawing on images.
So let's open up this notebook here.
Let's close off the previous two to one.
So here we go.
So now let's look at this chapter.
Him the chapters pretty cool and pretty useful.
And it's something that even though it's it's a bit silly, but it's something that we actually do often
in computer vision, which is putting text on images to four different labels or for whatever reason.
But it's something you might do quite often just do if you just want to enhance a show of your work.
So you'll see how how it's done in Open City now.
So again, let's just load off or input our libraries and motor function or plotting function.
So now we can do something here.
Let's firstly create a black blank image.
So we're going to create an image here five, 12 by 512 by tree, which means it's a color black image
as opposed to a gray scale black image, which looks the same.
It's black as again.
As you can see here, we can make a black and white grayscale one to remember with zeros.
Everything is going to be dark, dearest, darkest color, which is absence of color, which is black.
So we can plot this here, and you can see we get two images right here.
Will be black and gray scale black, if exactly the same thing.
However, this one is going to take up to three times the memory space because it has three dimensions
three, five, 12 three times.
So now let's take a look at see how we can draw a line of all black square.
So the reason we actually have a watch three dimensional black image here is because we want our blue
line to show up as blue as opposed to gray.
So we want to have a color image effectively so quick to open.
TV has a cool function called a v2.0 line.
And it takes the input of our image here.
It takes this is a starting coordinates here, which is zero zero, which is zero zero as a reference
point.
You can see this zero here.
So this is basically the same axis here.
This is on top.
It just labels on bottom, but it's the same thing.
Zero starts here, so it's zero zero here, five 11 here you can see five 11 is all the way here.
Five, 11, five 11.
So we're connecting two points here.
I've already put what what the function here is so we can see we have and then coordinate something
coordinates color and line thickness.
So let's take a look at this do this nice little blue line.
I do encourage you to experiment and do different lines if you want.
It's quite fun to do this.
Basically pin playing like a windows pinch or one of those painting programs.
Except no, you're actually coding.
And the lines are programmatically which could be interesting to do if you wanted to make something
more elaborate.
You can have like rows and rows of these little line functions doing all sort of intricate lines, or
you can have a polygon or circles, which you'll see below.
So it's actually a rectangle, that's the next one.
So actually, I didn't run this.
So let's just run this for running at sake.
So now we're going to do a rectangle.
So rectangles are actually pretty cool because in things like object detectors, you may want to draw
a box or something or some kind of contour or some sort of region you're looking at in an image.
So having the ability to draw a box is actually quite useful.
Surprisingly, so similarly, we have this takes this function takes the image as an input takes it,
starting with X, which is the top left with X and the opposite with X, which is a bottom right with
X.
So we have a top left, bottom right color and thickness again.
So let's create our blank image here or black canvas we use.
We use two rectangles.
You can see it here.
Now this this function, which I didn't mention previously, this function basically takes the image
here and manipulates the image itself.
It's called in function.
It doesn't have something click.
It is an output and a function image, and you call it equal to that.
That's not how this one works.
It manipulates the image in that line right there.
Which is something to note because if you wanted to keep the original image as the original, this is
going to draw a box over that original image.
So your input variable is has changed, basically.
So now we can run this and you can see we have this here.
This cool purple pink?
Well, I think it's put this purple more in pink, but is this a triangle here?
So now let's draw some circles so you can see the circle function again is similar.
However, you don't have a top left and bottom right vertices.
You have a center and a radius, which is all you need when you want to specify how big a circle.
In a way, you want to put it just drop percent center in specified radius and it just fills the circle
here.
Now you don't actually have to fill if used.
If you use different value here, it actually wouldn't fill the circle.
So let's take a look at that and see.
It's been a while since I actually did this.
This should just affect.
Let's take a look.
Yeah.
Blindsides so you can see by putting him negative one here, you actually follow through the cycle automatically
with that color, the color that you actually specified here.
Color because you can specify any color you want.
255, 255 255 is all white.
If you wanted to see it and not, take my word for it, we can run that.
No, oops.
And you can see we got a nice wide circle there.
So let's go back to a green circle, the leaf negative one.
So now let's move on to polygons.
So polygons are pretty interesting and cool.
Remember, I said you can draw a bunch of lines together by having a lot of line functions to create
something weird.
Well, you can use it here.
You can use this polygon function instead.
What this does, it takes an array of points so you can see carefully.
Look at this here.
This is an array one tree hill.
It's a single, a single array, but you have submarines in it.
Here we have.
These are coordinate points.
So you got this list here, which is 10, 50, 450 and 90 200.
Whatever the five hundred five fifty five hundred does it a four points here.
We're going to draw one two three four.
And this connects back to the last one.
So let's reshape four points.
This is how we have to reshape the points here for these four to see V to polyolefins function.
So this reset function?
Don't worry about it too much.
It just actually changes the format around.
If you wanted to actually see it, you can print it out yourself and take a look at it.
So we use a C V to pull the lines here to image the points.
True.
Basically means we are going to join the last point with the this point.
The color you want it at and the thickness.
And there we go.
Pretty cool.
Boomerang airplane type.
Which you there.
So yes, sir, I did see how it requires a degree to behave that way.
Basically, what you're doing here, you're just adding in a point in extra dimension in the middle.
And the reason for that for is just because of how it probably seemed to function the internal function
inside of poly lines and how it's basically how addict decodes the points here.
So it's pretty much it's not really that intuitive is not really important to know, but you can see
the difference in shape here.
What what this ratio of function did just for your information.
So now let's look at putting text, which is the key to put text function, which is often something,
something I use quite often as well.
You can see this is a variable fonts here.
I'll show you how to use it and change it quickly.
So let's create our blank image here and let's create a string string is going to call Hello World.
And what we're going to do, we're going to use to put text function here.
So it just takes the image text to display here.
Bottom left starting point right here, font.
We specify here font size, color, the color and thickness.
So we've have all of we have all the stuff we need right now.
So remember, the bottom of the starting point is actually here.
So this is where the text starts right now, so we can run this function and we've placed some text
here.
Let's try a different font.
Let's try the complex.
So, oops, this is just gives us access to the markdown, but you do have access to and we get a nice
little fancy font here going, which actually don't if you use this one because it looks a bit unprofessional
sometimes, but you can pretty up pretty easily anything you want using these different fonts here,
and you can change the color, the thickness, the size position.
Anything you want to do is within this function.
So that's quite cool.
So that now concludes this lesson on drawing on images.
Hope you find it useful and cool.
What we're going to do next is transmission's, which is includes translations and rotations, so stay
tuned for the next lesson.
Thank you.