Reputation: 5
i try to do finger vein feature extraction i had two files i'm getting this error (line 29) which is in the second file
[img_h, img_w] = size(img);
Not enough input arguments. first
% This script shows how the finger region and edges can be detected.
img = im2double(imread('finger.png')); % Read image
img = imresize(img, 0.5); % Downscale image
mask_height=4; % Height of the mask
mask_width=20; % Width of the mask
[fvr, edges] = lee_region(img,mask_height,mask_width);
% Create a nice image for showing the edges
edge_img = zeros(size(img));
edge_img(edges(1,:) + size(img,1)*[0:size(img,2)-1]) = 1;
edge_img(edges(2,:) + size(img,1)*[0:size(img,2)-1]) = 1;
rgb = zeros([size(img) 3]);
rgb(:,:,1) = (img - img.*edge_img) + edge_img;
rgb(:,:,2) = (img - img.*edge_img);
rgb(:,:,3) = (img - img.*edge_img);
% Show the original, detected region and edges in one figure
figure;
subplot(3,1,1)
imshow(img,[])
title('Original image')
subplot(3,1,2)
imshow(fvr)
title('Finger region')
subplot(3,1,3)
imshow(rgb)
title('Finger edges')
here is the second file
function [region, edges] = lee_region(img, mask_h, mask_w)
% Localise the finger region
% Parameters:
% img - Input vascular image
% mask_h - Height of the mask
% mask_w - Width of the mask
% Returns:
% region - Binary mask indicating the finger region
% edges - Matrix containing two rows, first row corresponds to the
% y-positions of the upper finger edge and the second row
% corresponds to the y-positions of the lower finger edge.
% Reference:
% Finger vein recognition using minutia-based alignment and local binary
% pattern-based feature extraction
% E.C. Lee, H.C. Lee and K.R. Park
% International Journal of Imaging Systems and Technology
% Volume 19, Issue 3, September 2009, Pages 175-178
% doi: 10.1002/ima.20193
% Author: Bram Ton <[email protected]>
% Date: 20th March 2012
% License: Simplified BSD License
[img_h, img_w] = size(img);
% Determine lower half starting point
if mod(img_h,2) == 0
half_img_h = img_h/2 + 1;
else
half_img_h = ceil(img_h/2);
end
% Construct mask for filtering
mask = zeros(mask_h,mask_w);
mask(1:mask_h/2,:) = -1;
mask(mask_h/2 + 1:end,:) = 1;
% Filter image using mask
img_filt = imfilter(img, mask,'replicate');
%figure; imshow(img_filt)
% Upper part of filtred image
img_filt_up = img_filt(1:floor(img_h/2),:);
[~, y_up] = max(img_filt_up);
% Lower part of filtred image
img_filt_lo = img_filt(half_img_h:end,:);
[~,y_lo] = min(img_filt_lo);
% Fill region between upper and lower edges
region = zeros(size(img));
for i=1:img_w
region(y_up(i):y_lo(i)+size(img_filt_lo,1), i) = 1;
end
% Save y-position of finger edges
edges = zeros(2,img_w);
edges(1,:) = y_up;
edges(2,:) = round(y_lo + size(img_filt_lo,1));
Upvotes: 0
Views: 1082
Reputation: 54
The one possible reason is that you defined one function whose name is 'size'. If so, rename your defined function to be another name.
If not, in case that your working folder only has two files, if the input is a colorful image, then you will meet bugs in the main file on line edge_img(edges(1,:) + size(img,1)*[0:size(img,2)-1]) = 1;
, not in the second file. I just tested it. To solve this bug, you need convert all input image (finger.png) to be gray-scale. you can change your main file in this way:
% This script shows how the finger region and edges can be detected.
img = im2double(imread('finger.png')); % Read image
img = imresize(img, 0.5); % Downscale image
img = rgb2gray(img);
mask_height=4; % Height of the mask
mask_width=20; % Width of the mask
[fvr, edges] = lee_region(img,mask_height,mask_width);
...
By the way, the matlab version I use is MATLAB2012B; And also if the input image is M*N*3, then [h,w] = size(img)
will return as follows: h = M; w = N*3. There will be no errors.
Upvotes: 1