hello as part of my Homework. i need to calculate and display the edge magnitude image and the edge direction image of image balls1.tif, using Sobel Edge detection.
Do not use matlab's edge function. You may use conv2. Display a binary edge image (1 edge pixel, 0 no edge) of strong edge pixels (above a threshold). Determine a threshold that eliminates the ball shadows.
here is my main.m
addpath(fullfile(pwd,'TOOLBOX'));
addpath(fullfile(pwd,'images'));
%Sobel Edge Detection
Image = readImage('balls1.tif');
showImage(Image);
message = sprintf('Sobel Edge Detection');
sobelEdgeDetection(Image);
uiwait(msgbox(message,'Done', 'help'));
close all
here is my SobeEdgeDetection.m
function [ output_args ] = SobelEdgeDetection( Image )
maskX = [-1 0 1 ; -2 0 2; -1 0 1];
maskY = [-1 -2 -1 ; 0 0 0 ; 1 2 1] ;
resX = conv2(Image, maskX);
resY = conv2(Image, maskY);
magnitude = sqrt(resX.^2 + resY.^2);
direction = atan(resY/resX);
thresh = magnitude < 101;
magnitude(thresh) = 0;
showImage(magnitude);
end
my questions are:
1. i what is the direction used for ? and how can i display it?
2. is there a better way to get a threshold to eliminate the ball shadows. i used trial and error....
these are my result as far as showing the magnitude: