Skip to content

Instantly share code, notes, and snippets.

@lettergram
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lettergram/c2d90f2a3cca3514ba69 to your computer and use it in GitHub Desktop.
Save lettergram/c2d90f2a3cca3514ba69 to your computer and use it in GitHub Desktop.
Applying Derived Gaussian Filters
% Convert an image to double for increased precision
img = double(img);
% Find two derived gaussians with respect to x and y
[hx, hy] = gradient(fspecial('gaussian',[5 5],sigma));
% Run the filters over the image, generating a filtered image
% Leaves x and y images of edges
gx = double(imfilter(img,hx,'replicate', 'conv'));
gy = double(imfilter(img,hy,'replicate', 'conv'));
% Take the absolute value, and combine the x and y edges
mag = sqrt((gx .* gx) + (gy .* gy));
% Use non-maxima suppression
[mag, ] = max(mag, [], 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment