source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vlutil/toolbox/imwhiten.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 985 bytes
Line 
1function J=imwhiten(I,alpha,cutoff)
2% IMWHITEN  Whiten image
3%  J = IMWHITEN(I,ALPHA,CUTOFF) approximatively whitens the power
4%  spectrum of the natural image I. The algorithm assumes that the
5%  modulus of the spectrum decays as 1/f^ALPHA (f is the frequency).
6%
7%  IMWHITEN(I) uses ALPHA=1 (typical value for natural images).
8%
9%  IMWHITEN(I,ALPHA,CUTOFF) also applies a low-pass filter with cutoff
10%  frequency equal to CUTOFF x FN, where FN is the Nyquist
11%  frequency (half of the sampling frequency).
12%
13
14if ~exist('alpha'),  alpha = 1 ; end
15if ~exist('cutoff'), cutoff = [] ; end
16
17[M,N]=size(I) ;
18
19% Frequency domain
20fn = 0.5 ; % Nyquist freq (=1/2T, T=1)
21fx_range=linspace(-fn, fn, N) ;
22fy_range=linspace(-fn, fn, M) ;
23[fx fy]=meshgrid(fx_range, fy_range) ;
24
25% Whitening filter
26rho=sqrt(fx.*fx+fy.*fy);
27filt=rho ;
28
29% Low-pass filter
30if ~isempty(cutoff)
31  fcut = cutoff * fn ;
32  filt = filt .* exp(-(rho/fcut).^4);
33end
34
35% Apply filter
36J = real(ifft2(fft2(I).*fftshift(filt))) ;
Note: See TracBrowser for help on using the repository browser.