Conteúdo do Curso
Fundamentals of Image Manipulation with Python
Scaling, Rotating, Shifting and Edge Detection
In OpenCV
, scaling, rotating, shifting, and edge detection are all image processing techniques used to manipulate and analyze images.
Scaling refers to changing the size of an image, which can be done using the cv2.resize()
function. This function takes in an image and a tuple of the desired width and height and returns the resized image.
Rotating involves rotating an image using the cv2.getRotationMatrix2D()
and cv2.warpAffine()
functions. The cv2.getRotationMatrix2D()
function accepts the following parameters:
- The center of rotation;
- The angle of rotation;
- A scaling factor.
It returns a rotation matrix. The cv2.warpAffine()
function takes in the image, the rotation matrix, and the size of the output image and returns the rotated image.
Shifting refers to moving an image by a specific amount in the x
and y
directions, which can be done using the cv2.warpAffine()
function. This function requires:
- An image;
- A translation matrix;
- The size of the output image.
It returns the shifted image.
Edge detection identifies the edges in an image, which can be accomplished using various edge detection algorithms such as Sobel, Canny, and Laplacian with the respective functions: Sobel()
, Canny()
and Laplacian()
. These algorithms identify and highlight the edges of objects in an image, aiding tasks like object detection and image segmentation.
Swipe to show code editor
- Resize the image
image1
. - Use the correct function to get the rotation matrix.
- Use the Canny algorithm for edge detection.
Obrigado pelo seu feedback!
In OpenCV
, scaling, rotating, shifting, and edge detection are all image processing techniques used to manipulate and analyze images.
Scaling refers to changing the size of an image, which can be done using the cv2.resize()
function. This function takes in an image and a tuple of the desired width and height and returns the resized image.
Rotating involves rotating an image using the cv2.getRotationMatrix2D()
and cv2.warpAffine()
functions. The cv2.getRotationMatrix2D()
function accepts the following parameters:
- The center of rotation;
- The angle of rotation;
- A scaling factor.
It returns a rotation matrix. The cv2.warpAffine()
function takes in the image, the rotation matrix, and the size of the output image and returns the rotated image.
Shifting refers to moving an image by a specific amount in the x
and y
directions, which can be done using the cv2.warpAffine()
function. This function requires:
- An image;
- A translation matrix;
- The size of the output image.
It returns the shifted image.
Edge detection identifies the edges in an image, which can be accomplished using various edge detection algorithms such as Sobel, Canny, and Laplacian with the respective functions: Sobel()
, Canny()
and Laplacian()
. These algorithms identify and highlight the edges of objects in an image, aiding tasks like object detection and image segmentation.
Swipe to show code editor
- Resize the image
image1
. - Use the correct function to get the rotation matrix.
- Use the Canny algorithm for edge detection.