You can download this code by clicking the button below.
This code is now available for download.
This function first loads an image from the given path, then detects edges in the image using the Canny edge detector. After that, it rotates the image by the specified angle and displays the original image side by side with the rotated image. Finally, the function returns the detected edges and the rotated image.
Technology Stack : numpy, scikit-image
Code Type : Image processing
Code Difficulty : Intermediate
import numpy as np
from skimage import feature, io, transform
def find_edges_and_rotate_image(image_path, angle):
# Load the image from the given path
image = io.imread(image_path)
# Detect edges in the image using the Canny edge detector
edges = feature.canny(image)
# Rotate the image using the specified angle
rotated_image = transform.rotate(image, angle, resize=False)
# Display the original image and the rotated image with edges
io.imshow(np.hstack((image, rotated_image)))
io.show()
# Return the edges detected and the rotated image
return edges, rotated_image