Help me with for loop

1 回表示 (過去 30 日間)
Mohammad Alwardat
Mohammad Alwardat 2020 年 5 月 6 日
コメント済み: Mohammad Alwardat 2020 年 5 月 6 日
Hi, I have a matrix A with size 32*32 and I need to study the similarity between all pixels.
The similairty between a pixel Xi and another pixel Xj in the neighbourhood of Xi is detemine by an exponantially decaying fuction of the squared difference in thier intensity values:
Sij = exp (-a (I(Xi) - I(Xj))^2);
% where a is a scale (a = 30) and I(x) is denotes the intensity of pixel x .
I need to study the similarity between pixel in location (1,1) with the ather pixels and recored the values of simialrity in matrix A1, so matrix A1 will has a size 32*32.
the value of A1(1,1) is the similarity between pixel A(1,1) with pixel A(1,1) ,
the value of A1(1,2) is the similarity bwtween pixel A(1,1) with pixel A(1,2) ,
and so on.
Thanks ♥

採用された回答

David Hill
David Hill 2020 年 5 月 6 日
a=.1;
B=exp(-a*(A-A(1,1)).^2);%comparing all pixels to A(1,1)
  4 件のコメント
David Hill
David Hill 2020 年 5 月 6 日
Not sure what you mean. In the above example, B is a 32x32 matrix that compares all pixels to A(1,1).
Mohammad Alwardat
Mohammad Alwardat 2020 年 5 月 6 日
We compared pixel A(1,1) with all pixels and recoreded the result in B matrix.
Now, I need to compare pixels A(1,2) with all pixels and recored the result in matrix B1
and compare pixels A(1,3) with all pixels and recored the result in matrix B2
.
.
and up to compare pixels A(32,32) with all pixels and recored the result in matrix B1023
so, I will get 32*32 = 1024 similarity matrix.
did you understand what I mean?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by