0
votes

I'm learning about Gabor filters for the first time and how they can be used to regenerate fingerprints from their orientation maps. I'm given an orientation map in the form of a .jpg and I want to apply gabor filters with 4 orientations on it. I followed the example in the documentation and ended up with the following code:

input_img = imread('orientation.jpg');
input_img = rgb2gray(input_img);  

wavelength = 6;
orientation = [0 45 90 135];
gaborArray = gabor(wavelength,orientation);
gaborMag = imgaborfilt(input_img,gaborArray);

figure
subplot(2,2,1);
for p = 1:4
    subplot(2,2,p)
    imshow(gaborMag(:,:,p),[]);
    theta = gaborArray(p).Orientation;
    lambda = gaborArray(p).Wavelength;
    title(sprintf('Orientation=%d, Wavelength=%d',theta,lambda));
end

My input is:

orientation.jpg

The output is: output

What I really want however is a single fingerprint like the following:

fingerprint.jpg

I understand that my output is currently the way it is due to the subplot. I tried replacing subplot with hold on and plot but what ends up happening is that the final image at Orientation=135 overlaps the others.

Is there a way to get the plots to overlap while averaging the luminance/intensity values of each pixel? Any guidance is appreciated.

1
You should not try to combine images during display, but before. Did you try adding the images together?Cris Luengo
Oh! No I haven't. I supposed to could do that using the result stored in gaborMag. I will try to do that, thank you.Calseon

1 Answers

0
votes

Following the suggestion from Cris Luengo's comment, I combined the images before displaying by averaging the magnitude values from gaborMag. My code is now as follows:

input_img = imread('orientation.jpg');
input_img = rgb2gray(input_img);  

wavelength = 2;
orientation = [0 45 90 135];
gaborArray = gabor(wavelength,orientation);
gaborMag = imgaborfilt(input_img,gaborArray);

[height, width, num_filters] = size(gaborMag(:,:,:));
combined_mag = zeros(height,width);

% Average the values from each filter
for i = 1:height
    for j = 1:width
        sum = 0;
        for f = 1:num_filters
            sum = sum + gaborMag(i,j,f);
        end
        combined_mag(i,j) = sum / num_filters;
    end
end
imshow(combined_mag,[]);

The output is:

combined