What is the meaning of this formula ?

6 ビュー (過去 30 日間)
I Made
I Made 2013 年 3 月 4 日
Hii all, i'm stuck with this formula, i kinda confused and don't understand it. Need help :
W = {W(i)= Img(k,j),i=k*M2+j, 0<=k<=M1, 0<=j<=M2}
the pseudocode says that, it was for converting two dimensional image matrix Img whose size is M1*M2, to a vector W of length M1*M2. But i feel kinda strange, take one example i had an image of M1=2 and M2=2 and i follow above formula it'll return
i=0*2+0,0*2+1,0*2+2 then 1*2+0,1*2+1,1*2+2 then 2*2+0,2*2+1,2*2+2
am i right? or maybe there is another explaination why it return 3x3 vector when we enter 2x2 image. I really wanted to know why this formula like this. Any help would be appreciated, sorry for my strange noob curiosity :(

採用された回答

Walter Roberson
Walter Roberson 2013 年 3 月 4 日
編集済み: Walter Roberson 2013 年 3 月 4 日
Yes you are correct, it should either be 0 < k <= M1 or 0 <= k < M1. The version in which 0 is allowed but M1 is not, would correspond to C array notation where the first array element is Img(0,0); the version in which 0 is not allowed but M1 is, would correspond to MATLAB array notation where the first array element is Img(1,1).
The MATLAB equivalent of the code can be written as
W = Img(:);

その他の回答 (1 件)

Jan
Jan 2013 年 3 月 4 日
The indices of your formula start at 0. So if M1 and M2 are 2, you get the elements at the indices 0, 1, and 2, which are 3 elements.
Btw, a corresponding Matlab implementation would be:
ImgT = Img.';
W = ImgT(:);
Assumed, that the data are stored in row order.

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by