0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 function [points,BB,dx,dem,bin_im,dist_t]=simulate_points_dem_16_precision(N,sigma_h,R)
0019
0020
0021
0022
0023 BB=[0,0,R,R];
0024
0025 factor=1;
0026 dx = 1/factor;
0027
0028 p = (1+rand(N,2)*(R-2));
0029 M=randn(4);
0030 a =[ones(N,1) (2*p(:,1)-R)/R (4*p(:,1).^2-4*p(:,1)*R-R^2)/(2*R^2) ...
0031 (2*p(:,1)-R).*(2*p(:,1).^2-2*p(:,1)*R-R^2)/R^3];
0032 b =[ones(N,1) (2*p(:,2)-R)/R (4*p(:,2).^2-4*p(:,2)*R-R^2)/(2*R^2) ...
0033 (2*p(:,2)-R).*(2*p(:,2).^2-2*p(:,2)*R-R^2)/R^3];
0034 z = 2*diag(a*M*b');
0035 points = [p,z,ones(N,1)*sigma_h];
0036
0037 k=0;
0038 for i=[1,round(R/2),R-1]
0039 for j=[1,round(R/2),R-1]
0040 k=k+1;
0041 points(k,:)=[i,j,2*[1 (2*i-R)/(2*R) 1/2*(4*i^2-4*i*R-R^2)/R^2 ...
0042 (2*i-R)*(2*i^2-2*i*R-R^2)/R^3]*M*...
0043 [1 (2*j-R)/(2*R) 1/2*(4*j^2-4*j*R-R^2)/R^2 ...
0044 (2*j-R)*(2*j^2-2*j*R-R^2)/R^3]',sigma_h];
0045 end
0046 end
0047
0048
0049
0050
0051
0052 xmin = BB(1);
0053 ymin = BB(2);
0054 xmax = BB(3);
0055 ymax = BB(4);
0056
0057 Nr = ceil((xmax-xmin)/dx)+1;
0058 Mc = ceil((ymax-ymin)/dx)+1;
0059
0060 dem = zeros(Nr,Mc);
0061
0062 bin_im = dem;
0063 for n=1:N
0064 i=ceil(points(n,1)*factor);
0065 j=ceil(points(n,2)*factor);
0066 bin_im(R+1-j,i)=1;
0067 end
0068
0069 ss = plot_init;
0070 figure('Color','w','Position',[0.1*ss(1),0.2*ss(2),0.7*ss(1),0.6*ss(2)])
0071 subplot(1,2,1)
0072 imshow(bin_im)
0073 axis equal
0074 dist_t=bwdist(bin_im,'euclidean');
0075 subplot(1,2,2)
0076 imagesc(sqrt(dist_t));
0077 title('points and distance transform')
0078 axis equal
0079 axis off
0080
0081
0082
0083 return