Re: fft2 and ifft2 outputs



nick wrote:


X = (A3.*r)/(abs(A3).*abs(r));

should read
X = (A3.*conj(r))./(abs(A3).*abs(r));

Whoops sorry

Dave Robinson

when i sub this line for the old one i get a
"divide by zero warning"

Why should i use this line over my original of
X=A3.*r; ???

my understanding of ur line is

A3 element by element mult of the complex conjugate of r,

./ is this element by element divide?

then taking the absolute value of A3 and r and .* them

I understand the sections of this lione of code, but not what it
actually does as a whole.

cheers

Nick

Yes ./ is the element by element divide.

Unfortunately I just copied and pasted from your original note, and
didn't notice that the conj() function was missing. In the frequency
domain convolution is undertaken by doing a .* of two vectors,
whereas correlation requires the conjugation of the second vector.

The reason that you are getting a divide by zero error is because you
have got some zeros in your data (i.e frequency components that
contain no data/energy). Normally in this position you have a 0/0
condition. How I usually fix that (and I warn you at the start it is
a bit of a bodge), I calculate abs(a).*abs(b) seperately, then hunt
out all locations which contain zeros, and replace them with a very
small number (say max(a)/1000000.0)This prevents the divide by zero,
and as the chances are the top deck is also 0, results in a 0 in the
final quotient.

Zero_points = find(Abs_Product==0);
Abs_Product(Zero_points) = little_number;

One could argue that you could get a better result by adding in a
very small random number to both the spectra before doing the
correlation (e.g. making it slightly noisy) The correlation will
remove most of the effect of this, although there is still the
possibility that the random noise will have an exactly 0 value still
leaving you with your problem.

What the algorithm actual does is a phase correlation. This makes it
very much more robust, and unlike the standard correlation which is
dependent on the relative intensity of the template and target, this
algorithm is not.

Hope that helps - comeback I would like to know the outcome of your
tests

Dave Robinson
.



Relevant Pages

  • Re: Phase Only Correlation with zero coordinate in center of image
    ... Please tell me how to write code phase only correlation with zero ... i did write code phase only correlation that i get in some website. ... Dave Robinson ...
    (comp.soft-sys.matlab)
  • Re: DataType Conversion Speed
    ... Then divide by zero to conver to percent. ... > - if either field contains a value, that's the discount, ... > Then divide by zero to conver to percent. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Correlation of X with XY ?
    ... For Mean=0 the correlation will in fact be zero. ... vectors fall on the "13 symmetry axes of a cube ". ... a dispute arose because actual Psychology Tests ...
    (sci.stat.math)
  • Re: DataType Conversion Speed
    ... > Then divide by zero to conver to percent. ... >> - if either field contains a value, that's the discount, ... >> Then divide by zero to conver to percent. ...
    (microsoft.public.access.modulesdaovba)
  • Re: How many mathematicians ...
    ... be divided by 7 before multiplying by 6. ... Who is trying to divide h by 7? ... No division by zero. ... gets to zero even if Bonehead wishes it so. ...
    (sci.physics.relativity)