% SAMPLE2D - Sample a 2D area using Gaussian Sampling % % Usage: % % function s = Sample2D(im,x0,y0,m,sig) % % Arguments: % % im = The image. % x0,y0 = position in im. % m = mask size. % sig = sigma of the Gaussian funcion. % % Returns: % % s = sample % % Copyright (c) 2012-2013 Anders Hast % Uppsala University % http://www.cb.uu.se/~aht % % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the "Software"), to deal % in the Software without restriction, subject to the following conditions: % % The above copyright notice and this permission notice shall be included in % all copies or substantial portions of the Software. % % The Software is provided "as is", without warranty of any kind. % function s = Sample2D(im,x0,y0,m,sig) x=floor(x0); y=floor(y0); m=floor(m/2); gs=0; s=0; for i=-m:m for j=-m:m g = Gauss2D(x+i,y+j,x0,y0,sig); gs=gs+g; s=s+g*im(x+i,y+j); end end s=s/gs; end