How to create a binary grating pattern with Matlab?

Hello Everyone,
I want to design several binary grating patterns with matlab. The matrix size is 1920*1080, the period is 4 pixels. The patterns have there direction angle, one is zero, the second is 2*pi/3, the last is 4*pi/3. I tried used square function, but the result is not correct. Does anyone know how to do this?
Thank you very much. Xiaolei

 採用された回答

Joseph Cheng
Joseph Cheng 2014 年 6 月 25 日
編集済み: Joseph Cheng 2014 年 6 月 25 日

0 投票

Well... what you could do is do:
I = zeros(1920,1080);
cols = 0:1080-1;
I(:,find(mod(cols,4)<2))=1;
and then use imrotate to get your direction angle.

2 件のコメント

Xiaolei
Xiaolei 2014 年 6 月 25 日
Hello Joseph, Thank you very much, that's very helpful. But there is a problem when I use imrotate, the matrix will change. I just want the grating pattern direction change while keep the matrix still is 1920*1080. Another question is how can I change the phase of this pattern? Would you please give me some suggestions?
Joseph Cheng
Joseph Cheng 2014 年 6 月 26 日
My license for imageprocessing was taken up by someone else so i couldn't try. However reading the documentation it maybe a property that you can set within the imrotate function.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeAerospace Blockset についてさらに検索

質問済み:

2014 年 6 月 25 日

コメント済み:

2014 年 6 月 26 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by