% ==================================================================================================
% Module:   imavgfilter.m
%
% Usage:    5 x 5 Avererage Filter
%
% Purpose: 
%     Runs a 5x5 average filter on image.
%     
% Input Variables:
%     nTheImage     input image
%     
% Returned Results:
%     The filtered image.
%     
% Restrictions/Notes:
%     This function is geared for grayscale images.
%     
% See Also:
% 
% References:
% 
% Author:       Isaac Gerg
% Date:         1/15/04
% Revisions:    none
% ==================================================================================================

function nOutput = imavgfilter(nTheImage)
	nWidth = size(nTheImage, 1);
	nHeight = size(nTheImage, 2);
	
	nOutput = zeros(size(nTheImage));
	
	nAvg = 0;
	neighborhood = [];
	for x = 1:nWidth,
        for y = 1:nHeight,
            if x>2 && x<nWidth-1 && y>2 && y<nHeight-1
                nNeighborhood = nTheImage(x-2:x+2, y-2:y+2);
                nAvg = sum(sum(nNeighborhood))/25;
                nOutput(x, y) = nAvg;  
            end
        end
	end

