Description Usage Arguments Details Value Author(s) See Also Examples
Input two images (matrices) and perform phase correlation by multiplication in the frequency domain. Return the maximum phase correlation value, its associated shift vector (x and y), and the phase correlation matrix.
1 | pcorr3d(img1,img2)
|
img1 |
Image (matrix) 1 |
img2 |
Image (matrix) 2 with same dimensions of |
Phase correlation calculated in the frequency domain as a multiplication. The dimensions of img1
and img2
must match. If pcorr3d
is used to apply a match filter, it is logical to input the image to be searched over as img1
and the match filter as img2
. Similarly, if tracking relative motion between images, it is logical to input the first image at time t=n as img1
and the second image at time t=n+1 as img2
, otherwise motions will backwards.
List whose values correspond to:
max.shifts |
Vector of length two whose values are the x and y indices associated with the highest phase correlation value. Note these values are shifted according to the zero frequency which changes depending on the dimensions of |
max.corr |
Highest normalized phase correlation value in the correlation matrix |
corr.mat |
Normalized phase correlation matrix |
Alex J.C. Witsil
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 | #################
### Example 1 ###
#################
## track movement between images
## load in the images
data(tux1,tux2)
## now find the shift vector by using the phase correlation function
shifts <- pcorr3d(tux1,tux2)
## ---- Plotting Example 1 ----- ##
split.screen(c(1,2))
screen(1)
image(1:nrow(tux1),1:ncol(tux1),tux1,col=gray.colors(200))
## define an example arrow starting and end points based on the shift found
x0 = nrow(tux1)/2
y0 = ncol(tux1)/2
x1 = x0 + shifts$max.shifts[1]
y1 = y0 + shifts$max.shifts[2]
## add arrows indicating how the image shifted
arrows(x0,y0,x1,y1)
## add a point where the arrow is
points(nrow(tux1)/2+shifts$max.shifts[1],ncol(tux1)/2+shifts$max.shifts[2],pch=21,bg='green')
screen(2)
image(1:nrow(tux2),1:ncol(tux2),tux2,col=gray.colors(200))
points(nrow(tux1)/2+shifts$max.shifts[1],ncol(tux1)/2+shifts$max.shifts[2],pch=21,bg='green')
## close the screen
close.screen(all.screens=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.