-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGrayCodePattern.m
More file actions
31 lines (21 loc) · 892 Bytes
/
GrayCodePattern.m
File metadata and controls
31 lines (21 loc) · 892 Bytes
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
function [ grayPatternSeq ] = GrayCodePattern( resolution )
% input: resolution: the gray pattern img size you want
col_proj_img_num = ceil(log2(resolution(1)));
row_proj_img_num = ceil(log2(resolution(2)));
% generate col pattern seq
col_gray_de = grays(col_proj_img_num);
mat = transpose(flip(transpose(de2bi(col_gray_de))));
colPatternSeq = zeros(resolution(2), resolution(1), col_proj_img_num);
for i = 1:col_proj_img_num
colPatternSeq(:, :, i) = transpose(repmat(mat(:, i), 1, resolution(2)));
end
% generate row pattern seq
row_gray_de = grays(row_proj_img_num);
mat2 = transpose(flip(transpose(de2bi(row_gray_de))));
rowPatternSeq = zeros(resolution(2), resolution(1), row_proj_img_num);
for i = 1:row_proj_img_num
rowPatternSeq(:, :, i) = repmat(mat2(1:resolution(2), i), 1, resolution(1));
end
% cat 2 seq
grayPatternSeq = cat(3, colPatternSeq, rowPatternSeq);
end