2
$\begingroup$

Is this procedure for whitening and unwhitening correct?

Given an image $i$:

decompose the image in patches:

patch=im2col(i,[8 8],'sliding');

Whitening step:

1) subtract the mean from each patch (i.e., from each column):

meanP=mean(patch);
patch_m=patch-repmat(mean(patch),[size(patch,1) 1]);

2) divide by the standard deviation:

devP=sqrt(sum(patch.^2));
devpatch_m=sqrt(sum(patch_m.^2));
patch_m_s=patch_m./repmat(sqrt(sum(patch_m.^2)),[size(patch_m,1) 1]);

Unwhitening step:

1) multiply by the standard deviation:

rec_patch= rec_patch .* repmat(devpatch_m, [size(rec_patch,1) 1]);

2) add the mean:

rec_patch=rec_patch+repmat(meanP,[size(rec_patch,1) 1]);

I have also read that before starting the unwhitening step, it is possible to subtract the mean from the "new patches" obtained from the sparse coding step. Which is the correct procedure?

$\endgroup$
5
  • $\begingroup$ depends on the dimensions of patch.... $\endgroup$
    – user603
    Jan 21, 2013 at 20:11
  • $\begingroup$ @user603 Could you please elaborate a bit, as this alone is unlikely to help the asker? $\endgroup$ Jan 22, 2013 at 10:35
  • $\begingroup$ if patch is a vector then yes, this is how whitening is done. If patch is matrix then, no. $\endgroup$
    – user603
    Jan 22, 2013 at 11:58
  • $\begingroup$ @user603 patch is a matrix, whose columns are patches in a vector form. As you can see in the code I posted, mean and std dev are computed for each column. Your answer is definitely obscure. $\endgroup$ Jan 22, 2013 at 12:16
  • $\begingroup$ then, no, you are not whitening patch correctly. I will answer below. $\endgroup$
    – user603
    Jan 22, 2013 at 12:35

1 Answer 1

2
$\begingroup$

To whiten a $n$ by $d$ matrix $M$ it is not enough to center and scale: you also have to remove the correlation structure. So, denoting $M'$ your whitened matrix, we have:

$$M'=(M-t_M)'S_M^{-1/2}$$

where $t_M$ is the $d$ vector of columnwize means of $M$ and $S_M$ is $M$'s covariance matrix:

$$S_M=\frac{1}{n-1}(M-t_M)'(M-t_M)$$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.