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 time consuming function
Replies: 2   Last Post: Mar 29, 2012 8:21 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
draasoft

Posts: 12
Registered: 3/28/12
A time consuming function
Posted: Mar 28, 2012 12:48 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi everyone,

Could any one tell me how to make this function faster (it gets as inputs an image + 4 parameters)? I tried to vectorize it as shown below, but an error occurs given just after the second code).

Many thanks

% The original code

function [out]=enhance2(in,a,b,c,k)
[aa bb]=size(in);

dev=stdfilt(in);
M=mean2(in);
H = fspecial('average',[3 3]);
moy = double(imfilter(in, H));

for j=1:bb
for i=1:aa
out(i,j)=(k*M/(dev(i,j)+b))*(in(i,j)-c*moy(i,j))+moy(i,j)^a;
end
end
return

% Code 2:
function [out]=enhance2(in,a,b,c,k)

[aa bb]=size(in);
dev=stdfilt(in);
M=mean2(in);
H = fspecial('average',[3 3]);
moy = double(imfilter(in, H));

out=(k*M./(dev+b)).*(in-c.*moy)+moy.^a;

return

error: Integers can only be combined with integers of the
same class, or scalar doubles.



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.