vector optimization
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
i have written this code and i wish to use vectorization to the inner if loop. because the program takes a long long time to execute even for a 128x128 image. can someone please provide me with the vector optimization logic for the following code?
for i=1:row
for j=i+1:row
if C(i,g)==C(j,g)
P2(C(i,g+1):C(i,g+1)+in-1, C(i,g+2):C(i,g+2)+in-1)=0;
P2(C(j,g+1):C(j,g+1)+in-1, C(j,g+2):C(j,g+2)+in-1)=0;
end
end
end
2 comentarios
Respuestas (1)
Jan
el 15 de Feb. de 2012
Not a vectorization, but at least no repeated calculations in the inner loop:
for i=1:row
C_ig = C(i, g);
a = false;
for j=i+1:row
if C_ig == C(j,g)
a = true;
P2(C(j,g+1):C(j,g+1)+in-1, C(j,g+2):C(j,g+2)+in-1) = 0;
end
end
if a
P2(C(i,g+1):C(i,g+1)+in-1, C(i,g+2):C(i,g+2)+in-1) = 0;
end
end
Ver también
Categorías
Más información sobre Computer Vision with Simulink en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!