miura_usage.m 2.28 KB
 André Anjos committed Oct 12, 2017 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 ``````% Howto use the miura_* scripts. img = im2double(imread('finger.png')); % Read the image img = imresize(img,0.5); % Downscale image % Get the valid region, this is a binary mask which indicates the region of % the finger. For quick testing it is possible to use something like: % fvr = ones(size(img)); % The lee_region() function can be found here: % http://www.mathworks.com/matlabcentral/fileexchange/35752-finger-region-localisation fvr = lee_region(img,4,40); % Get finger region %% Extract veins using maximum curvature method sigma = 3; % Parameter v_max_curvature = miura_max_curvature(img,fvr,sigma); % Binarise the vein image md = median(v_max_curvature(v_max_curvature>0)); v_max_curvature_bin = v_max_curvature > md; %% Extract veins using repeated line tracking method max_iterations = 3000; r=1; W=17; % Parameters v_repeated_line = miura_repeated_line_tracking(img,fvr,max_iterations,r,W); % Binarise the vein image md = median(v_repeated_line(v_repeated_line>0)); v_repeated_line_bin = v_repeated_line > md; %% Match cw = 80; ch=30; % Note that the match score is between 0 and 0.5 score = miura_match(double(v_repeated_line_bin), double(v_max_curvature_bin), cw, ch); fprintf('Match score: %6.4f %%\n', score); %% Visualise % Overlay the extracted veins on the original image overlay_max_curvature = zeros([size(img) 3]); overlay_max_curvature(:,:,1) = img; overlay_max_curvature(:,:,2) = img + 0.4*v_max_curvature_bin; overlay_max_curvature(:,:,3) = img; % Overlay the extracted veins on the original image overlay_repeated_line = zeros([size(img) 3]); overlay_repeated_line(:,:,1) = img; overlay_repeated_line(:,:,2) = img + 0.4*v_repeated_line_bin; overlay_repeated_line(:,:,3) = img; figure; subplot(3,2,1) imshow(img,[]) title('Original captured image') subplot(3,2,2) imshow(fvr) title('Detected finger region') subplot(3,2,3) imshow(v_max_curvature_bin) title('Binarised veins extracted by maximum curvature method') subplot(3,2,4) imshow(overlay_max_curvature) title('Maximum curvature method') subplot(3,2,5) imshow(v_repeated_line_bin) title('Binarised veins extracted by repeated line tracking method') subplot(3,2,6) imshow(overlay_repeated_line) title('Repeated line tracking method')``````