[visionlist] phase spectrum scrambling

Steven Dakin s.dakin at ucl.ac.uk
Thu May 31 17:59:51 GMT 2007


hi mariya
(am posting this as it may be of general-ish interest.)
if your image is called 'im' and is ranged 0-1 then the
following code should work:

   [m n p]=size(im);
   for i=1:p
        im1=im(:,:,i); % get separate RGB components
        mi=min(im1(:)); ma=max(im1(:)); % store so we can make noise have
the same range
        pow1=abs(fft2(im1))   % compute image power
        phase2=angle(fft2(randn(m))); % get phase structure from some noise
        tmp1=real(ifft2(cos(phase2).*pow1+sqrt(-1).*sin(phase2).*pow1));
%combine power+phase

res(:,:,i)=mi+(ma-mi).*(tmp1-min(tmp1(:)))./(max(tmp1(:))-min(tmp1(:)));
%scale range
   end
   imshow(res)

the code uses 2 FFTs because a neat trick to make random phases
that have right (Hermitian) symmetries in the fourier domain is to compute
them from the FFT of a noise pattern. if you don't do this (i.e. use
randn(m).*2*pi
or similar for phases) you will have substantially non-zero imaginary
components when you back-transform the combination of the power and phase.

good luck
best
steven
------------
Dr. Steven Dakin
UCL Institute of Ophthalmology
Bath Street
London EC1V 9EL

Office: +44 207 608 6988
Lab:    +44 207 608 6924
Fax:    +44 207 608 6850
Skype:+44 208 123 5999 or scdakin
Web:   http://www.dakinlab.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://visionscience.com/pipermail/visionlist/attachments/20070531/cb96777c/attachment.htm


More information about the visionlist mailing list