View Single Post
Old 19th April 2011, 16:01   #6  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
Well actually I tried. First of all, when you do divisions you generally need a lot of accuracy, and I did numerical studies and you need at least 16 bits (they ranged up to 24). Next, there's one step in the equation where you have an expression of 4 variables, which I couldn't do. Maybe you can find some way to do it.
Here's some code:
Code:
For i=0 To l-1
	mx=mx+ref(i)
	my=my+v(i)
Next i

mx=mx/l
my=my/l

For i=0 To l-1
	sxy=sxy+(ref(i)-mx)*(v(i)-my)
	s2x=s2x+(ref(i)-mx)^2
	s2y=s2y+(v(i)-my)^2
Next i

r=sxy/(sqr(s2x)*Sqr(s2y))
ps this is one of the reasons I was wishing for shift operators in masktools; I finally got it in a48, so it should be easier now anyways.
I calculated the means mx my as averages directly. I think you can even do that with a simple resize.
My DeepColor tools has some of the code needed (it does 16bit operations with masktools).

Last edited by jmac698; 19th April 2011 at 16:23.
jmac698 is offline   Reply With Quote