Created
March 14, 2015 03:17
-
-
Save lettergram/63cff51e8502d7c9ebf6 to your computer and use it in GitHub Desktop.
Lab gradient filter
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
% Convert an image to the Lab color space | |
colorTransform = makecform('srgb2lab'); | |
img = applycform(rgbImg, colorTransform); | |
% Make it double to improve representation | |
img = double(img); | |
% Find x and y derivative of a 9x9 gaussian | |
[hx, hy] = gradient(fspecial('gaussian',[9 9],sigma)); | |
% Apply filters | |
gx = double(imfilter(img,hx,'replicate')); | |
gy = double(imfilter(img,hy,'replicate')); | |
% Find absolute value | |
gSquared = sqrt(gx .* gx) + (gy .* gy); | |
% Apply non-maxima suppression (find best points for edges) | |
[mag, ] = max(gSquared, [], 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment