500 likes | 650 Views
Correlation and Spectral Analysis. Application 4. Review of covariance. Autocorrelation (Autocovariance). Noise Power. Zero-Mean Gaussian Noise. Power Spectrum. E{P n ( k )} = s 2 = 1.12 = R n (0). Auto-correlation. R n (0) = s 2 = 1.12. >> for j = 1:256,
E N D
Correlation and Spectral Analysis Application 4
Power Spectrum E{Pn(k)} = s2 = 1.12 = Rn(0)
Auto-correlation Rn(0) = s2 = 1.12 >> for j = 1:256, R(j) = sum(n.*circshift(n',j-1)'); end
Window Selection: Hamming y = filter(Hamming,1,n);
Filtered Noiseimage = imnoise(I,’gaussian’,0,10); N_autocov = xcorr2(Noiseimage); figure;imagesc(N_autocov/(128*128));colormap(gray);axis('image') Image Noise Field Autocovariance
Unfiltered figure;imagesc(fftshift(abs(fft2(N_autocov/(128*128)))));colormap(gray);axis('image') Power Spectrum Image Noise Field
Filtered (wc = 0.6; order 20; Hamming Window) N_autocov = xcorr2(Noiseimage_filtered); figure;imagesc(N_autocov/(128*128));colormap(gray);axis('image') Autocovariance Image Noise Field
Filtered (wc = 0.6; order 20; Hamming Window) N_autocov = xcorr2(Noiseimage_filtered); figure;imagesc(N_autocov/(128*128));colormap(gray);axis('image') Power Spectrum Image Noise Field
Windowing vs. Filtering • “Window” applied in temporal or spatial domain to reduce spectral leakage and ringing artifact • Windows fall into a specialized set of functions generally used for spectral analysis • “Filter” applied to reduce noise, i.e. noise matching, or to degrade or improve spatial resolution • Some cross-over: one method of filter design is the “window” method which uses window functions for frequency space modulating functions.
Windowing vs. Filtering • Mathematically,
Filtering MP 574
Outline • Review of FIR/IIR Filters • Z-transform • Difference Equation • Filter Design by Windowing • Power Spectra • Correlation and Convolution • Example from Prof. Holden’s Notes • Windowing and Spectral Estimation • Weiner/Adaptive Filters • Deconvolution
z-Transform as an Analysis Tool • Sampled version (discrete version) of the Laplace transform: • z esT, where T is the sampling period. • DFT and z-transform are related: z = eiwT where s eiwT
iw s Laplace to z-Transform Im(z) Non-causal signals unit circle Re(z) 0 ws Discrete FT Continuous FT
f(n) g(n) h(n) T{f(n)} z-Transform and Linear Systems • Stated more generally:
Difference Equation Implementation • Shift theorem of z-transform:
Difference Equation Implementation • Shift theorem of z-transform: FIR
FIR Coefficients and Impulse Response • FIR filter:
FIR vs. IIR filters • Finite impulse response (FIR) implies a linear system that is always stable • There are no poles • Infinite impulse response (IIR) is only stable if poles are inside the unit circle or pole coincides with a zero.
IIR System Im(z) Zeros (o) at: -1, 2 Poles (x) at: 0.5±0.5j, 0.75 unit circle x Re(z) o x o x
fvtool(B,A) B = [1 -1 -2]; A=[1 -1.75 1.25 -0.375]
Unstable B = [1 -1 -2]; A=[1 -1.75 1.25 -0.6]
Unstable B = [1 -1 -2]; A=[1 -1.75 1.25 -0.6]
Finite impulse response (FIR) B = [1 -1 -2]; A=[1]
FIR filter Design by Windowing • Simply truncate IIR filter • Rectangular Window:
filter() in Matlab FILTER One-dimensional digital filter. Y = FILTER(B,A,X) filters the data in vector X with the filter described by vectors A and B to create the filtered data Y. The filter is a "Direct Form II Transposed" implementation of the standard difference equation: a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb) - a(2)*y(n-1) - ... - a(na+1)*y(n-na)
Extension to 2D • Radial Transform • H(k)-> (H(k1)2+H(k2)2)1/2=T(k1,k2) • See Matlab script on filter design using radial transformation to 2D: Filter Design • http://zoot.radiology.wisc.edu/~fains/Code/MP574_FilterDesign.m • Parks-McClellan Transformation • Step 1: Translate specifications of H(w1,w2) to H(w) • Step 2: Design 1D filter H(w) • Step 3: Map to 2D frequency space cosw = - ½ + ½ cosw1 + ½ cosw2 + ½ cosw1 cosw2 = T(w1,w2) - Step 4: determine h(n1,n2) by 2D FT.
Hamming Window Example >> w1 = -pi:0.01:pi; >> w2 = -pi:0.01:pi; >> [W1,W2] = meshgrid(w1,w2); >> H_2d = 0.54+0.46.*(-0.5+0.5.*cos(W1)+0.5.*cos(W2)+0.5.*cos(W1).*cos(W2)); >>figure;mesh(H_2d) filter2()