How to reduce for loops
Afficher commentaires plus anciens
I would like to construct a matrix from two differnent(r,g,b) channels of a image.
by using
c_i (x,y,j)= -(‖(f_i ) ̂(Ω)‖ _2)/‖f ̂_j (Ω)‖_2
where i,j are r,g,b channels,
Ω = (m,n), neighborhood support.
code is :
%Image is I
%Ir, Ig, Ib are respective r,g,b channels of image
% code for Ir and Ig as
M=size(I,1);
N=size(I,2);
M1=ceil(sqrt(M));
N1=ceil(sqrt(N));
M2=M-M1;
N2=N-N1;
for i=1:M1
for j=1:N1
f1=norm(Ir(i:i+M2-1,j:j+N2-1));
for i1=1:M1
for j1=1:N1
f2=norm(Ig(i1:i1+M2-1,j1:j1+N2-1));
c((i*(M1))+j-(M1),((N1)*i1)+j1-(N1))=-(f1/f2);
end
end
end
end
Réponses (0)
Catégories
En savoir plus sur Neighborhood and Block Processing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!