How do I replace my for loops using matrix manipulation?
Mostra commenti meno recenti
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 Commento
Rik
il 29 Nov 2017
This depends entirely on the contents of the ent function. Without it, it is impossible to answer this question.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su MATLAB in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!