-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgenerateDatasetOneClass.m
78 lines (58 loc) · 2.16 KB
/
generateDatasetOneClass.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
%
% Compute a certain number of holograms (nbHolograms) with a certain number of
% point sources in the 3D scene (nbPoints)
%
% Inputs:
% nbPoints
% - Number of point sources in the hologram
% nbHolograms
% - Number of holograms created with nbPoints point sources
%
% Outputs:
% hologramDataset
% - Array NxNxH with all holograms calculated for the specific class
% reconstructionDataset
% - Array NxNxH with all reconstructed images calculated for the specific class
% pointsDataset
% - Matrix (H*P)x3 with the positions of all the points for the specific class
%
function [hologramDataset, reconstructionDataset, pointsDataset] = ...
generateDatasetOneClass(nbPoints, nbHolograms)
% Location of the reconstructed image in the z-axis
targetZ = -0.2;
% Dimensions of the hologram
hologramWidth = 2e-3; % 2mm
hologramHeight = 2e-3; % 2mm
% Size of the hologram plane and reconstructed image plane
hologramSamplesX = 200;
hologramSamplesY = 200;
% Range of values for particle position
rangeX = hologramWidth/2;
rangeY = hologramHeight/2;
depth = 0.5;
% Create database to store values
hologramDataset = zeros(hologramSamplesX, hologramSamplesY, nbHolograms);
reconstructionDataset = zeros(hologramSamplesX, hologramSamplesY, nbHolograms);
pointsDataset = zeros(nbHolograms*nbPoints, 3);
points3DScene = zeros(nbPoints, 3);
% Auxiliar
counter = 1;
for index = 1:nbHolograms
for j = 1:nbPoints
% Generate a random 3D point
point3D = generateRandomPoint(rangeX, rangeY, depth);
% Force z value to be in accordance with the place of reconstruction (BUG)
%point3D(1,3) = targetZ;
% Add the point created in the matrix with all points
points3DScene(j, :) = point3D;
% Database update
pointsDataset(counter,:) = point3D;
counter = counter + 1;
end
% Compute hologram
[hologram, reconstruction] = computeHologram(points3DScene, targetZ);
% Database update
hologramDataset(:,:,index) = hologram;
reconstructionDataset(:,:,index) = reconstruction;
end
end