Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

matlab - How to create a gray code pattern that relates to frequency

I am trying to create a sequence of gray code pattern that relates with the frequency.

gray code 512

The above image shows for one row pixel the gray code patterns and a wrapped phase which was obtained from sinusoidal pattern. Here, the number of gray code patterns were obtained based on number of cycles. For frequency = 150, we need 150 pixels for each cycle and thus, we have totally 6 cycles. So the gray code pattern should follow the same atleast for the final sequence 3 as shown in figure below.

gray code original

As you can see in my case, my pixel range for G3 is around 250 and i need it for 150. How to change do this?

f = 100; no_cycles_1 = floor(px/f1); 
gray_level = ceil(sqrt(no_cycles_freq));
n = ceil(log2(1024));
pattern = zeros(2^n,1) ;  pattern(2) = 1;  T = 2;
for  k = 2:n
    T2 = T+T;
    pattern(T+1:T2) = T + flipud(pattern(1:T));
    T = T2;  
end
mat = transpose(flip(transpose(de2bi(pattern))));
gray_pattern = zeros(py,px,gray_level);
figure,
for i = 1:gray_level
    patternSeq = transpose(repmat(mat(:, i), 1, 1024));
    gray_pattern(:,:,i) = patternSeq;
    subplot(gray_level+1,1,i); plot(gray_pattern(512,:,i));
    title(['G', num2str(i)]);
end
question from:https://stackoverflow.com/questions/65842543/how-to-create-a-gray-code-pattern-that-relates-to-frequency

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...