Prev: delete more equal rows
Next: Sparse Neural Networks
From: Jack Andrews on 28 Mar 2010 19:16 "Sean " <sean.dewolski(a)Idontwantspam.umit.maine.edu> wrote in message <hoomvp$89r$1(a)fred.mathworks.com>... > "Jack Andrews" <krehsi01(a)qub.ac.uk> wrote in message <hoobk5$q2u$1(a)fred.mathworks.com>... > > > > > > Test your algorithm with sample images like this: > > > > > > >>I = imread('cameraman.tif'); %Load image > > > >>I2 = zeros(size(I)+10, 'uint8'); > > > >>I2(4:end-7,7:end-4) = I; %Shift image over (4 down, 7 across) > > > >>I = padarray(I,[10 10], 0, 'post'); %Make original image same size > > > >>[x y peak] = pruebapoc1(I, I2); > > > > Sean, > > > > Thank you for your support. Can you please explain to me what is happening in the above test algorithm please. Like I2 = zeros(size(I)+10, 'unit8'); > > > > Thanks Again > > %% > I2 = zeros(size(I) +10,'uint8'); > %This makes a zero matrix of class uint8 (the same as cameraman or I) and makes it 10rows and 10columns bigger > %Then set a part of this bigger matrix to be the exact same as the first image. I.e. I'm setting rows 4:259 of columns 7:262 equal to your original image. This is a perfectly ideal case (no sub pixel shifts) of image motion. It's actually [3 down, 6 over] I was wrong above. > %Then in order for the array multiplication to work the original image needs to be the same size as the second image. > I = padarray(I,[10 10],0,'post'); > %This pads the original cameraman image with 10 rows and 10 columns of zeros after the image. For your own understanding run the original code above then do: > >>imtool(I) > >>imtool(I2) > %That should make it clearer. > Then since the algorithm returns x, y indices into the matrix and the original picture starts in position (1,1) the new indices - original indices will be motion. > > from above: > [row col] = sub2ind(size(I), idx); > x = row - 1; %Should be 3 > y = col - 1; %Should be 6 > > Now if you were calculating this shift at somewhere other than (1,1) you would have to subtract those coordinates instead. I don't know what you're applying this to so it makes it hard to understand > What is your end goal here? > > Good luck! Thanks again Sean for your reply! I am trying to use POC for image registration for finger print recongnition. Basically the function will take two images, original and the other being captured one, implements POC, display POC and finally finds and returns the peak location and its value in the POC. Also how could I use Mesh() function to draw up the POC. Lastly is it possible to use functions like max() and find() to find the peak value and function? Thanks a million.
From: Sean on 28 Mar 2010 19:38 > I am trying to use POC for image registration for finger print recongnition. > > Basically the function will take two images, original and the other being captured one, implements POC, display POC and finally finds and returns the peak location and its value in the POC. > > Also how could I use Mesh() function to draw up the POC. Lastly is it possible to use functions like max() and find() to find the peak value and function? > > Thanks a million. You're welcome. This is a big part of my work and it interests me too. So if you make the POC function exactly as I have detailed above it should work fine. Right now your output arguments are [x y peak]. max() was already used above to give you the linear index of the peak. If you want to see a mesh or surface plot of the peak_correlation_matrix just add it to your output. I.e. [x y peak peak_correlation_matrix] Then all you should have to do is mesh(peak_correlation_matrix) or surf(peak_correlation_matrix). You will see a strong spike at the peak location (Advantages of POC!).
From: Jack Andrews on 29 Mar 2010 05:27 > > You're welcome. This is a big part of my work and it interests me too. > > So if you make the POC function exactly as I have detailed above it should work fine. Right now your output arguments are [x y peak]. max() was already used above to give you the linear index of the peak. If you want to see a mesh or surface plot of the peak_correlation_matrix just add it to your output. I.e. > [x y peak peak_correlation_matrix] > Then all you should have to do is mesh(peak_correlation_matrix) or >surf(peak_correlation_matrix). You will see a strong spike at the peak location >(Advantages of POC!). I tested the algorithm after as you suggested like this: But for the spike I dont seem to get that in the middle? Its more like towards the left. >function [row col peak peak_correlation_matrix] = poc(I, I2) >% fourier transform both images >fi = fft2(I); >fr = fft2(I2); >% perform phase correlation (amplitude is normalized) >fc = fi .* conj(fr); >fcn = fc ./abs(fc); >%(row, col) denotes the peak location in the phase only domain where peak >%shows the value at this location. >peak_correlation_matrix = ifft2(fcn); >[peak, idx] = max(abs(peak_correlation_matrix)); %If you want the peak correlation >value it'll be 'peak', if you want the >[row col] = ind2sub(size(peak_correlation_matrix),idx); %whole correlation matrix >it'll be peak_correlation_matrix. >%Displaying POC >mesh(peak_correlation_matrix); >%Find the peak >find(peak); >end
From: Jack Andrews on 29 Mar 2010 05:40 Pehaps I could use 'fftshift' to turn the center coordinat of phase only correlation to the center of image? Please advice Thanks
From: Jack Andrews on 29 Mar 2010 11:42
Thanks Sean again, Everything is working now! Appreciate your help. I used fftshift function |