We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c1243cd commit db44f0cCopy full SHA for db44f0c
util/im2patches.m
@@ -1,8 +1,11 @@
1
function patches = im2patches(im,m,n)
2
+ assert(rem(size(im,1),m)==0)
3
+ assert(rem(size(im,2),n)==0)
4
+
5
patches = [];
- for i=1:10:n
- for u=1:10:m
- patch = im(u:u+9,i:i+9);
6
+ for i=1:m:size(im,1)
7
+ for u=1:n:size(im,2)
8
+ patch = im(u:u+m-1,i:i+n-1);
9
patches = [patches patch(:)];
10
end
11
util/whiten.m
@@ -1,6 +1,7 @@
-function [X] = whiten(X,fudgefactor)
- X = bsxfun(@minus, X, mean(X));
- A = X'*X;
- [V,D] = eig(A);
- X = X*V*diag(1./(diag(D)+fudgefactor).^(1/2))*V';
+function X = whiten(X, fudgefactor)
+ C = cov(X);
+ M = mean(X);
+ [V,D] = eig(C);
+ P = V * diag(sqrt(1./(diag(D) + fudgefactor))) * V';
+ X = bsxfun(@minus, X, M) * P;
0 commit comments