Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



A slow Matlab code for kapur comuting
Posted:
Mar 16, 2013 1:31 PM


Hello everyone
Could anyone please tell me how to make the following function code faster, I have to run it thousands of times in my code, which makes the execution of the whole program very time consuming.
Where: I is an input gray level Image, vect is a vector of gray levels
Thank you in advance
_______
function [fit] = fitSeg(im, vect)
s=size(im); k=length(vect);
vect=[0 vect 255];
for i=1:k+1 p=im(im>vect(i) & im<=vect(i+1)); s=size(p); if s(1)==0 entropies(i)=0; else entropies(i)=entropy(p); end end fit=sum(entropies);



