260 likes | 517 Views
Edge Magnitude and Orientation. Roger S. Gaborski. Matlab Script to Calculate Magnitude and Orientation. First, use slide 90 of lecture 5 as a guide Read in image (in this example, Sign4.jpg from webpage) , convert to double in range [0,1] Convert to grayscale
E N D
Edge Magnitude and Orientation Roger S. Gaborski
Matlab Script to Calculate Magnitude and Orientation • First, use slide 90 of lecture 5 as a guide • Read in image (in this example, Sign4.jpg from webpage) , convert to double in range [0,1] • Convert to grayscale • Use the following filters to calculate the edges: fx = [ -1 -1 -1; 0 0 0; 1 1 1] fy = [ -1 0 1; -1 0 1; -1 0 1] • Use imfilter to find edges in x and y directions (Ifx and Ify) • Use the subplot filter to display the two images • One row, two columns Roger S. Gaborski
Gray scale Image Roger S. Gaborski
EDGE IMAGES Ifx and Ify Roger S. Gaborski
Find the magnitude of the edges and display the edge image (this is NOT a binary image) • figure, imshow(mag, []), title('Magnitude of Edges in Image') • Display a histogram of the magnitudes Roger S. Gaborski
Find the orientation in degrees (NOT radians) of all the edges • Display a histogram of the orientation of the edges Roger S. Gaborski
Find the magnitude value of the strongest edge, assign to variable max_mag • %Find edges that are 10%, 25 and 50% greater than the max_mag • ed10 = ??? • ed25 = ??? • ed50 = ??? • DISPLAY THESE EDGES • figure, imshow(ed10, []), title('Edges that are atleast 10% or greater of maximum edge strength') • figure, imshow(ed25, []), title('Edges that are atleast 25% or greater of maximum edge strength') • figure, imshow(ed50, []), title('Edges that are atleast 50% or greater of maximum edge strength') Roger S. Gaborski
Display Orientated Edges using Color Map • figure, imshow(???, []), title('Orientation of edges that are atleast 10% or greater of maximum edge strength') • colormap(jet) • figure, imshow(???, []), title('Orientation of edges that are atleast 25% or greater of maximum edge strength') • colormap(jet) • figure, imshow(???, []), title('Orientation of edges that are atleast 50% or greater of maximum edge strength') • colormap(jet) Roger S. Gaborski
EMAIL THIS RESULTS WITH SCRIPT Roger S. Gaborski
EMAIL THIS RESULTS WITH SCRIPT Roger S. Gaborski
EMAIL THIS RESULTS WITH SCRIPT Roger S. Gaborski
Extra Credit for Exam 1 • Write a script to perform the operations described in this presentation and discussed in class • Use good MATLAB programming practices • No loops, etc. Zero credit if loops are used • Not counting print statements, about 15 lines of code • Use raingirl.jpg image • Email script, and last three images to course account by 5pm today, Thursday • You must work independently – students not working independently will receive a zero for Exam 1 • 10 points added to exam 1 score for correct programming techniques and correct answers • No partial credit Roger S. Gaborski