From the course: OpenCV for Python Developers

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Scale and rotate images

Scale and rotate images

- [Instructor] Some of the most basic but important image processing actions include scaling and rotating. Let's begin by learning how to use scaling. To do this, we'll define our first variable called img_half = cv2.resize, noting that cv2.resize is the main resizing function. We'll pass in a value of img, and then we pass in the absolute size or 0,0 to not set an absolute size in pixels, and then we can optionally pass in our relative factors of fx=0.5, fy=0.5. This will result in an image that is half the size in both dimensions of the original. Next, we can type img_stretch = cv2.resize, and then, again, we'll pass in our image. This time in parentheses, we'll pass in a value of 600,600. Meaning we're going to explicitly scale the image to those dimensions. Next, let's type out img_stretch_near, and this will equal cv2.resize. Again, passing an img. Again, setting to be 600,600 in parentheses. And then this time…

Contents