Calculation of cross variogram
4 ビュー (過去 30 日間)
古いコメントを表示
I need to generate cross variograms of images using moving windows. To explain the process in a simple way, let me consider two matrices:
j = 1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
k = 17 18 19 20
21 22 23 24
25 26 27 28
29 30 31 32
For generation of cross variograms, the calculation goes on like this:
(1 - 2)(17 - 18) + (2 - 3)(18 - 19)+(3 - 4)(19-20)...
for such pairs of elements. I am not able to think about what kind of loop or built-in function can be used for such work.
I also had to generate variograms from images for this work. For generation of variograms I had to consider only one band of data. For that case I used nlfilter for moving window and created a function to select and calculate values.
0 件のコメント
採用された回答
the cyclist
2011 年 5 月 1 日
It wasn't 100% clear to me if each row was supposed to be treated independently, because you don't indicate how terms from any other rows are used. This does the same operation on each row, ultimately giving you a column vector of the same size as the first dimension of your matrices.
diff_j = -diff(j,1,2); % First parenthetical term of the pair
diff_k = -diff(k,1,2); % Second parenthetical term of the pair
prod_jk = diff_j.*diff_k; % All the parenthetical products
sum_prod_jk = sum(prod_jk,2) % Sum of the parenthetical products
This could all be combined into a one-liner, but I kept it split apart to make it easier to see what was going on.
2 件のコメント
the cyclist
2011 年 5 月 1 日
I don't have any experience with the Image Processing Toolbox, but from reading the documentation, it seems likely you will be able to use nlfilter().
If this answer solved your issue, please "accept" it, so that others looking for a similar solution know that it was helpful.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!