-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGrayCodePattern4ProjectorCalibration.m
More file actions
39 lines (28 loc) · 1.27 KB
/
GrayCodePattern4ProjectorCalibration.m
File metadata and controls
39 lines (28 loc) · 1.27 KB
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
function [ grayPatternSeq ] = GrayCodePattern4ProjectorCalibration( 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)));
% Éú³ÉÈ«°×ºÍÈ«ºÚͼ
refferPattern(:, :, 1) = ones(resolution(2), resolution(1));
refferPattern(:, :, 2) = zeros(resolution(2), resolution(1));
% 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), 2 * col_proj_img_num);
for i = 1:col_proj_img_num
colPatternSeq(:, :, 2 * i - 1) = transpose(repmat(mat(:, i), 1, resolution(2)));
temp = colPatternSeq(:, :, 2 * i - 1);
colPatternSeq(:, :, 2 * i) = ones(size(temp)) - temp;
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), 2 * row_proj_img_num);
for i = 1:row_proj_img_num
rowPatternSeq(:, :, 2 * i - 1) = repmat(mat2(1:resolution(2), i), 1, resolution(1));
temp2 = rowPatternSeq(:, :, 2 * i - 1);
rowPatternSeq(:, :, 2 * i) = ones(size(temp2)) - temp2;
end
% cat 3 seq
grayPatternSeq = cat(3, refferPattern, colPatternSeq, rowPatternSeq);
end