I have implemented a gaussian filter following the algorithm of Nixon Aguado. The algorithm (after finding the template as described here gaussian template) is the following.
The pseudo code is in MATLAB style I believe.
function convolved=convolve(image,template)
%New image point brightness convolution of template with image
%Usage:[new image]=convolve(image,template of point values)
%Parameters:image-array of points
% template-array of weighting coefficients
%Author: Mark S. Nixon
%get image dimensions
[irows,icols]=size(image);
%get template dimensions
[trows,tcols]=size(template);
%set a temporary image to black
temp(1:irows,1:icols)=0;
%half of template rows is
trhalf=floor(trows/2);
%half of template cols is
tchalf=floor(tcols/2);
%then convolve the template
for x=trhalf+1:icols-trhalf %address all columns except border
for y=tchalf+1:irows-tchalf %address all rows except border
sum=0;
for iwin=1:trows %address template columns
for jwin=1:tcols %address template rows
sum=sum+image(y+jwin-tchalf-1,x+iwin-trhalf-1)* template(jwin,iwin);
end
end
temp(y,x)=sum;
end
end
%finally, normalise the image
convolved=normalise(temp);
Anyway, what worries me is the last part "normalise". I have tried my algorithm (written in C#) and some pixels got the value 255.00000003 (which is obviously larger than 255). Should I "normalise" the results to enlarge it to a 0-255 range? Wouldn't that be modifying the image (other than the gaussian) I just wan't this operation to involve a gaussian filter and nothing else.
EDIT: I have eliminated the "normalization" and it seems that it works well, so I have no idea why the authors of the book recommended it. Still, worries me that my program will crash if for some reason some value > 255 appears and cannot be drawn.