Question
Task 1 [50 Points]: Figure 1: From left to right, top to bottom: original image, result of canny edge detection (threshold=4), result of oriented_edges(original image,
Task 1 [50 Points]:
Figure 1: From left to right, top to bottom: original image, result of canny edge detection (threshold=4), result of oriented_edges(original image, 1.4, 4, 0, 15), result of oriented_edges(original image, 1.4, 4, 45, 15), result of oriented_edges(original image, 1.4, 4, 90, 15), result of oriented_edges(original image, 1.4, 4, 135, 15).
Write a Matlab function that takes in as an argument a color or grayscale image, and returns an image that shows edge pixels with a certain orientation. In particular, you should implement a function that is invoked as follows:
oriented_edges(img, sigma, threshold, direction, tolerance)
Pixels in the resulting image should be white (value 255) if and only if they satisfy all the following requirements:
- The pixel is white in the result of canny4(img, sigma, 1.35, threshold, 2*threshold).
- The normal to the gradient at that pixel has a direction within tolerance degrees from direction.
The normal to the gradient is simply the direction that is perpendicular to the gradient. Example outputs of oriented_edges are shown in Figure 1 above.
This is a mathematical problem. You have to carefully read the specifications for what the function should return, and make sure that your solution satisfies those specifications. Your solution should work for any image. YOUR FUNCTION SHOULD NOT DISPLAY ANY FIGURES.
Directions are measured in degrees. Here are some specifications that your solution should comply with:
- Directions are specified in degrees.
- There is no distinction between angle A and angle A+180.
- Direction 0 corresponds to 3 o'clock orientation (horizontal).
- Direction 45 corresponds to 4:30 orientation (diagonal, going down and right).
- Direction 90 corresponds to 6 o'clock orientation (vertical).
- Direction 135 corresponds to 7:30 orientation (diagonal, going down and left).
- Direction difference is not a simple subtraction: the difference between direction 177 and direction 2 is 5 degrees. The difference between direction 1807 and direction 7 is 0 degrees.
- The direction argument of oriented_edges function is NOT CONSTRAINED to the 0-180 range, it can be anything (like 1823, -532, ...).
- The tolerance argument of oriented_edges function is constrained to be a real number >= 0 and
-
Figure 2: Three example images of straight roads, downloaded from Google Maps, and converted to grayscale.
Task 2 [50 Points]:
-
Write a Matlab function called road_orientation that takes as input a grayscale image of a straight road, and returns, as output, the orientation of that road in degrees. Your orientation should be accurate within 15 degrees.
Note: You are NOT allowed to use the Matlab function 'hough' to compute the result.
Hint: your solution for task 1 will probably be related to your solution for task 2.
Your function should work in most images of the type shown in Figure 2. Your solution will be tested on images not available to you. You can assume, however, that in all images the road is straight and most significant edges are parallel to the road. The file 06_hough.zip in the Data directory contains several examples.The convention for angles should be the same as in task 1.
-
Task 3: (optional, 10 points extra credit): Reimplement Task 2, and make your function produce a figure showing the location of the road with a straight line going along the center of the road.
-
Again, you are not allowed to use the Matlab function 'hough' to compute the result.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started