Created
March 14, 2015 03:12
-
-
Save lettergram/fcd27186b7c9e8044074 to your computer and use it in GitHub Desktop.
Oriented Filters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Create four filters | |
[hx, hy] = gradient(fspecial('gaussian',[5 5],sigma)); | |
[hx1, hy1] = altOrientFilter1(hx, hy); | |
[hx2, hy2] = altOrientFilter2(hx, hy); | |
[hx3, hy3] = altOrientFilter3(hx, hy); | |
% Run gaussian filters on the image | |
gx = double(imfilter(img,hx,'replicate', 'conv')); | |
gy = double(imfilter(img,hy,'replicate', 'conv')); | |
gx1 = double(imfilter(img,hx1,'replicate', 'conv')); | |
gy1 = double(imfilter(img,hy1,'replicate', 'conv')); | |
gx2 = double(imfilter(img,hx2,'replicate', 'conv')); | |
gy2 = double(imfilter(img,hy2,'replicate', 'conv')); | |
gx3 = double(imfilter(img,hx3,'replicate', 'conv')); | |
gy3 = double(imfilter(img,hy3,'replicate', 'conv')); | |
% Merge all filters | |
squareGD = (gx .* gx) + (gy .* gy); | |
squareGD = squareGD + (gx1 .* gx1) + (gy1 .* gy1); | |
squareGD = squareGD + (gx2 .* gx2) + (gy2 .* gy2); | |
squareGD = squareGD + (gx3 .* gx3) + (gy3 .* gy3); | |
% Run non-maxima supression | |
[mag, ] = max(sqrt(squareGD), [], 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment