syn_Img.m
566 Bytes
function I1 = syn_Img(r, ps)
range = -r:r;
[cx, cy, cz] = meshgrid(range, range, range);
c1 = zeros(2*r+1,2*r+1,2*r+1);
c1(cx.^2 + cy.^2 + cz.^2 < r^2) = 255;
I1 = zeros(ps);
sx = [15 50 45 78 31 20 85];
sy = [23 17 34 29 19 25 15];
sz = [15 20 25 17 23 18 24];
for kk = 1:7
% set = [randi([r+1,ps(1)-r]) randi([r+1,ps(2)-r]) randi([r+1,ps(3)-r])];
% I1(set(1)-r:set(1)+r, set(2)-r:set(2)+r, set(3)-r:set(3)+r)= c1;
I1(sx(kk)-r:sx(kk)+r, sy(kk)-r:sy(kk)+r, sz(kk)-r:sz(kk)+r)= c1;
end
% -------------------------------------------------------------------