Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
building up a new image from another

Subject: building up a new image from another

From: Alex Harrison

Date: 22 Mar, 2011 10:10:05

Message: 1 of 14

Hi everyone,

I'm stuck on a piece of work that I'm doing for my final year uni project. The program that I have so far scans an image of overlaying fingerprints and, using FFT's, tries to eliminate one of the fingerprints. Because FFT's only really work with straight lines I'm having to scan across the image using a 50x50 pixel box but my problem is that I can't work out how to build up a complete image in a new figure as it scans across, whatever I try all I end up with at the end is a snapshot of the final 50x50 pixel box.

This is probably something very simple or covered somewhere else (although I can't find it anywhere!) but does anyone have a solution? I can upload my program so far if needed but would rather not have to if it is a relatively straight forward problem!

Many thanks

Subject: building up a new image from another

From: ImageAnalyst

Date: 22 Mar, 2011 10:17:04

Message: 2 of 14

This is definitely not true "FFT's only really work with straight
lines " - not sure where you heard that but it's nonsense.

I have no idea what your code is doing to build up an image by
scanning with a 50x50 box, and won't until you post it.

Subject: building up a new image from another

From: Alex Harrison

Date: 22 Mar, 2011 10:30:21

Message: 3 of 14

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <979d192d-185f-4e94-9c80-6fccd1c71eac@y31g2000prd.googlegroups.com>...
> This is definitely not true "FFT's only really work with straight
> lines " - not sure where you heard that but it's nonsense.
>
> I have no idea what your code is doing to build up an image by
> scanning with a 50x50 box, and won't until you post it.

sorry that wasn't clear; I meant that if you take an FFT of a whole fingerprint, because the lines all curve in a circular fashion, you end up with a massive 'cloud' of intensities and nothing which can be used to separate one set of lines from the other, by breaking it down you only get a more useable FFT.

Here's the program anyway:

test_first_search = 1;

% Here is the size of my box for fft:
box_size = 51;

% Scan across the image checking the signal intensity
figure(1)
imagesc(A)
colormap jet

% define a signal on the basis of which the cropped section
% will be analysed or not:
signal_threshold = 100;
figure(2)
colormap jet

for start_index_v = 1:(size(A,1)-box_size+1)
    if round(start_index_v/2) == start_index_v/2
        scan_h = fliplr(1:(size(A,2)-box_size+1));
    else
        scan_h = 1:(size(A,2)-box_size+1);
    end
    for start_index_h = scan_h;
        cropped_A = A(start_index_v:(start_index_v + box_size-1),start_index_h:(start_index_h + box_size-1));
        
        spectrum = fftshift(fft2(cropped_A));

        if max(max(abs(spectrum))) > signal_threshold
            spectrum_no_centre = spectrum;
            spectrum_no_centre((round(box_size/2)-1):(round(box_size/2)+1),(round(box_size/2)-1):(round(box_size/2)+1)) = 0;
            if test_first_search == 1
                [a by] = max(max(abs(spectrum_no_centre)));
                [a bx] = max(max(abs(spectrum_no_centre')));
                test_first_search = 0;
            else
                % Generate a temporary matrix to limit the search to the
                % neighbourhood of the last maximum found:
                temp = zeros(size(spectrum_no_centre,1),size(spectrum_no_centre,2));
                temp((bx-2:bx+2),(by-2:by+2)) = spectrum_no_centre((bx-2:bx+2),(by-2:by+2));
                [a by] = max(max(abs(temp)));
                [a bx] = max(max(abs(temp')));
                % Generate another temporary matrix to store the area of
                % the FFT that corresponds to one of the two fingerprints:
                B = zeros(size(spectrum_no_centre,1),size(spectrum_no_centre,1));
                % Store the information in the two lobes mirrored around
                % the centre of the Fourier space:
                B((bx-2:bx+2),(by-2:by+2)) = spectrum((bx-2:bx+2),(by-2:by+2));
                bx_mirror = (round(box_size/2)) - (bx - round(box_size/2));
                by_mirror = (round(box_size/2)) - (by - round(box_size/2));
                B((bx_mirror-2:bx_mirror+2),(by_mirror-2:by_mirror+2)) = spectrum((bx_mirror-2:bx_mirror+2),(by_mirror-2:by_mirror+2));
                % Restore the centre of the Fourier space:
                B((round(box_size/2)-1),(round(box_size/2)-1)) = spectrum((round(box_size/2)-1),(round(box_size/2)-1));
                imagesc(abs(B))
                %Inverse the temporary matrix (B) FFT:
                figure(3)
                imagesc(abs(ifft2(fftshift(B))))
                colormap gray
            end
            pause(0.001)
        end
    end
end

Subject: building up a new image from another

From: ImageAnalyst

Date: 22 Mar, 2011 10:43:44

Message: 4 of 14

My prediction would be that the FFT of a fingerprint would look like a
mess. Maybe you'd see some spikes or rings related to the ridge width
or ridge spacing but that's about it.

Anyway, why are you scanning with a 51 pixel box? Why not just take
the FFT of the whole thing if that's what you want? (Sorry I don't
have time now to comprehend your entire program).

Subject: building up a new image from another

From: Alex Harrison

Date: 22 Mar, 2011 10:58:03

Message: 5 of 14

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <e230c973-002a-4983-a44c-b4bacfe947e8@b22g2000prb.googlegroups.com>...
> My prediction would be that the FFT of a fingerprint would look like a
> mess. Maybe you'd see some spikes or rings related to the ridge width
> or ridge spacing but that's about it.
>
> Anyway, why are you scanning with a 51 pixel box? Why not just take
> the FFT of the whole thing if that's what you want? (Sorry I don't
> have time now to comprehend your entire program).

Using the 51 pixel box means that you only get 2 positive intensities (plus the mirrors/negative intensities - I'm not sure what the proper name is!) this then allows for the complete removal of one set of lines leaving just one set. The box then moves across one pixel and does the same thing, the idea being that by the time it is finished one fingerprint is left and the other is totally removed. The problem I'm having is then capturing each 51 pixel FFT once it has been processed and building up a complete image from all of them.

The middle part of the program is for two lobes that search for the highest intensity in the region of the last intensity meaning it always removes the lines from one print and keeps them from the other.

Subject: building up a new image from another

From: ImageAnalyst

Date: 22 Mar, 2011 12:13:06

Message: 6 of 14

Alex:
I didn't understand what you said about the FFT - maybe Wayne or Greg
will. Is your image an image of two fingerprints superimposed?
Sounds like you're trying to extract just one of them. Posting a
photo of the image and at least one of the spectra somewhere
(uploadhouse.com) would help. Off the top of my head I don't see how
a Fourier approach would do that, unless you have some published paper
that proves it, or you have some good sound theory on how it would
work. If you've got just a mishmash of lines, how is it supposed to
know which particular lines are part of one fingerprint and which are
part of the other? Maybe you have some hope if the ridges are
perpendicular to each other, but if they're parallel.....????

Here's a MATLAB fingerprint link I've saved:
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/#fingerprints

But are you trying to build up a mosaic or montage of all the small
51x51 spectra? You can either stuff each image into a slice (layer)
of a 3D image, or put each into a cell of a cell array, though I
prefer the 3D image and leave the cell arrays for situations when each
cell has different size or data type. There is also a montage()
function in the Image Processing Toolbox, and a nice program by Oliver
Woodford called imdisp:
http://www.mathworks.com/matlabcentral/fileexchange/authors/29192

-ImageAnalyst

Subject: building up a new image from another

From: Alex Harrison

Date: 22 Mar, 2011 13:23:03

Message: 7 of 14

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <1ae48b27-f7bd-443a-b9f0-7b2058ab82bc@j35g2000prb.googlegroups.com>...
> Alex:
> I didn't understand what you said about the FFT - maybe Wayne or Greg
> will. Is your image an image of two fingerprints superimposed?
> Sounds like you're trying to extract just one of them. Posting a
> photo of the image and at least one of the spectra somewhere
> (uploadhouse.com) would help. Off the top of my head I don't see how
> a Fourier approach would do that, unless you have some published paper
> that proves it, or you have some good sound theory on how it would
> work. If you've got just a mishmash of lines, how is it supposed to
> know which particular lines are part of one fingerprint and which are
> part of the other? Maybe you have some hope if the ridges are
> perpendicular to each other, but if they're parallel.....????
>
> Here's a MATLAB fingerprint link I've saved:
> http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/#fingerprints
>
> But are you trying to build up a mosaic or montage of all the small
> 51x51 spectra? You can either stuff each image into a slice (layer)
> of a 3D image, or put each into a cell of a cell array, though I
> prefer the 3D image and leave the cell arrays for situations when each
> cell has different size or data type. There is also a montage()
> function in the Image Processing Toolbox, and a nice program by Oliver
> Woodford called imdisp:
> http://www.mathworks.com/matlabcentral/fileexchange/authors/29192
>
> -ImageAnalyst

Sorry it's quite difficult to explain but yes the images are superimposed and yes that is exactly what I'm trying to do with them.

Below are links to three images I've uploaded to uploadhouse.com; fingerprint4 is the complete image but it takes hours to process so I've been using the other two as tester images. One is a section that doesn't overlap and, if I can get the program to work with that then I can focus on the other smaller image, which does overlap.

Fingerprint4
http://www.uploadhouse.com/viewfile.php?id=8789453

Fingerprint9
http://www.uploadhouse.com/viewfile.php?id=8789459

Fingerprint11
http://www.uploadhouse.com/viewfile.php?id=8789456

Unfortunately I don't have any spectra as it processes continually but below is a link to the image of the 'lobes' thing I tried (and failed) to explain - not sure if this is of any use though but I have explained the lobes again in more detail below.
http://www.uploadhouse.com/viewfile.php?id=8789732

I don't have any papers on it (I'm pretty sure it hasn't been done before - at least not in a scientific capacity) but the theory behind it is that if there are only two fingerprints overlapping then there won't be a mishmash as such as the lines will be at an angle to each other - although I realise it isn’t going to work for all of the image as, like you say, there will be times when they are parallel and overlapping (thankfully it doesn’t have to as it’s just a research project/dissertation and therefore doesn’t have to be perfect first time around!).

The program differentiates between the two fingerprints using the lobes I tried to explain. When the FFT of the first 51 pixel box is being processed the maximum intensity in the top right and bottom left quadrants is found and then, when the box moves along one pixel, the ‘lobes’ limit the search for the next FFT intensities to those two localised regions (each lobe is 5x5 pixels). Because the lines from the two fingerprints are roughly perpendicular to each other the intensities from the other print will (to start with) appear in the top left and bottom right quadrants of the FFT so these areas are forced to zero meaning (theoretically) that those lines ‘disappear’ from the image, leaving just the lines from one fingerprint. The lobes, because they search in a localised area, then slowly move around as per the angle of the lines in the fingerprint but
don’t detect the lines from the second fingerprint.

I know that the FFT works in a ‘static’ situation as I tried it on a small section of the image but, since automating it so that I don't end up with several hundred still images, I have no way of having a full image at the end.

A montage would seem like the ideal way to achieve this but I have no idea how to implement it (I’m still pretty new to this and the program as it is now has taken AGES to make!). I'll have a look at the imdisp program and see if I can make it work for me.

As for the 3D image vs cell array I don’t really know what the difference is but I’m willing to accept that a 3D image would be better with each image stuffed into a slice of the image.

Thank you for your help and your patience with my poor explanations, I hope it makes more sense now.

Alex

Subject: building up a new image from another

From: ImageAnalyst

Date: 22 Mar, 2011 14:42:37

Message: 8 of 14

Damn. I can't even look at it here at work anymore. Apparently the
corporate censors have decided this nonsense:

"Forbidden
Date Tue 22/03/2011 14:39:29 GMT
You have been denied access to http:// "www.uploadhouse.com". This is
filtered under the denied category "Pornography".
This URL belongs to one of the categories that are blocked by
Corporate Policy. "

This just like any other file sharing web site, just more convenient
than the others. I hope they don't ban them all. I'll have to wait
until later today to look at it on my home computer.

Subject: building up a new image from another

From: Alex Harrison

Date: 22 Mar, 2011 20:43:05

Message: 9 of 14

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <65b4e379-7f1a-4f86-9e45-793d3ff3801a@34g2000pru.googlegroups.com>...
> Damn. I can't even look at it here at work anymore. Apparently the
> corporate censors have decided this nonsense:
>
> "Forbidden
> Date Tue 22/03/2011 14:39:29 GMT
> You have been denied access to http:// "www.uploadhouse.com". This is
> filtered under the denied category "Pornography".
> This URL belongs to one of the categories that are blocked by
> Corporate Policy. "
>
> This just like any other file sharing web site, just more convenient
> than the others. I hope they don't ban them all. I'll have to wait
> until later today to look at it on my home computer.

Blocked for pornography?! That's interesting, considering the images are a series of black and white lines!

I had a look at the imdisp program but most of it is way over my level of understanding. From what I could gather though you have to have all of the images stored somewhere for that to montage them which, at the moment, I don't have as my program doesn't capture each image; it just keeps on scanning and processing FFT's before disposing of them and moving on to the next one :s

Alex

Subject: building up a new image from another

From: Alex Harrison

Date: 7 Apr, 2011 16:15:07

Message: 10 of 14

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <1ae48b27-f7bd-443a-b9f0-7b2058ab82bc@j35g2000prb.googlegroups.com>...
> Alex:
> I didn't understand what you said about the FFT - maybe Wayne or Greg
> will. Is your image an image of two fingerprints superimposed?
> Sounds like you're trying to extract just one of them. Posting a
> photo of the image and at least one of the spectra somewhere
> (uploadhouse.com) would help. Off the top of my head I don't see how
> a Fourier approach would do that, unless you have some published paper
> that proves it, or you have some good sound theory on how it would
> work. If you've got just a mishmash of lines, how is it supposed to
> know which particular lines are part of one fingerprint and which are
> part of the other? Maybe you have some hope if the ridges are
> perpendicular to each other, but if they're parallel.....????
>
> Here's a MATLAB fingerprint link I've saved:
> http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/#fingerprints
>
> But are you trying to build up a mosaic or montage of all the small
> 51x51 spectra? You can either stuff each image into a slice (layer)
> of a 3D image, or put each into a cell of a cell array, though I
> prefer the 3D image and leave the cell arrays for situations when each
> cell has different size or data type. There is also a montage()
> function in the Image Processing Toolbox, and a nice program by Oliver
> Woodford called imdisp:
> http://www.mathworks.com/matlabcentral/fileexchange/authors/29192
>
> -ImageAnalyst

Hi Image Analyst,

I'm still working on this and still struggling with it. I now have all of my individual images being produced and saved OK but I don't know how to put them back together again into one file.

Before, you recommended stuffing each image into a slice of a 3D matrix. Is this relatively simple to do? All of the images are saved into 1 directory so is it a case of creating a loop that inserts the first file into the 1st slice, the second into the 2nd slice etc? I understand how to create a 3D matrix, eg all zeros or ones etc, but I don't know how to insert actual images into one.

Alex

Subject: building up a new image from another

From: ImageAnalyst

Date: 7 Apr, 2011 17:06:42

Message: 11 of 14

Then, why don't you try the montage() function of the Image Processing
Toolbox?

Subject: building up a new image from another

From: Joseph

Date: 7 Apr, 2011 23:04:05

Message: 12 of 14

Just played with one of your images. It's not perfect but have you might want to try imerode using a linear structure element.

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <d9192623-21ef-483a-b94e-dbb25a0fabcc@hg8g2000vbb.googlegroups.com>...
> Then, why don't you try the montage() function of the Image Processing
> Toolbox?

Subject: building up a new image from another

From: Alex Harrison

Date: 8 Apr, 2011 11:20:07

Message: 13 of 14

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <d9192623-21ef-483a-b94e-dbb25a0fabcc@hg8g2000vbb.googlegroups.com>...
> Then, why don't you try the montage() function of the Image Processing
> Toolbox?

I tried but got an error saying that the montage function wasn't recognised and when I searched for montage in the help bit it didn't find anything. I'm using Matlab in uni and it's version 7.5.0 R(2007b). Is the error because montage wasn't available for this release or because the Image Processing Toolkit is an addon or something?

Subject: building up a new image from another

From: ImageAnalyst

Date: 8 Apr, 2011 11:48:32

Message: 14 of 14

Alex Harrison:
Yes, the Image Processing Toolbox is an additional product that you
should purchase. I can't imagine doing image processing without it,
unless you want to spend your time writing hundreds of functions
yourself, and testing and validating them all. Otherwise, just call
up a figure and use subplot to display all your subimages.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us