how to reduce time of for loop?
1 view (last 30 days)
Show older comments
hello, please i need a help i wrote a code that took an image and work on it to get certain metrics for her quality. the code is well running but the problem is with the time consumption it took 20sec can anyone help me please to reduce the time consumed by the for loop
the main purpose of the code is to calculate the max and the min of 3 consecutive values
img1=lum(img1); [M N]=size(img1);
e1=M-2; e2=N-2;
c=0;
for i=1:M-2 for j=1:N-2
a=img1(i:i+2,j:j+2);
a1=im2double(max(max(a)));
a(a==0)=a1;
b1=im2double(min(min(a)));
if a1>0 && b1>0 && a1~=b1
c1=(a1+b1)/(a1-b1);
c_log=log(single(c1));
c = c + (1/sqrt(c_log));
end
end
end
thank you
0 Comments
Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!