对于图像来说,高斯滤波器是利用高斯核的一个2维的卷积算子,用于图像模糊化(去除细节和噪声)。 1. 高斯分布 一维高斯分布 , 二维高斯分布 2.高斯核 理论上,高斯分布在所有定义域上都有非负值,这就需要一个无限大的卷积核。实际上,仅需要取均值周围3倍标准差内的值,以外部份直接去掉即可。 如下图为一个标准差为1.0的整数值高斯核。 3. 高斯滤波(平滑) 完成了高斯核的构造后,高斯滤波就是用此核来执行标准的卷积。 4.应用 高斯滤波后图像被平滑的程度取决于标准差。它的输出是领域像素的加权平均,同时离中心越近的像素权重越高。因此,相对于均值滤波(mean filter)它的平滑效果更柔和,而且边缘保留的也更好。 高斯滤波被用作为平滑滤波器的本质原因是因为它是一个低通滤波器,见下图。而且,大部份基于卷积平滑滤波器都是低通滤波器。 图.高斯滤波器(标准差=3像素)的频率响应。The spatial frequency axis is marked in cycles per pixel, and hence no value above 0.5 has a real meaning。 Matlab函数:h = fspecial('gaussian', hsize, sigma) returns a rotationally symmetric Gaussian lowpass filter of size hsize with standard deviation sigma (positive). hsize can be a vector specifying the number of rows and columns in h, or it can be a scalar, in which case h is a square matrix. The default value for hsize is ; the default value for sigma is 0.5. 5 资源: 1) http://homepages.inf.ed.ac.uk/rbf/HIPR2/gsmooth.htm
转自: program main implicit none character(len=20) input logical alive integer,parameter::inputfile=11,outputfile=12 integer ::counter=0,lines real x,y,w2 real,allocatable:: x0(,y0( real left,right real ::A=3.0,step=0.05,w !A为半高宽,step为x增加的间距 integer ::status w2=A**2/2/LOG(2.0) write(*,*)"input file name:" read(*,*)input inquire(file=input,exist=alive) if(.not.alive)then write(*,*)input,"does not exist" stop end if open(unit=inputfile,file=input,access="sequential",status="old" do while(.true.) read(unit=inputfile,fmt="(F6.2,1X,F8.6)",iostat=status)x,y if(status/=0)exit counter=counter+1 write(*,*)counter,"line:",x,y end do lines=counter rewind(inputfile) allocate(x0(counter)) allocate(y0(counter)) do counter=1,lines read(unit=inputfile,fmt="(F6.2,1X,F8.6)",iostat=status)x0(counter),y0(counter) if(status/=0)exit end do write(*,*)"left:" read(*,*)left write(*,*)"right:" read(*,*)right open(unit=outputfile,file="data.dat" x=left do while(x=right) y=0.0 do counter=1,lines if(abs(x-x0(counter)=3*A)) then y=y0(counter)/EXP(2*(x-x0(counter))**2/w2)+y end if end do write(unit=outputfile,fmt="(F6.2,1X,F8.6)"x,y x=x+step end do stop end program
betarnd 贝塔分布的随机数生成器 binornd 二项分布的随机数生成器 chi2rnd 卡方分布的随机数生成器 exprnd 指数分布的随机数生成器 frnd f分布的随机数生成器 gamrnd 伽玛分布的随机数生成器 geornd 几何分布的随机数生成器 hygernd 超几何分布的随机数生成器 lognrnd 对数正态分布的随机数生成器 nbinrnd 负二项分布的随机数生成器 ncfrnd 非中心f分布的随机数生成器 nctrnd 非中心t分布的随机数生成器 ncx2rnd 非中心卡方分布的随机数生成器 normrnd 正态(高斯)分布的随机数生成器 poissrnd 泊松分布的随机数生成器 raylrnd 瑞利分布的随机数生成器 trnd 学生氏t分布的随机数生成器 unidrnd 离散均匀分布的随机数生成器 unifrnd 连续均匀分布的随机数生成器 weibrnd 威布尔分布的随机数生成器 RANDN Normally distributed random numbers. RANDOM Generate random arrays from a specified distribution. R = RANDOM(NAME,A) returns an array of random numbers chosen from the one-parameter probability distribution specified by NAME with parameter values A. R = RANDOM(NAME,A,B) or R = RANDOM(NAME,A,B,C) returns an array of random numbers chosen from a two- or three-parameter probability distribution with parameter values A, B (and C). The size of R is the common size of the input arguments. A scalar input functions as a constant matrix of the same size as the other inputs. R = RANDOM(NAME,A,M,N,...) or R = RANDOM(NAME,A, ) returns an M-by-N-by-... array of random numbers for a one-parameter distribution. Similarly, R = RANDOM(NAME,A,B,M,N,...) or R = RANDOM(NAME,A,B, ), and R = RANDOM(NAME,A,B,C,M,N,...) or R = RANDOM(NAME,A,B,C, ), return an M-by-N-by-... array of random numbers for a two- or three-parameter distribution. NAME can be: 'beta' or 'Beta', 'bino' or 'Binomial', 'chi2' or 'Chisquare', 'exp' or 'Exponential', 'ev' or 'Extreme Value', 'f' or 'F', 'gam' or 'Gamma', 'gev' or 'Generalized Extreme Value', 'gp' or 'Generalized Pareto', 'geo' or 'Geometric', 'hyge' or 'Hypergeometric', 'logn' or 'Lognormal', 'nbin' or 'Negative Binomial', 'ncf' or 'Noncentral F', 'nct' or 'Noncentral t', 'ncx2' or 'Noncentral Chi-square', 'norm' or 'Normal', 'poiss' or 'Poisson', 'rayl' or 'Rayleigh', 't' or 'T', 'unif' or 'Uniform', 'unid' or 'Discrete Uniform', 'wbl' or 'Weibull'.