initLDAStuff.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. function ldaStuff = initLDAStuff( ny, nx, modeltemplate)
  2. % function ldaStuff = initLDAStuff( ny, nx, modeltemplate)
  3. %
  4. % BRIEF:
  5. % At the beginning, every detector is built only from a single
  6. % block (see the 1-SVM paper for motivation details)
  7. %
  8. % Lateron, further blocks are added to this struct increasing the
  9. % number of training samples of every detector
  10. %
  11. % INPUT:
  12. % ny -- ysize of our HoG features, assumed to be constant
  13. % nx -- xsize of our HoG features, assumed to be constant
  14. % modeltemplate -- template for best LDA model (size) determined by who code
  15. %
  16. % OUTPUT:
  17. % ldaStuff -- struct containing following fields:
  18. % ldaStuff.R -- covariance matrix of all data
  19. % ldaStuff.neg -- mean of universal negative data
  20. % ldaStuff.modelTemplate -- model template for LDA models
  21. %this needs to be done only ones since our parameters are always the same
  22. model = modeltemplate;
  23. if ( isfield(modeltemplate.lda,'b_noiseDropOut') && ~isempty(modeltemplate.lda.b_noiseDropOut) )
  24. model.lda.b_noiseDropOut = modeltemplate.lda.b_noiseDropOut;
  25. end
  26. if ( isfield(modeltemplate.lda,'d_dropOutProb') && ~isempty(modeltemplate.lda.d_dropOutProb) )
  27. model.lda.d_dropOutProb = modeltemplate.lda.d_dropOutProb;
  28. end
  29. if ( isfield(modeltemplate.lda,'lambda') && ~isempty(modeltemplate.lda.lambda) )
  30. model.lda.lambda = modeltemplate.lda.lambda;
  31. end
  32. [ldaStuff.R,ldaStuff.neg] = whitenWithDropout(model.bg, model.lda, nx,ny);
  33. ldaStuff.modelTemplate = modeltemplate;
  34. %per default, we work on all dimensions
  35. %however, DPM HOG features have as last feature dimension truncation
  36. %features constant to 0. In thoses cases, we set the flag to true and
  37. %ignore the last dimension in further processing stages
  38. ldaStuff.b_ignoreLastDim = false;
  39. end