OK, so now let's begin our fifth lesson, which is called transformations.
So let's open this file is close off the previous four chapter and wait for this file to load.
So what we're going to do in the chapter, we're going to do something basically called translations
and rotations, which are the types of transformations.
You can see it here.
Transformations.
What this means is that these are the manipulations where we actually alter or shift the image without
actually interfering with anything of the aspect ratio of the original original image.
So to begin, let's lower over functions here and download our images as we did previously.
And let's take a look at translations.
No transitions are an I find transform, which means that it just shifts the position of an image that
doesn't affect it, doesn't warp the image in any way, doesn't change anything with the aspect ratio.
It just basically moves it left or right or up and down.
So you can see this is what this is.
This how it works.
Basically, it just actually multiplies this image here by this here.
And what I find this is the function we used to do it called WARP.
I find this matrix at T.
Is this yeah, this is a translation matrix here.
We're not going to get got to get into the mathematic terry between different matrices to do these things.
However, what you should know is that this is this this dimension here where we have X and T y here
and this matrix with the ones and zeros here.
This multiplied by an image here gives us an actual shift in the image left and right or politically
as well.
So you can see that's slow.
This image have me playing volleyball in a pool so we can load the image here and show the original
image here.
We get to get the height and weight of that image.
Now that's what we're going to do.
We're going to shift it by a quarter of the height and weight, basically.
So what to do that we just get to height that we got here, divided by four?
Similarly, for the width and that's what we're going to use for X and two y, we're going to shift
the image basically a quarter of this full height up and then a quarter of its width to the right to
right.
So let's create our transition matrix here.
You can see how we did it here before.
So is a one zero one zero one two here.
So that's how you can see this one zero.
So this line then quarter to width, which is two x dimension, we're shifting again.
Similarly, we have two zero and one, and Y is a political dimension of the direction we're moving.
So we're moving at that quarter of the height.
And as we said previously, we're going to use the CVT CV to go up our phone function here.
Um, to do that.
So you can see this is the inputs here within the height or to file image.
And that's just run this magically.
And you can see that it's here.
So actually, when I started moving, it is going to be dissuaded actually with it this way.
And that's because it's shifting from this reference point here.
That's all you need to know.
So this is pretty cool.
Sometimes I naturally assumed the reference point is here because of the different libraries I use,
but happens if it's at zero zero here.
So you can see it pushed it this way exactly as we expected and wanted.
So this is what he looks like here, and this is a bit of pride in what it looks like here in case you're
wondering what our T.
So this is the quarter with quarter height.
And you can see the full height here for that here and zeros and ones as we looked at and or a translation
matrix previously.
So now let's take a look at rotations.
And now OpenCV has this function called CV to Dot get rotation.
Now this function is pretty cool and it actually takes the rotation center here of the X and Y point
to a point you want to rotate about.
So imagine there's a center point in the image or wherever you center point you want it to be.
And that's a pivot point, and you just basically stick a pin here in the image and you just turn it
on on on around at that point.
That's where the rotation center is angular foundation and just how much rotation you want to do and
scale basically changes.
If you want to actually re scale this, resize the image, which we'll take a look at resizing quite
quite soon in one of the chapters later on.
So the notice, as applied, is rotation matrix to it, though let's see what we do.
So what are we going to use for the arguments here?
Let's use the center point to the center point would be would divide by two and a high divide by two.
That's rotated 90 degrees.
And I believe this 90 degrees is in a counterclockwise direction.
So it's going to.
Counterclockwise.
And one here means a skill, which means we're keeping the same skill.
So after we do this rotation matrix here, after we after we run this function here, get rotation matrix
2D that gives us this rotation matrix.
The rotation matrix is what we use now in the warp are fine.
That's what we that we take this and use it as an input into the war.
Baffling here to actually execute.
So rotation function here to see rotation matrix function doesn't do the rotation, it just creates
the matrix required to do the rotation.
So let's run this now and you'll get this.
So let's change something else changes to tree and this changes to a Nona like, let's just say, one
two five.
So let's see what that looks like.
And you can see it rotated at a different point or point that's probably closer to here believe and
tilted it into a different sort of a weird direction.
Or you can't even see me in the picture anymore.
I'm out of it.
So let's bring it back to what it was before.
And you get to get back on nicely rotated image, so you can see that basically to frame part of the
image of missing from this frame if you wanted to keep the entire image in the frame now.
That's why you use that's what a skill.
You see this this last argument here called skill.
That's what it does.
It actually re scales the image a bit now.
So it gives us a rotation matrix where there's a scaling factor involved, and that's actually pretty
cool.
We'll take a look at that afterward.
I shall do it here.
Let's bring this right here.
Looks.
And let's execute this now, so you can see this is what the rotation matrix looks like now.
It's quite different to what we saw in the transmission matrix.
So you can see it's doing, it's doing a number of things.
It's doing the rotation along with skewing playing by doing this matrix.
So that's pretty cool.
So, no, you can begin with this.
There's a lot of black space around the image.
Now it is a weight around that is called CB2 transports.
CB to transpose is actually quite cool.
However, it is less flexible as in, we don't have as much control over what we want to do.
So let's take a look at what it does.
Leslie, you can see it just rotated the image here.
It was hitting me like, actually, this is especially original image as well as side by side, so we
can actually see, let's do this.
Let's call this one the original website.
And let's just use this as the image I should add, I'm making typos because I'm reaching around my
microphone, it's quite awkward to do.
So you can see this is how it looked.
So you can see Transposed does something that does almost like a sort of like a flip in their actions.
It flipped it left to right.
You know, you know, that type of flip where it actually kind of mirrors it a bit.
Imagine a mirror mirror was right on this side here.
Oh, and that's kind of what it did.
It puts it put me on the other side, and it rotated at the same time.
So that's what a transpose function does.
So it's not really even the best to think to use for rotation.
They just supplies the transpose in case you ever needed for for it and for whatever purpose.
OK.
And you can apply twice and you get back what supposedly is the original image, and it should be.
Yup, it is.
So now this is an example of using transports to sort of rotate images, but not it's not true rotation.
So now let's take a look at using Flip.
The flip function does basically what I said transpose was doing the transposes, doing it in all aspects
flip left to right and a flip basically a vertical rotation at 90 degrees at that point as well.
So no flip basically does a horizontal flip.
We imagine is a mirror like in the point center here, and that's what you're going to get the mirror
image over here with me.
So that's flip for you.
And that's the end of this lesson.
They hope you enjoyed it.
We're going to move on to scaling, resizing and cropping and interpretations.
So it's a big jump to the next next section.
So stay tuned and hope you enjoyed it.
Thank you.