Function iawcorr

namespace:ia636
page:iawcorr

Synopse

Perform weighted correlation between two images of the same size

Weighed Average

Weighed Covariance

Weighed Correlation

  • corr= iawcorr(im1, im2, w)
    • im1, im2: input images
    • w: array of weights, with the same dimentions as im1 and im2
    • corr: correlation between im1 and im2 weighted by w
01. def iawcorr(im1, im2, w):
02.     import numpy as np
03.     w = w.astype(float)
04.     wf = w.ravel()
05.     sw = np.sum(wf)
06.     im1f = im1.astype(float).ravel()
07.     im2f = im2.astype(float).ravel()
08.     mim1f = np.sum(im1f * wf)/sw
09.     mim2f = np.sum(im2f * wf)/sw
10. 
11.     im1x = im1f - mim1f
12.     im2x = im2f - mim2f
13. 
14.     cov12 = np.sum(im1x*im2x*wf)/sw
15.     cov11 = np.sum(im1x*im1x*wf)/sw
16.     cov22 = np.sum(im2x*im2x*wf)/sw
17. 
18.     return cov12/np.sqrt(cov11*cov22)
1. pass