Matlab nested for loop too Slow -


following nested loop in matlab slow, want reduce time used following process, improve situation shall highly appreciated.

r =0; c =0; ch=0;  myimage = imread('test1.tif'); [r, c, ch] = size(myimage);  l1 = 2.3;  l2 = 14.1;   q1 = 1;  q2 = 255;  k1 = 200;  k2 = 1000;  e = 1.1; rcpv = zeros(r, c); v = zeros(r, c); t = zeros(r, c); c = 1:c     r = 1:r         pv(r,c) = impixel(myimage,c,r);         pv(r,c) = mean(pv(:));         %pv(r,c) = pv;         v(r,c) = ((l2-l1)/(q2-q1))* (pv(r,c)-q1) + l1;         t(r,c)= (k2/log(((k1*e)/v(r,c))+1))-273;      end end  xlswrite('testdata.xlsx',t); 

why don't try parfor instead of for. better number of iterations 7000x8000.

it

parfor loopvar = initval:endval    statements; end 

you can have inner loop i.e. j running in parallel manner. try different ways :)


Comments