|
a |
|
b/functions/functions_Kovesi/ridgefreq.m |
|
|
1 |
% RIDGEFREQ - Calculates a ridge frequency image |
|
|
2 |
% |
|
|
3 |
% Function to estimate the fingerprint ridge frequency across a |
|
|
4 |
% fingerprint image. This is done by considering blocks of the image and |
|
|
5 |
% determining a ridgecount within each block by a call to FREQEST. |
|
|
6 |
% |
|
|
7 |
% Usage: |
|
|
8 |
% [freqim, medianfreq] = ridgefreq(im, mask, orientim, blksze, windsze, ... |
|
|
9 |
% minWaveLength, maxWaveLength) |
|
|
10 |
% |
|
|
11 |
% Arguments: |
|
|
12 |
% im - Image to be processed. |
|
|
13 |
% mask - Mask defining ridge regions (obtained from RIDGESEGMENT) |
|
|
14 |
% orientim - Ridge orientation image (obtained from RIDGORIENT) |
|
|
15 |
% blksze - Size of image block to use (say 32) |
|
|
16 |
% windsze - Window length used to identify peaks. This should be |
|
|
17 |
% an odd integer, say 3 or 5. |
|
|
18 |
% minWaveLength, maxWaveLength - Minimum and maximum ridge |
|
|
19 |
% wavelengths, in pixels, considered acceptable. |
|
|
20 |
% |
|
|
21 |
% Returns: |
|
|
22 |
% freqim - An image the same size as im with values set to |
|
|
23 |
% the estimated ridge spatial frequency within each |
|
|
24 |
% image block. If a ridge frequency cannot be |
|
|
25 |
% found within a block, or cannot be found within the |
|
|
26 |
% limits set by min and max Wavlength freqim is set |
|
|
27 |
% to zeros within that block. |
|
|
28 |
% medianfreq - Median frequency value evaluated over all the |
|
|
29 |
% valid regions of the image. |
|
|
30 |
% |
|
|
31 |
% Suggested parameters for a 500dpi fingerprint image |
|
|
32 |
% [freqim, medianfreq] = ridgefreq(im,orientim, 32, 5, 5, 15); |
|
|
33 |
% |
|
|
34 |
% I seem to find that the median frequency value is more useful as an |
|
|
35 |
% input to RIDGEFILTER than the more detailed freqim. This is possibly |
|
|
36 |
% due to deficiencies in FREQEST. |
|
|
37 |
% |
|
|
38 |
% See also: RIDGEORIENT, FREQEST, RIDGESEGMENT |
|
|
39 |
|
|
|
40 |
% Reference: |
|
|
41 |
% Hong, L., Wan, Y., and Jain, A. K. Fingerprint image enhancement: |
|
|
42 |
% Algorithm and performance evaluation. IEEE Transactions on Pattern |
|
|
43 |
% Analysis and Machine Intelligence 20, 8 (1998), 777 789. |
|
|
44 |
|
|
|
45 |
% Peter Kovesi |
|
|
46 |
% School of Computer Science & Software Engineering |
|
|
47 |
% The University of Western Australia |
|
|
48 |
% pk at csse uwa edu au |
|
|
49 |
% http://www.csse.uwa.edu.au/~pk |
|
|
50 |
% |
|
|
51 |
% January 2005 |
|
|
52 |
|
|
|
53 |
function [freq, medianfreq] = ridgefreq(im, mask, orient, blksze, windsze, ... |
|
|
54 |
minWaveLength, maxWaveLength) |
|
|
55 |
|
|
|
56 |
[rows, cols] = size(im); |
|
|
57 |
freq = zeros(size(im)); |
|
|
58 |
|
|
|
59 |
for r = 1:blksze:rows-blksze |
|
|
60 |
for c = 1:blksze:cols-blksze |
|
|
61 |
blkim = im(r:r+blksze-1, c:c+blksze-1); |
|
|
62 |
blkor = orient(r:r+blksze-1, c:c+blksze-1); |
|
|
63 |
|
|
|
64 |
freq(r:r+blksze-1,c:c+blksze-1) = ... |
|
|
65 |
freqest(blkim, blkor, windsze, minWaveLength, maxWaveLength); |
|
|
66 |
end |
|
|
67 |
end |
|
|
68 |
|
|
|
69 |
% Mask out frequencies calculated for non ridge regions |
|
|
70 |
freq = freq.*mask; |
|
|
71 |
|
|
|
72 |
% Find median freqency over all the valid regions of the image. |
|
|
73 |
medianfreq = median(freq(find(freq>0))); |