Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Basic Transformations | Image Processing with OpenCV
Computer Vision Essentials

Свайпніть щоб показати меню

book
Basic Transformations

Reading and Displaying an Image

Before performing transformations, let's first load and display an image using OpenCV. We have already imported the photo. But in your local computer for simple reading and displaying the photo you should use:

Resizing an Image

Resizing is useful for scaling images up or down while maintaining aspect ratio (fx and fy parameters), where fx and fy define the scaling factor for width and height.

You can also specify exact pixel dimensions (dsize parameter), where dsize is (new_y, new_x) output shape.

Rotating an Image

To rotate an image by a specific angle, we use cv2.getRotationMatrix2D() and cv2.warpAffine().

  • cv2.getRotationMatrix2D(center, angle, scale) defines the rotation matrix;

  • cv2.warpAffine(image, matrix, output_size) applies the transformation.

Cropping an Image

Cropping extracts a specific region from an image. It's done using NumPy slicing. The syntax image[start_y:end_y, start_x:end_x] selects a region of interest.

Завдання

Swipe to start coding

You are given an image:

  • Resize image to a (100, 100) shape and store it in resized variable;
  • Extract height and width from image;
  • Calculate center of height and width;
  • Create rotation matrix and stote it in rotation_matrix variable;
  • Rotate image 90 degrees clockwise and stote it in rotated variable;
  • Crop the X: 250-600 and Y: 100-450 region of the image and store in cropped variable.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 1

Запитати АІ

expand
ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

book
Basic Transformations

Reading and Displaying an Image

Before performing transformations, let's first load and display an image using OpenCV. We have already imported the photo. But in your local computer for simple reading and displaying the photo you should use:

Resizing an Image

Resizing is useful for scaling images up or down while maintaining aspect ratio (fx and fy parameters), where fx and fy define the scaling factor for width and height.

You can also specify exact pixel dimensions (dsize parameter), where dsize is (new_y, new_x) output shape.

Rotating an Image

To rotate an image by a specific angle, we use cv2.getRotationMatrix2D() and cv2.warpAffine().

  • cv2.getRotationMatrix2D(center, angle, scale) defines the rotation matrix;

  • cv2.warpAffine(image, matrix, output_size) applies the transformation.

Cropping an Image

Cropping extracts a specific region from an image. It's done using NumPy slicing. The syntax image[start_y:end_y, start_x:end_x] selects a region of interest.

Завдання

Swipe to start coding

You are given an image:

  • Resize image to a (100, 100) shape and store it in resized variable;
  • Extract height and width from image;
  • Calculate center of height and width;
  • Create rotation matrix and stote it in rotation_matrix variable;
  • Rotate image 90 degrees clockwise and stote it in rotated variable;
  • Crop the X: 250-600 and Y: 100-450 region of the image and store in cropped variable.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 1
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Ми дуже хвилюємося, що щось пішло не так. Що трапилося?
some-alt