Re: Gaussian Convolution [message #3190] |
Fri, 18 November 1994 14:08 |
velt
Messages: 19 Registered: June 1994
|
Junior Member |
|
|
In reply to: Thomas Edgar Nichols <tn0o+@andrew.cmu.edu>
Date: Mon, 14 Nov 1994 00:24:11 -0500
>
> I have checked the FAQ and poked around the suggested FTP sites and have
> not come up with a
> Gaussian Blur function (in 3D)
> along the lines of smooth() which uses a uniform kernal instead of a
> Gaussian one.
>
I wrote a Gaussian smoothing a while ago for a image processing class.
It's two-D, but can easily be extende to 3D. It is a very small piece
of code, and is not exactly fast, but it does the job.
Robert Velthuizen, velt@rad.usf.edu
Digital Medical Imaging Program of the
H. Lee Moffitt Cancer Center and Research Institute at the
University of South Florida.
============================================================ =====
;+
; Name: gsmooth
; Purpose: smooth an image with a gaussian template
; Calling-seq: result=gsmooth(image,sigma)
; Inputs: image: a 2d array
; sigma: standard deviation of the smoothing function
; Author: Robert Velthuizen 020492
;-
Function gsmooth, image, sigma
if sigma lt 0.25 then return,image
TemplateWidth=fix(2*sigma +0.5)
Template=exp(-0.5*(indgen(TemplateWidth + 1)/sigma)^2)
Template=Template/(template(0)+2*total(template(1,*)))
Temp=Template(0)*image
for i=1,TemplateWidth do $
Temp=Temp + Template(i)*(1.0 * shift(image,i,0) + shift(image,-i,0))
Temp2=Template(0)*Temp
for i=1,TemplateWidth do $
Temp2=Temp2 + Template(i)*(1.0 * shift(Temp,0,i) + shift(Temp,0,-i))
return,Temp2
end
|
|
|