Created
December 18, 2012 21:21
-
-
Save ferryzhou/4332122 to your computer and use it in GitHub Desktop.
get maxima of a gray scale image
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
function [I, J, xvals] = get_local_maxima(imcor, radius) | |
% a = rand(10); | |
% [I, J, xvals] = get_local_maxima(a, 3); | |
% figure, imagesc(a); hold on; scatter(J, I); | |
[m, n] = size(imcor); | |
nim = ones(m + radius * 2, n + radius * 2) * 1e-10; | |
nim(radius + (1:m), radius + (1:n)) = imcor; | |
cols = im2col(nim, [2*radius + 1, 2 * radius + 1], 'sliding'); | |
mcols = max(cols); | |
o = imcor == reshape(mcols, m, n); | |
[I, J] = find(o); | |
xvals = imcor(sub2ind([m, n], I, J)); | |
end |
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
a = rand(10); | |
[I, J, xvals] = get_local_maxima(a, 3); | |
figure, imagesc(a); hold on; scatter(J, I); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment