GRID MAPPING Z-TRANSFORMS 9-2-2011 By Laurence G. Hassebrook 1. Grid Mapping a Z-transform As an example, let’s grid map a simple single pole Z-form H (z ) = 1 1 − a z −1 ( ) The code used can be found in the appendix. We let a=0.4 with results in a pole on the real axis at 0.4 units. A contour map is shown in Fig. 1. The term grid mapping indicates that to get Fig. 1 we looped through each pixel and then calculated the mapping back to H(z) a complex value. The solution to the grid mapping is %Rxout=axy*Nx+bxy, -Rxout=axy*1+bxy, axy=2*Rxout/(Nx-1); bxy=Rxout-axy*Nx; where axy and bxy are the scale and offset to map from pixel coordinates {x,y} (sometimes called “u,v”) and complex coordinates such that alpha=axy*x+bxy; sigma=axy*y+bxy; where alpha is the Euclidian real coordinate and sigma is the imaginary coordinate. Figure 1: Color encoded contour map of H(z). The Discrete-Time Fourier Transform (DTFT) is defined on the “unit circle” in the Z-plane so we can sample the DTFT by grid mapping between a unit circle and H(z). The resulting amplitude and phase are plotted in Fig. 2. The grid mapping is done with a single loop such that the index n sequences through an angle from 0 to 2π radians. 1 for n=1:Ndtft alpha=cos(2*pi*(n-1)/Ndtft); sigma=sin(2*pi*(n-1)/Ndtft); x=round((alpha-bxy)./axy); y=round((sigma-bxy)./axy); dtft(n)=Zmap(y,x); end; % n Figure 2: Amplitude and Phase along unit circle. If we set the suppression radius Rxin=1 for the code in the appendix, a 3-D plot using GL3Dview would clearly show the relationship between the unit circle and the response as shown in Fig. 3. Figure 3: 3D representation of H(z) with |z|<1 suppressed to 0. VISUALIZATION: Reproduce the example results and visualization with the 2-pole Z-form: 2 H (z ) = 1 − r z −1 cos(ω0 ) 1 − 2 r z −1 cos(ω0 ) + r 2 z − 2 For r = 0.8 and ω0 = π/4. APPENDIX: A. Sample Code for a single pole Z-form clear all; % Grid Mapping 2-D signals % H(z)=1/(1-az^(-1)); a=.4; Rxin=0; Rxout=2; Zmax=20; Nx=256; My=Nx; % grid map coefficients Rxin %Rxout=axy*Nx+bxy, -Rxout=axy*1+bxy, axy=2*Rxout/(Nx-1); bxy=Rxout-axy*Nx; % Zmap=zeros(My,Nx)+i*zeros(My,Nx); for x=1:Nx for y=1:My alpha=axy*x+bxy; sigma=axy*y+bxy; r2=alpha*alpha+sigma*sigma; z=alpha-i*sigma; if r2>=Rxin.^2 if z ~= a Zmap(y,x)=1/(1-a/z); else Zmap(y,x)=0+i*0; end; else Zmap(y,x)=0+i*0; end; if Zmap(y,x) >=Zmax Zmap(y,x)=Zmap(x,y)/Zmax; end; end; % y end; % x zmax=max(max(abs(Zmap))); zmin=min(min(abs(Zmap))); figure(1); imagesc(real(Zmap)); %colormap gray; colormap VGA; axis image print -djpeg90 figure1_1.jpg % display Figure 1 % store mat5file 3 Albedo8=uint8(round( 255*(abs(Zmap)-zmin)./(zmax-zmin) ) ); imageC=uint8(zeros(My,Nx,3)); imageC(:,:,1)=Albedo8; imageC(:,:,2)=Albedo8; imageC(:,:,3)=Albedo8; Albedo8=uint8(20*ones(My,Nx)); imageI=zeros(My,Nx,3); imageI(:,:,1)=Albedo8; imageI(:,:,2)=Albedo8; imageI(:,:,3)=Albedo8; index=1; xw=zeros(My,Nx); yw=xw; zw=yw; for x=1:Nx for y=1:My xw(index)=x-1; yw(index)=y-1; zw(index)= abs( Zmap(y,x)*Nx/(2*(zmax-zmin)) ); index=index+1; end; end; mat5prefix = 'SinglePoleZform'; result= mat5CIXYZwrite2011(mat5prefix,imageC,imageI,xw,yw,zw); % get the DTFT Ndtft=512; k=1:Ndtft; dtft=zeros(1,Ndtft)+i*zeros(1,Ndtft); for n=1:Ndtft alpha=cos(2*pi*(n-1)/Ndtft); sigma=sin(2*pi*(n-1)/Ndtft); x=round((alpha-bxy)./axy); y=round((sigma-bxy)./axy); dtft(n)=Zmap(y,x); end; % n figure(2); plot(k,abs(dtft),k,angle(dtft)); xlabel('frequency'); ylabel('Amplitude & Phase of DTFT'); axis([0 N 0 1.1]);print -djpeg90 figure1_2.jpg % display Figure 2 4