Username Remember Me?
Password   forgot password?
   
   
Performance improvement of im2feat
Posted: 10 October 2011 03:52 PM   [ Ignore ]  
Newbie
Rank
Total Posts:  12
Joined  2011-10-10

Hello!
I am working with a big dataset of feature images and i noticed that im2feat is pretty slow.
I profiled the code and discovered a non preallocated growing matrix. (line=80)

imm [];
for 
i=1:m
    imm 
[immreshape(im(:,:,:,i),imsize(1)*imsize(2),n)];
end
objsize 
[imsize(1:2m];

I rewrote the code this way:

rtc imsize(1)*imsize(2);
imm zeros(m*rtc,n);
for 
i=1:m
    imm
(rtc*(i-1)+1:rtc*(i),:) = reshape(im(:,:,:,i),rtc,n);
end
objsize 
[imsize(1:2m];

Now it runs much faster, hope you like the patch!

Thanks
Giuseppe

File Attachments
im2feat.zip  (File Size: 2KB - Downloads: 17)
Profile
 
 
Posted: 10 October 2011 11:16 PM   [ Ignore ]   [ # 1 ]  
Moderator
RankRankRankRank
Total Posts:  253
Joined  2008-11-08

Looks fine, thanks!

Bob

Profile
 
 
   
 
 
‹‹ Still problems with pcodes      NuSVC Score ››