How do I replace my for loops using matrix manipulation?
古いコメントを表示
I want a more efficient way to do a window search between two images. I currently have two images; a small clip, and a larger image the clip should be a part of. I want to compare the small clip to every possible subset of the larger image to build a map of mutual information values. I can do this with a for loop as shown below.
dim_Large = size(Large);
dim_Clip = size(Clip);
for j = 1:dim_Large(1)-dim_Clip(1)
for k = 1:dim_Large(2)-dim_Clip(2)
map(j,k) = ...
ent(Large(j:j+dim_Clip(1)-1,k:k+dim_Clip(2)-1),Clip);
end
end
The 'ent' function is code to calculate the mutual information between two matrices of the same size. This does what I need it to do, but is very slow.
I'm sure there is a better way to write this for MatLab, something like
map = ent( Large(1:dim_Large(1)-dim_Clip(1)-1,1:dim_Large(2)-dim_Clip(2)-1), Clip);
but I can't get it to work.
Is there a more efficient way to write this code, preferably one that uses no for loops?
1 件のコメント
Rik
2017 年 11 月 29 日
This depends entirely on the contents of the ent function. Without it, it is impossible to answer this question.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!