Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOGPicture speedup #61

Open
rosenfeldamir opened this issue Aug 2, 2012 · 1 comment
Open

HOGPicture speedup #61

rosenfeldamir opened this issue Aug 2, 2012 · 1 comment

Comments

@rosenfeldamir
Copy link

Hi,
I've re-implemented HOGPicture to be much faster, using a single matrix multiplication.
I think this should be in the main branch, and I don't know what would happen if I simply fork the project as is the default behavior;
So check it out - it's really useful (just copy & paste instead of the original code...)


function im = HOGpicture(w, bs)
%NOTE(TJM): I fixed a visualization bug which would sometimes show
%funky artifacts because pedro's version shows only the orientations
%facing one way. On synthetic images of squares this could be
%seen. The simple fix is to scan over 18 orientations not 9 when
%creating the histogram pics.

% Modified to vectorized version by Amir Rosenfeld, July 31st, 2012

if ~exist('bs','var')
bs = 20;
end
% HOGpicture(w, bs)
% Make picture of positive HOG weights.

% construct a "glyph" for each orientaion
s = size(w);
w(w<0) = 0;
bim1 = zeros(bs, bs);
bim1(:,round(bs/2):round(bs/2)+1) = 1;
bim = zeros([size(bim1) 9]);
bim(:,:,1) = bim1;
for i = 2:9,
bim(:,:,i) = imrotate(bim1, -(i-1)*20, 'crop');
end

bim = cat(3,bim,bim);
bim_ = reshape(bim,[],18);

B = im2col( zeros(bs_s(1), bs_s(2)),[bs bs],'distinct');
w_ = reshape(w(:,:,1:18),[],18);
im = col2im(bim__w_',[bs bs],[bs_s(1), bs*s(2)],'distinct');

end

@quantombone
Copy link
Owner

Sweet, Let me check this out, and I will push this into the main branch once I make sure it doesn't break anything! Will let you know once the change is made or if I have any questions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants