Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: A slow Matlab code for kapur comuting
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
draasoft

Posts: 12
Registered: 3/28/12
A slow Matlab code for kapur comuting
Posted: Mar 16, 2013 1:31 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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);



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.