No BSD License  

Highlights from
z-transform of 1D & 2D Savitzky-Golay Smoothing and Differentiation Filter

image thumbnail

z-transform of 1D & 2D Savitzky-Golay Smoothing and Differentiation Filter

by

 

02 Nov 2005 (Updated )

z-transform of 1D & 2D Savitzky-Golay Smoothing and Differentiation Filter

ztdemo
% NOTES
% Savitzky-Golay (GS)Filters are polynomial-based filters frequently used
% for processing of 2D Images. A good basic introdution to these filters
% is found on net at:
% http://research.microsoft.com/users/jckrumm/SavGol/SavGol.htm.
%
% The following MATLAB functions that compute GS-filters are available
% at the MATLAB File Exchange:
% File IDs [4038; 5661; 4270; 6121; 7003; 5556; 6047; 6151]
%
% This zip-folder contains two functions: ztrans1d.m and ztrans2d.m
% that compute the z-transform of any GS filter and plot its amplitude
% spectrum.
%
% Following is a demo of these functions in action for 1D and 2D
% GS-filters.
%
% (1) 1D Smoothing & Differentiation Filters
h = sgsdf1d([-5:5],1,0,0,0);
[A,u]=ztrans1d(h);
subplot(2,2,1),plot(u/pi,A);grid;
title('Smoothing of Order 1');

h = sgsdf1d([-5:5],5,0,0,0);
[A,u]=ztrans1d(h);
subplot(2,2,2),plot(u/pi,A);grid;
title('Smoothing of Order 5');

h = sgsdf1d([-5:5],3,1,0,0);
[A,u]=ztrans1d(h);
subplot(2,2,3),plot(u/pi,A);grid;
title('1st Derivative of Order 3');

h = sgsdf1d([-5:5],4,3,0,0);
[A,u]=ztrans1d(h);
subplot(2,2,4),plot(u/pi,A);grid;
title('3ed Derivative of Order 4');

% (2) 2D Smoothing & Differentiation Filters
% Smoothing.
h=sgsf2d([-5:5],[-5:5],3,1);
[u,v,T]=ztrans2d(h);
figure;
subplot(2,2,1),surfc(u/pi,v/pi,T);
title('Smoothing of Order 3');

h=sgsf2d([-5:5],[-5:5],7,1);
[u,v,T]=ztrans2d(h);
subplot(2,2,2),surfc(u/pi,v/pi,T);
title('Smoothing of Order 7');

%
% Differentiation
h=sgdf2d([-5:5],[-5:5],3,1);
[u,v,T]=ztrans2d(h);
subplot(2,2,3),surfc(u/pi,v/pi,T);
title('1st Derivative of Order 3');

h=sgdf2d([-5:5],[-5:5],7,1);
[u,v,T]=ztrans2d(h);
subplot(2,2,4),surfc(u/pi,v/pi,T);
title('1st Derivative of Order 7');

Contact us