├── README.md ├── ReadMe.m ├── face image shadow removal ├── ADMM │ ├── admmAXB.m │ ├── admm_pic.m │ ├── mirt_dctn.m │ └── mirt_idctn.m ├── demo.m └── yale05.mat ├── synthetic data ├── 100.mat ├── ADMM │ ├── admmAXB.m │ └── admm_pic.m └── demo.m └── video background subtraction ├── ReadMe.m ├── admmAXB.m ├── admm_v.m ├── bdsqr.m ├── bdsqr.mexw32 ├── compute_int.m ├── dataset ├── Video_003.avi └── escalator.avi ├── demo.m ├── gui ├── gui_close.m ├── gui_display_cputime.m ├── gui_display_speed.m ├── gui_show_results.m ├── gui_show_results_mat.m ├── gui_show_video.m ├── gui_show_video_file.m ├── main.fig ├── main.m ├── main_about.fig ├── main_about.m ├── main_edit_video.fig └── main_edit_video.m ├── hard_threshold.m ├── lanbpro.m ├── lansvd.m ├── libs ├── +lightspeed │ ├── @double │ │ └── gammaln.mexw64 │ ├── @mutable │ │ ├── display.m │ │ ├── fieldnames.m │ │ ├── getfield.m │ │ ├── immutable.m │ │ ├── isfield.m │ │ ├── mutable.m │ │ ├── rmfield.m │ │ ├── setfield.m │ │ ├── subsasgn.m │ │ └── subsref.m │ ├── Contents.m │ ├── README.txt │ ├── addflops.c │ ├── addflops.m │ ├── addflops.mexw64 │ ├── argfilter.m │ ├── argmax.m │ ├── argmax2.m │ ├── argmin.m │ ├── argmin2.m │ ├── cholproj.m │ ├── col_sum.m │ ├── cols.m │ ├── digamma.c │ ├── digamma.m │ ├── digamma.mexw64 │ ├── dtrsm.c │ ├── duplicated.m │ ├── find_sameobject.m │ ├── finddiag.m │ ├── flops.c │ ├── flops.h │ ├── flops.m │ ├── flops.obj │ ├── flops_abs.m │ ├── flops_chol.m │ ├── flops_col_sum.m │ ├── flops_det.m │ ├── flops_digamma.m │ ├── flops_div.m │ ├── flops_exp.m │ ├── flops_inv.m │ ├── flops_log.m │ ├── flops_lu.m │ ├── flops_mul.m │ ├── flops_normpdfln.m │ ├── flops_pow.m │ ├── flops_randnorm.m │ ├── flops_row_sum.m │ ├── flops_sample.m │ ├── flops_solve.m │ ├── flops_solve_tri.m │ ├── flops_spadd.m │ ├── flops_spmul.m │ ├── flops_sqrt.m │ ├── fromJava.m │ ├── gammaln.c │ ├── getaddress.c │ ├── glob.m │ ├── glob2regexp.m │ ├── globstrings.m │ ├── graphics │ │ ├── Contents.m │ │ ├── RYB_colors.m │ │ ├── YR_colors.m │ │ ├── YlGnBu_colors.m │ │ ├── axis_pct.m │ │ ├── category_colors.m │ │ ├── color_plot.m │ │ ├── cut_diverging.m │ │ ├── cut_quantile.m │ │ ├── draw_circle.m │ │ ├── draw_ellipse.m │ │ ├── draw_ellipse_axes.m │ │ ├── draw_line_clip.m │ │ ├── hhist.m │ │ ├── labeled_curves.m │ │ ├── linechart.m │ │ ├── min_errorbar_scale.m │ │ ├── mobile_points.m │ │ ├── mobile_text.m │ │ ├── move_obj.m │ │ ├── plot_errorbars.m │ │ ├── quantile.m │ │ ├── send_to_back.m │ │ ├── set_linespec.m │ │ ├── test_draw.m │ │ └── test_hhist.m │ ├── ind2subv.m │ ├── install_lightspeed.m │ ├── install_random.bat │ ├── int_hist.c │ ├── int_hist.m │ ├── int_hist.mexw64 │ ├── intersect_sorted.m │ ├── inv_posdef.m │ ├── inv_triu.m │ ├── invnormcdf.m │ ├── ismember_sorted.m │ ├── ismember_sorted_rows.m │ ├── isposdef.m │ ├── license.txt │ ├── logdet.m │ ├── logmulexp.m │ ├── logsumexp.m │ ├── makestruct.m │ ├── match.m │ ├── match_sorted.m │ ├── match_sorted_rows.m │ ├── matfile.c │ ├── maxdiff.m │ ├── mexcompiler.m │ ├── mexutil.c │ ├── mexutil.h │ ├── mexutil.obj │ ├── mvnormpdf.m │ ├── mvnormpdfln.m │ ├── mysqueeze.m │ ├── ndgridmat.m │ ├── ndlogsumexp.m │ ├── ndmax.m │ ├── ndsum.m │ ├── ndsumC.c │ ├── normcdf.m │ ├── normcdfln.m │ ├── normcdflogit.m │ ├── randbeta.m │ ├── randbinom.c │ ├── randbinom.m │ ├── randbinom.mexw64 │ ├── randgamma.c │ ├── randgamma.m │ ├── randgamma.mexw64 │ ├── randnorm.m │ ├── random.c │ ├── random.def │ ├── random.dll │ ├── random.exp │ ├── random.lib │ ├── random.obj │ ├── randomseed.c │ ├── randomseed.m │ ├── randomseed.mexw64 │ ├── randwishart.m │ ├── repmat.c │ ├── repmat.log │ ├── repmat.mexw64 │ ├── row_sum.m │ ├── rows.m │ ├── sameobject.c │ ├── sameobject.m │ ├── sameobject.mexw64 │ ├── sample.m │ ├── sample_hist.c │ ├── sample_hist.m │ ├── sample_hist.mexw64 │ ├── sample_vector.m │ ├── scale_cols.m │ ├── scale_rows.m │ ├── setdiag.m │ ├── setdiff_sorted.m │ ├── setfields.m │ ├── setnonzeros.c │ ├── setnonzeros.mexw64 │ ├── shortsize.m │ ├── sizeJava.m │ ├── solve_tril.c │ ├── solve_tril.m │ ├── solve_tril.mexw64 │ ├── solve_triu.c │ ├── solve_triu.m │ ├── solve_triu.mexw64 │ ├── sqdist.m │ ├── struct2arglist.m │ ├── subv2ind.m │ ├── table1.c │ ├── tests │ │ ├── test_digamma.m │ │ ├── test_duplicated.m │ │ ├── test_flops.c │ │ ├── test_flops.m │ │ ├── test_flops2.m │ │ ├── test_gammaln.m │ │ ├── test_int_hist.m │ │ ├── test_inv_posdef.m │ │ ├── test_java.m │ │ ├── test_lightspeed.m │ │ ├── test_logmulexp.m │ │ ├── test_logsumexp.m │ │ ├── test_matfile.mat │ │ ├── test_max.m │ │ ├── test_mutable.m │ │ ├── test_ndsum.m │ │ ├── test_normcdf.m │ │ ├── test_normpdf.m │ │ ├── test_randbeta.m │ │ ├── test_randbinom.m │ │ ├── test_randgamma.m │ │ ├── test_randomseed.m │ │ ├── test_randwishart.m │ │ ├── test_repmat.m │ │ ├── test_repmat_struct.m │ │ ├── test_row_sum.m │ │ ├── test_sameobject.m │ │ ├── test_sample.m │ │ ├── test_scale.m │ │ ├── test_solve_tri.m │ │ ├── test_sorted.m │ │ ├── test_sparse.m │ │ ├── test_sqdist.m │ │ └── test_trigamma.m │ ├── tetragamma.c │ ├── tetragamma.mexw64 │ ├── timing.cpp │ ├── toJava.m │ ├── trigamma.c │ ├── trigamma.m │ ├── trigamma.mexw64 │ ├── union_sorted.m │ ├── union_sorted_rows.m │ ├── util.c │ ├── util.h │ ├── util.obj │ ├── vec.m │ ├── wishpdf.m │ ├── wishpdfln.m │ ├── xones.c │ └── xrepmat.m ├── +tensorlab │ ├── Contents.m │ ├── btd_minf.m │ ├── btd_nls.m │ ├── btd_rnd.m │ ├── btdgen.m │ ├── btdres.m │ ├── cpd.m │ ├── cpd3_sd.m │ ├── cpd3_sgsd.m │ ├── cpd_aels.m │ ├── cpd_als.m │ ├── cpd_els.m │ ├── cpd_eps.m │ ├── cpd_gevd.m │ ├── cpd_lsb.m │ ├── cpd_minf.m │ ├── cpd_nls.m │ ├── cpd_rnd.m │ ├── cpderr.m │ ├── cpdgen.m │ ├── cpdres.m │ ├── cum4.m │ ├── deriv.m │ ├── dotk.m │ ├── fmt.m │ ├── frob.m │ ├── ful.m │ ├── full.m │ ├── gap.m │ ├── kmeans.m │ ├── kr.m │ ├── kron.m │ ├── license.txt │ ├── lmlra.m │ ├── lmlra3_dgn.m │ ├── lmlra3_rtr.m │ ├── lmlra_aca.m │ ├── lmlra_hooi.m │ ├── lmlra_minf.m │ ├── lmlra_nls.m │ ├── lmlra_rnd.m │ ├── lmlraerr.m │ ├── lmlragen.m │ ├── lmlrares.m │ ├── ls_mt.m │ ├── mat2tens.m │ ├── minf_lbfgs.m │ ├── minf_lbfgsdl.m │ ├── minf_ncg.m │ ├── mlrank.m │ ├── mlrankest.m │ ├── mlsvd.m │ ├── mpcg.m │ ├── mtkronprod.m │ ├── mtkrprod.m │ ├── nls_gncgs.m │ ├── nls_gndl.m │ ├── nls_lm.m │ ├── nlsb_gndl.m │ ├── noisy.m │ ├── polymin.m │ ├── polymin2.m │ ├── polysol2.m │ ├── polyval2.m │ ├── rankest.m │ ├── ratmin.m │ ├── ratmin2.m │ ├── scov.m │ ├── sdf_minf.m │ ├── sdf_nls.m │ ├── slice3.m │ ├── spy3.m │ ├── struct_LL1.m │ ├── struct_abs.m │ ├── struct_band.m │ ├── struct_cell2mat.m │ ├── struct_conj.m │ ├── struct_ctranspose.m │ ├── struct_diag.m │ ├── struct_gram.m │ ├── struct_hankel.m │ ├── struct_inv.m │ ├── struct_invsqrtm.m │ ├── struct_invtransp.m │ ├── struct_log.m │ ├── struct_matvec.m │ ├── struct_nonneg.m │ ├── struct_normalize.m │ ├── struct_orth.m │ ├── struct_plus.m │ ├── struct_poly.m │ ├── struct_power.m │ ├── struct_rational.m │ ├── struct_rbf.m │ ├── struct_sigmoid.m │ ├── struct_sqrt.m │ ├── struct_sum.m │ ├── struct_times.m │ ├── struct_toeplitz.m │ ├── struct_transpose.m │ ├── struct_tridiag.m │ ├── struct_tril.m │ ├── struct_triu.m │ ├── struct_vander.m │ ├── sumk.m │ ├── surf3.m │ ├── tens2mat.m │ ├── tens2vec.m │ ├── tmprod.m │ ├── vec2tens.m │ └── voxel3.m ├── .gitignore ├── SVD │ ├── +mexsvd │ │ ├── mexsvd.c │ │ ├── mexsvd.mexa64 │ │ ├── mexsvd.mexglx │ │ ├── mexsvd.mexw32 │ │ ├── mexsvd.mexw64 │ │ ├── mexsvdold.c │ │ └── mexsvdwin.c │ ├── +mexsvdold │ │ └── mexsvd.mexw32 │ ├── +mexsvdwin │ │ ├── mexsvd.c │ │ ├── mexsvd.mexw32 │ │ └── mexsvd.mexw64 │ ├── BL_EVD.m │ ├── BL_SVD.m │ ├── LMSVD.m │ ├── LMSVDS.m │ ├── lansvd_d1.m │ ├── pcaecon.m │ ├── pcasecon.m │ ├── svdecon.m │ ├── svdsecon.m │ └── testsvd.m ├── manopt │ ├── CLA.txt │ ├── COPYING.txt │ ├── CREDITS.txt │ ├── LICENSE.txt │ ├── README.txt │ ├── checkinstall │ │ └── basicexample.m │ ├── examples │ │ ├── dominant_invariant_subspace.m │ │ ├── generalized_procrustes.m │ │ ├── low_rank_matrix_completion.m │ │ ├── maxcut.m │ │ ├── maxcut_octave.m │ │ ├── packing_on_the_sphere.m │ │ ├── positive_definite_karcher_mean.m │ │ ├── sparse_pca.m │ │ └── truncated_svd.m │ ├── importmanopt.m │ ├── manopt │ │ ├── manifolds │ │ │ ├── complexcircle │ │ │ │ └── complexcirclefactory.m │ │ │ ├── euclidean │ │ │ │ ├── euclideanfactory.m │ │ │ │ └── symmetricfactory.m │ │ │ ├── fixedrank │ │ │ │ ├── fixedrankMNquotientfactory.m │ │ │ │ ├── fixedrankembeddedfactory.m │ │ │ │ ├── fixedrankfactory_2factors.m │ │ │ │ ├── fixedrankfactory_2factors_preconditioned.m │ │ │ │ ├── fixedrankfactory_2factors_subspace_projection.m │ │ │ │ ├── fixedrankfactory_3factors.m │ │ │ │ └── fixedrankfactory_3factors_preconditioned.m │ │ │ ├── grassmann │ │ │ │ └── grassmannfactory.m │ │ │ ├── oblique │ │ │ │ └── obliquefactory.m │ │ │ ├── rotations │ │ │ │ ├── randrot.m │ │ │ │ ├── randskew.m │ │ │ │ └── rotationsfactory.m │ │ │ ├── sphere │ │ │ │ ├── spherecomplexfactory.m │ │ │ │ └── spherefactory.m │ │ │ ├── stiefel │ │ │ │ └── stiefelfactory.m │ │ │ └── symfixedrank │ │ │ │ ├── elliptopefactory.m │ │ │ │ ├── spectrahedronfactory.m │ │ │ │ ├── symfixedrankYYfactory.m │ │ │ │ └── sympositivedefinitefactory.m │ │ ├── privatetools │ │ │ ├── applyStatsfun.m │ │ │ ├── canGetCost.m │ │ │ ├── canGetDirectionalDerivative.m │ │ │ ├── canGetEuclideanGradient.m │ │ │ ├── canGetGradient.m │ │ │ ├── canGetHessian.m │ │ │ ├── canGetLinesearch.m │ │ │ ├── canGetPrecon.m │ │ │ ├── getApproxHessian.m │ │ │ ├── getCost.m │ │ │ ├── getCostGrad.m │ │ │ ├── getDirectionalDerivative.m │ │ │ ├── getEuclideanGradient.m │ │ │ ├── getGlobalDefaults.m │ │ │ ├── getGradient.m │ │ │ ├── getHessian.m │ │ │ ├── getHessianFD.m │ │ │ ├── getLinesearch.m │ │ │ ├── getPrecon.m │ │ │ ├── getStore.m │ │ │ ├── hashmd5.m │ │ │ ├── mergeOptions.m │ │ │ ├── purgeStoredb.m │ │ │ ├── setStore.m │ │ │ └── stoppingcriterion.m │ │ ├── solvers │ │ │ ├── conjugategradient │ │ │ │ └── conjugategradient.m │ │ │ ├── linesearch │ │ │ │ ├── linesearch.m │ │ │ │ ├── linesearch_adaptive.m │ │ │ │ └── linesearch_hint.m │ │ │ ├── neldermead │ │ │ │ ├── centroid.m │ │ │ │ └── neldermead.m │ │ │ ├── pso │ │ │ │ └── pso.m │ │ │ ├── steepestdescent │ │ │ │ └── steepestdescent.m │ │ │ └── trustregions │ │ │ │ ├── license for original GenRTR code.txt │ │ │ │ ├── tCG.m │ │ │ │ └── trustregions.m │ │ └── tools │ │ │ ├── checkdiff.m │ │ │ ├── checkgradient.m │ │ │ ├── checkhessian.m │ │ │ ├── diagsum.m │ │ │ ├── hessianspectrum.m │ │ │ ├── identify_linear_piece.m │ │ │ ├── multiprod.m │ │ │ ├── multiprodmultitransp_license.txt │ │ │ ├── multiscale.m │ │ │ ├── multiskew.m │ │ │ ├── multisym.m │ │ │ ├── multitrace.m │ │ │ ├── multitransp.m │ │ │ ├── plotprofile.m │ │ │ ├── powermanifold.m │ │ │ └── productmanifold.m │ └── manopt_version.m ├── mmread │ ├── FFGrab.cpp │ ├── FFGrab.mexa64 │ ├── FFGrab.mexglx │ ├── FFGrab.mexmac │ ├── FFGrab.mexmaci │ ├── FFGrab.mexmaci64 │ ├── FFGrab.mexw32 │ ├── FFGrab.mexw64 │ ├── avbin.dll │ ├── avbin64.dll │ ├── libavbin.dylib │ ├── libavbin.so │ ├── libavbin.so.32 │ ├── libavbin.so.64 │ ├── license.txt │ ├── mexDDGrab.cpp │ ├── mexDDGrab.dll │ ├── mexDDGrab.mexw32 │ ├── mexDDGrab.mexw64 │ ├── mmread.m │ └── processFrame.m ├── mtt │ ├── circmat.m │ ├── show_3dtensors.m │ ├── tensor_fibers_column.m │ ├── tensor_fibers_row.m │ ├── tensor_fibers_tube.m │ ├── tensor_fold.m │ ├── tensor_hosvd.m │ ├── tensor_ihosvd.m │ ├── tensor_matricization.m │ ├── tensor_nmodeproduct.m │ ├── tensor_product.m │ ├── tensor_slices_frontal.m │ ├── tensor_slices_horizontal.m │ ├── tensor_slices_lateral.m │ ├── tensor_t_svd.m │ ├── tensor_transpose.m │ ├── tensor_tucker_prod.m │ ├── tensor_unfold.m │ └── tensor_unfolding.m └── vlfeat │ ├── .gitattributes │ ├── .gitignore │ ├── COPYING │ ├── Makefile │ ├── Makefile.mak │ ├── README.md │ ├── apps │ ├── phow_caltech101.m │ ├── recognition │ │ ├── encodeImage.m │ │ ├── experiments.m │ │ ├── extendDescriptorsWithGeometry.m │ │ ├── getDenseSIFT.m │ │ ├── readImage.m │ │ ├── setupCaltech256.m │ │ ├── setupFMD.m │ │ ├── setupGeneric.m │ │ ├── setupScene67.m │ │ ├── setupVoc.m │ │ ├── trainEncoder.m │ │ └── traintest.m │ └── sift_mosaic.m │ ├── data │ ├── box.pgm │ ├── box.sift │ ├── river1.jpg │ ├── river2.jpg │ ├── roofs1.jpg │ ├── roofs2.jpg │ └── spots.jpg │ ├── docsrc │ ├── about.html │ ├── api.html │ ├── apps.html │ ├── compiling.html │ ├── doc.html │ ├── download.html │ ├── doxygen.conf │ ├── doxygen.css │ ├── doxytag.py │ ├── dtd │ │ └── xhtml1 │ │ │ ├── xhtml-lat1.ent │ │ │ ├── xhtml-special.ent │ │ │ ├── xhtml-symbol.ent │ │ │ ├── xhtml.soc │ │ │ ├── xhtml1-frameset.dtd │ │ │ ├── xhtml1-strict.dtd │ │ │ ├── xhtml1-transitional.dtd │ │ │ └── xhtml1.dcl │ ├── figures │ │ ├── cell-bins.fig │ │ ├── covdet-normalization.svg │ │ ├── covdet.svg │ │ ├── dhog-bins.fig │ │ ├── dsift-geom.svg │ │ ├── frame-canonical.svg │ │ ├── frame-types.svg │ │ ├── frames.svg │ │ ├── lbp.svg │ │ ├── liop.svg │ │ ├── mser-er-step.svg │ │ ├── mser-er.svg │ │ ├── mser-tree.svg │ │ ├── scalespace-basic.svg │ │ ├── scalespace.svg │ │ ├── sift-angle.fig │ │ ├── sift-bins.fig │ │ ├── sift-can.fig │ │ ├── sift-conv-vlfeat.fig │ │ ├── sift-conv.fig │ │ ├── sift-descr-easy.fig │ │ ├── sift-frame.fig │ │ ├── sift-image-frame.fig │ │ ├── sift-orient.fig │ │ └── sift-ss.svg │ ├── formatter.py │ ├── images │ │ ├── PASCAL2.png │ │ ├── caltech-collage.jpg │ │ ├── down.png │ │ ├── fulkerson.jpg │ │ ├── git.png │ │ ├── help.png │ │ ├── lenc.jpg │ │ ├── liop-neighbours-sampling.png │ │ ├── liop-patch-layout.png │ │ ├── perdoch.jpg │ │ ├── perrone.jpg │ │ ├── placeholder.jpg │ │ ├── sarbortova.jpg │ │ ├── sift-mosaic.jpg │ │ ├── sulc.jpg │ │ ├── using-vs-additional-deps.png │ │ ├── using-vs-additional-include.png │ │ ├── using-vs-additional-libdir.png │ │ ├── using-vs-all-configurations.png │ │ ├── using-vs-empty-project.png │ │ ├── using-vs-new-project.png │ │ ├── using-vs-nodll.png │ │ ├── using-vs-ok.png │ │ ├── using-vs-post-step.png │ │ ├── using-vs-project-properties.png │ │ ├── using-xcode-copy-2.png │ │ ├── using-xcode-copy.png │ │ ├── using-xcode-dylib.png │ │ ├── using-xcode-edit.png │ │ ├── using-xcode-err.png │ │ ├── using-xcode-info.png │ │ ├── using-xcode-new.png │ │ ├── using-xcode-ok.png │ │ ├── vedaldi.jpg │ │ ├── vl_blue.ico │ │ ├── vl_blue.png │ │ ├── vl_blue.pxm │ │ ├── vl_blue_large.pxm │ │ └── yandex.png │ ├── index.html │ ├── install-c.html │ ├── install-matlab.html │ ├── install-octave.html │ ├── install-shell.html │ ├── license.html │ ├── mdoc.py │ ├── notfound.html │ ├── pygmentize.css │ ├── roadmap.html │ ├── tutorials.html │ ├── tutorials │ │ ├── aib.html │ │ ├── covdet.html │ │ ├── dsift.html │ │ ├── encode.html │ │ ├── frame.html │ │ ├── gmm.html │ │ ├── hikm.html │ │ ├── hog.html │ │ ├── ikm.html │ │ ├── imdisttf.html │ │ ├── kdtree.html │ │ ├── kmeans.html │ │ ├── liop.html │ │ ├── mser.html │ │ ├── plots-rank.html │ │ ├── quickshift.html │ │ ├── sift.html │ │ ├── slic.html │ │ ├── svm.html │ │ └── utils.html │ ├── using-gcc.html │ ├── using-vsexpress.html │ ├── using-xcode.html │ ├── vlfeat-website-main-content.xml │ ├── vlfeat-website-preproc.xml │ ├── vlfeat-website-template.xml │ ├── vlfeat-website.xml │ ├── vlfeat.bib │ ├── vlfeat.css │ ├── webdoc.py │ └── wikidoc.py │ ├── make │ ├── bin.mak │ ├── dist.mak │ ├── dll.mak │ ├── doc.mak │ ├── matlab.mak │ ├── nmake_helper.mak │ ├── octave.mak │ └── update-mak.sh │ ├── src │ ├── aib.c │ ├── check.h │ ├── generic-driver.h │ ├── mser.1 │ ├── mser.c │ ├── sift.1 │ ├── sift.c │ ├── test_gauss_elimination.c │ ├── test_getopt_long.c │ ├── test_gmm.c │ ├── test_heap-def.c │ ├── test_host.c │ ├── test_imopv.c │ ├── test_kmeans.c │ ├── test_liop.c │ ├── test_mathop.c │ ├── test_mathop_abs.c │ ├── test_mathop_fast_resqrt.tc │ ├── test_mathop_fast_sqrt_ui.tc │ ├── test_nan.c │ ├── test_qsort-def.c │ ├── test_rand.c │ ├── test_sqrti.c │ ├── test_stringop.c │ ├── test_svd2.c │ ├── test_threads.c │ ├── test_vec_comp.c │ └── vlfeat.7 │ ├── startup.m │ ├── toolbox │ ├── aib │ │ ├── vl_aib.c │ │ ├── vl_aib.m │ │ ├── vl_aibcut.m │ │ ├── vl_aibcuthist.m │ │ ├── vl_aibcutpush.m │ │ ├── vl_aibhist.c │ │ └── vl_aibhist.m │ ├── demo │ │ ├── vl_demo_aib.m │ │ ├── vl_demo_alldist.m │ │ ├── vl_demo_cmd.m │ │ ├── vl_demo_covdet.m │ │ ├── vl_demo_dsift.m │ │ ├── vl_demo_frame.m │ │ ├── vl_demo_gmm_2d_rand.m │ │ ├── vl_demo_gmm_2d_twist.m │ │ ├── vl_demo_gmm_3d.m │ │ ├── vl_demo_gmm_convergence.m │ │ ├── vl_demo_hog.m │ │ ├── vl_demo_ikmeans.m │ │ ├── vl_demo_imdisttf.m │ │ ├── vl_demo_kdtree.m │ │ ├── vl_demo_kdtree_ann.m │ │ ├── vl_demo_kdtree_forest.m │ │ ├── vl_demo_kdtree_plot.m │ │ ├── vl_demo_kdtree_self.m │ │ ├── vl_demo_kdtree_sift.m │ │ ├── vl_demo_kmeans_2d.m │ │ ├── vl_demo_kmeans_ann_speed.m │ │ ├── vl_demo_kmeans_init.m │ │ ├── vl_demo_kmeans_vs_builtin.m │ │ ├── vl_demo_mser_basic.m │ │ ├── vl_demo_mser_cmd.m │ │ ├── vl_demo_mser_delta.m │ │ ├── vl_demo_plots_rank.m │ │ ├── vl_demo_print.m │ │ ├── vl_demo_quickshift.m │ │ ├── vl_demo_sift_basic.m │ │ ├── vl_demo_sift_cmd.m │ │ ├── vl_demo_sift_edge.m │ │ ├── vl_demo_sift_match.m │ │ ├── vl_demo_sift_or.m │ │ ├── vl_demo_sift_peak.m │ │ ├── vl_demo_sift_vs_ubc.m │ │ ├── vl_demo_slic.m │ │ ├── vl_demo_svm.m │ │ └── vl_demo_svm_data.mat │ ├── fisher │ │ ├── vl_fisher.c │ │ └── vl_fisher.m │ ├── geometry │ │ ├── vl_hat.m │ │ ├── vl_ihat.m │ │ ├── vl_irodr.c │ │ ├── vl_irodr.m │ │ ├── vl_rodr.c │ │ └── vl_rodr.m │ ├── gmm │ │ ├── vl_gmm.c │ │ └── vl_gmm.m │ ├── imop │ │ ├── vl_dwaffine.m │ │ ├── vl_imarray.m │ │ ├── vl_imarraysc.m │ │ ├── vl_imdisttf.c │ │ ├── vl_imdisttf.m │ │ ├── vl_imdown.m │ │ ├── vl_imgrad.m │ │ ├── vl_imintegral.c │ │ ├── vl_imintegral.m │ │ ├── vl_impattern.m │ │ ├── vl_imreadbw.m │ │ ├── vl_imreadgray.m │ │ ├── vl_imsc.m │ │ ├── vl_imsmooth.c │ │ ├── vl_imsmooth.m │ │ ├── vl_imup.m │ │ ├── vl_imwbackward.m │ │ ├── vl_imwbackwardmx.c │ │ ├── vl_imwhiten.m │ │ ├── vl_rgb2xyz.m │ │ ├── vl_tps.m │ │ ├── vl_tpsu.m │ │ ├── vl_tpsumx.c │ │ ├── vl_waffine.m │ │ ├── vl_witps.m │ │ ├── vl_wtps.m │ │ ├── vl_xyz2lab.m │ │ ├── vl_xyz2luv.m │ │ └── vl_xyz2rgb.m │ ├── info.xml │ ├── kmeans │ │ ├── vl_hikmeans.c │ │ ├── vl_hikmeans.m │ │ ├── vl_hikmeanshist.m │ │ ├── vl_hikmeanspush.c │ │ ├── vl_hikmeanspush.m │ │ ├── vl_ikmeans.c │ │ ├── vl_ikmeans.m │ │ ├── vl_ikmeanshist.m │ │ ├── vl_ikmeanspush.c │ │ ├── vl_ikmeanspush.m │ │ ├── vl_kmeans.c │ │ └── vl_kmeans.m │ ├── mexutils.h │ ├── misc │ │ ├── inthist.tc │ │ ├── kdtree.h │ │ ├── samplinthist.tc │ │ ├── svms_common.h │ │ ├── vl_alldist.c │ │ ├── vl_alldist2.c │ │ ├── vl_alldist2.m │ │ ├── vl_alphanum.m │ │ ├── vl_argparse.m │ │ ├── vl_binsearch.c │ │ ├── vl_binsearch.m │ │ ├── vl_binsum.c │ │ ├── vl_binsum.def │ │ ├── vl_binsum.m │ │ ├── vl_colsubset.m │ │ ├── vl_cummax.c │ │ ├── vl_cummax.def │ │ ├── vl_cummax.m │ │ ├── vl_getpid.c │ │ ├── vl_getpid.m │ │ ├── vl_grad.m │ │ ├── vl_histmarg.m │ │ ├── vl_hog.c │ │ ├── vl_hog.m │ │ ├── vl_homkermap.c │ │ ├── vl_homkermap.m │ │ ├── vl_ihashfind.c │ │ ├── vl_ihashfind.m │ │ ├── vl_ihashsum.c │ │ ├── vl_ihashsum.m │ │ ├── vl_inthist.c │ │ ├── vl_inthist.m │ │ ├── vl_isoctave.m │ │ ├── vl_kdtreebuild.c │ │ ├── vl_kdtreebuild.m │ │ ├── vl_kdtreequery.c │ │ ├── vl_kdtreequery.m │ │ ├── vl_lbp.c │ │ ├── vl_lbp.m │ │ ├── vl_lbpfliplr.m │ │ ├── vl_localmax.c │ │ ├── vl_localmax.m │ │ ├── vl_matlabversion.m │ │ ├── vl_numder.m │ │ ├── vl_numder2.m │ │ ├── vl_override.m │ │ ├── vl_pegasos.m │ │ ├── vl_sampleinthist.c │ │ ├── vl_sampleinthist.m │ │ ├── vl_simdctrl.c │ │ ├── vl_simdctrl.m │ │ ├── vl_svmdataset.m │ │ ├── vl_svmpegasos.m │ │ ├── vl_svmtrain.c │ │ ├── vl_svmtrain.m │ │ ├── vl_threads.c │ │ ├── vl_threads.m │ │ ├── vl_twister.c │ │ ├── vl_twister.m │ │ ├── vl_version.c │ │ ├── vl_version.m │ │ ├── vl_whistc.m │ │ └── vl_xmkdir.m │ ├── mser │ │ ├── vl_erfill.c │ │ ├── vl_erfill.m │ │ ├── vl_ertr.m │ │ ├── vl_mser.c │ │ └── vl_mser.m │ ├── plotop │ │ ├── vl_cf.m │ │ ├── vl_click.m │ │ ├── vl_clickpoint.m │ │ ├── vl_clicksegment.m │ │ ├── vl_det.m │ │ ├── vl_figaspect.m │ │ ├── vl_linespec2prop.m │ │ ├── vl_plotbox.m │ │ ├── vl_plotframe.m │ │ ├── vl_plotgrid.m │ │ ├── vl_plotpoint.m │ │ ├── vl_plotstyle.m │ │ ├── vl_pr.m │ │ ├── vl_printsize.m │ │ ├── vl_roc.m │ │ ├── vl_tightsubplot.m │ │ └── vl_tpfp.m │ ├── quickshift │ │ ├── vl_flatmap.m │ │ ├── vl_imseg.m │ │ ├── vl_quickseg.m │ │ ├── vl_quickshift.c │ │ ├── vl_quickshift.m │ │ └── vl_quickvis.m │ ├── sift │ │ ├── vl_covdet.c │ │ ├── vl_covdet.m │ │ ├── vl_dsift.c │ │ ├── vl_dsift.m │ │ ├── vl_frame2oell.m │ │ ├── vl_liop.c │ │ ├── vl_liop.m │ │ ├── vl_phow.m │ │ ├── vl_plotsiftdescriptor.m │ │ ├── vl_plotss.m │ │ ├── vl_sift.c │ │ ├── vl_sift.m │ │ ├── vl_siftdescriptor.c │ │ ├── vl_siftdescriptor.m │ │ ├── vl_ubcmatch.c │ │ ├── vl_ubcmatch.m │ │ └── vl_ubcread.m │ ├── slic │ │ ├── vl_slic.c │ │ └── vl_slic.m │ ├── special │ │ ├── vl_ddgaussian.m │ │ ├── vl_dgaussian.m │ │ ├── vl_dsigmoid.m │ │ ├── vl_gaussian.m │ │ ├── vl_rcos.m │ │ └── vl_sigmoid.m │ ├── vl_compile.m │ ├── vl_demo.m │ ├── vl_harris.m │ ├── vl_help.m │ ├── vl_noprefix.m │ ├── vl_root.m │ ├── vl_setup.m │ ├── vlad │ │ ├── vl_vlad.c │ │ └── vl_vlad.m │ └── xtest │ │ ├── vl_assert_almost_equal.m │ │ ├── vl_assert_equal.m │ │ ├── vl_assert_exception.m │ │ ├── vl_test.m │ │ ├── vl_test_aib.m │ │ ├── vl_test_alldist.m │ │ ├── vl_test_alldist2.m │ │ ├── vl_test_alphanum.m │ │ ├── vl_test_argparse.m │ │ ├── vl_test_binsearch.m │ │ ├── vl_test_binsum.m │ │ ├── vl_test_colsubset.m │ │ ├── vl_test_cummax.m │ │ ├── vl_test_dsift.m │ │ ├── vl_test_fisher.m │ │ ├── vl_test_gmm.m │ │ ├── vl_test_grad.m │ │ ├── vl_test_hikmeans.m │ │ ├── vl_test_hog.m │ │ ├── vl_test_homkermap.m │ │ ├── vl_test_ihashsum.m │ │ ├── vl_test_ikmeans.m │ │ ├── vl_test_imarray.m │ │ ├── vl_test_imdisttf.m │ │ ├── vl_test_imintegral.m │ │ ├── vl_test_imsmooth.m │ │ ├── vl_test_imwbackward.m │ │ ├── vl_test_init.m │ │ ├── vl_test_inthist.m │ │ ├── vl_test_kdtree.m │ │ ├── vl_test_kmeans.m │ │ ├── vl_test_lbp.m │ │ ├── vl_test_liop.m │ │ ├── vl_test_mser.m │ │ ├── vl_test_phow.m │ │ ├── vl_test_plotbox.m │ │ ├── vl_test_pr.m │ │ ├── vl_test_printsize.m │ │ ├── vl_test_roc.m │ │ ├── vl_test_sift.m │ │ ├── vl_test_slic.m │ │ ├── vl_test_svmtrain.m │ │ ├── vl_test_twister.m │ │ ├── vl_test_vlad.m │ │ └── vl_test_whistc.m │ ├── vl │ ├── aib.c │ ├── aib.h │ ├── array.c │ ├── array.h │ ├── covdet.c │ ├── covdet.h │ ├── dsift.c │ ├── dsift.h │ ├── fisher.c │ ├── fisher.h │ ├── float.th │ ├── generic.c │ ├── generic.h │ ├── getopt_long.c │ ├── getopt_long.h │ ├── gmm.c │ ├── gmm.h │ ├── heap-def.h │ ├── hikmeans.c │ ├── hikmeans.h │ ├── hog.c │ ├── hog.h │ ├── homkermap.c │ ├── homkermap.h │ ├── host.c │ ├── host.h │ ├── ikmeans.c │ ├── ikmeans.h │ ├── ikmeans_elkan.tc │ ├── ikmeans_init.tc │ ├── ikmeans_lloyd.tc │ ├── imopv.c │ ├── imopv.h │ ├── imopv_sse2.c │ ├── imopv_sse2.h │ ├── kdtree.c │ ├── kdtree.h │ ├── kmeans.c │ ├── kmeans.h │ ├── lbp.c │ ├── lbp.h │ ├── liop.c │ ├── liop.h │ ├── mathop.c │ ├── mathop.h │ ├── mathop_avx.c │ ├── mathop_avx.h │ ├── mathop_sse2.c │ ├── mathop_sse2.h │ ├── mser.c │ ├── mser.h │ ├── pgm.c │ ├── pgm.h │ ├── qsort-def.h │ ├── quickshift.c │ ├── quickshift.h │ ├── random.c │ ├── random.h │ ├── rodrigues.c │ ├── rodrigues.h │ ├── scalespace.c │ ├── scalespace.h │ ├── shuffle-def.h │ ├── sift.c │ ├── sift.h │ ├── slic.c │ ├── slic.h │ ├── stringop.c │ ├── stringop.h │ ├── svm.c │ ├── svm.h │ ├── svmdataset.c │ ├── svmdataset.h │ ├── vlad.c │ └── vlad.h │ ├── vlfeat.sln │ ├── vlfeat.vcproj │ └── vlfeat.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ └── xcschemes │ ├── make doc-api.xcscheme │ ├── make info.xcscheme │ └── make.xcscheme ├── lrs_conf.mat ├── lrs_gui.m ├── lrs_load_conf.m ├── lrs_setup.m ├── mirt_dctn.m ├── mirt_idctn.m ├── process_video.m ├── refinebounds.m ├── reorth.m ├── run_alg.m ├── run_algorithm.m └── utils ├── bytesize.m ├── convert_2dresults2mov.m ├── convert_3dresults2mov.m ├── convert_video2d_to_avi.m ├── convert_video3d_to_2d.m ├── convert_video3d_to_avi.m ├── convert_video4d_to_avi.m ├── convert_video_to_2d.m ├── convert_video_to_3d.m ├── convert_video_to_3dtensor.m ├── convert_video_to_4d.m ├── crop_4dvideo.m ├── displog.m ├── gen_file_name.m ├── get_file_extension.m ├── isemptydir.m ├── load_video_file.m ├── load_video_file2.m ├── nma_rescale.m ├── resize_4dvideo.m ├── save_results.m ├── show_2dresults.m ├── show_2dvideo.m ├── show_3dvideo.m ├── show_4dvideo.m ├── show_Svideo.m ├── show_results.m ├── show_video.m ├── subsampling.m └── video2mat.m /face image shadow removal/yale05.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/face image shadow removal/yale05.mat -------------------------------------------------------------------------------- /synthetic data/100.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/synthetic data/100.mat -------------------------------------------------------------------------------- /video background subtraction/ReadMe.m: -------------------------------------------------------------------------------- 1 | % The code for LRSD-TNNSR algorithm 2 | % 3 | % Some codes about processing videos are available from LRSLibrary [1] 4 | % and downloaded from https://github.com/andrewssobral/lrslibrary. 5 | % 6 | %[1] Sobral, A., Bouwmans, T., Zahzah, E.h.: Lrslibrary: Lowrank 7 | % and sparse tools for background modeling and subtraction 8 | % in videos. In: Robust Low-Rank and Sparse 9 | % Matrix Decomposition: Applications in Image and Video 10 | % Processing. CRC Press, Taylor and Francis Group. 11 | -------------------------------------------------------------------------------- /video background subtraction/bdsqr.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/bdsqr.mexw32 -------------------------------------------------------------------------------- /video background subtraction/dataset/Video_003.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/dataset/Video_003.avi -------------------------------------------------------------------------------- /video background subtraction/dataset/escalator.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/dataset/escalator.avi -------------------------------------------------------------------------------- /video background subtraction/demo.m: -------------------------------------------------------------------------------- 1 | %the demo of the video background subtraction 2 | % 3 | % References: 4 | % Z. Xue, J. Dong, Y. Zhao, C. Liu, and R. Chellali, 5 | % "Low-rank and Sparse Matrix Decomposition via the Truncated Nuclear Norm and a Sparse Regularizer," 6 | % submitted to The Visual Computer, April 2018. 7 | % 8 | % Written by Zhichao Xue, version 1.0 9 | 10 | lrs_setup; 11 | 12 | lrs_load_conf; 13 | 14 | input_avi = fullfile(lrs_conf.lrs_dir,'dataset','escalator.avi'); %input video, for example: escalator.avi. And Video_003.avi is from BMC dataset. 15 | output_avi = fullfile(lrs_conf.lrs_dir,'output','output.avi'); 16 | 17 | process_video(input_avi, output_avi); -------------------------------------------------------------------------------- /video background subtraction/gui/gui_close.m: -------------------------------------------------------------------------------- 1 | function gui_close(hObject, eventdata, handles) 2 | 3 | end 4 | 5 | -------------------------------------------------------------------------------- /video background subtraction/gui/gui_display_cputime.m: -------------------------------------------------------------------------------- 1 | function gui_display_cputime(n, handle) 2 | lrs_load_conf; 3 | 4 | fig_dir = fullfile(lrs_conf.lrs_dir,'figs'); 5 | fig_name = fullfile(fig_dir,'time0.png'); 6 | 7 | switch n 8 | case 1 9 | fig_name = fullfile(fig_dir,'time1.png'); 10 | case 2 11 | fig_name = fullfile(fig_dir,'time2.png'); 12 | case 3 13 | fig_name = fullfile(fig_dir,'time3.png'); 14 | case 4 15 | fig_name = fullfile(fig_dir,'time4.png'); 16 | case 5 17 | fig_name = fullfile(fig_dir,'time5.png'); 18 | end 19 | 20 | img_time = imread(fig_name,'BackgroundColor',[0.94 0.94 0.94]); 21 | imshow(img_time,'parent',handle); 22 | end -------------------------------------------------------------------------------- /video background subtraction/gui/gui_display_speed.m: -------------------------------------------------------------------------------- 1 | function gui_display_speed(n, handle) 2 | lrs_load_conf; 3 | 4 | fig_dir = fullfile(lrs_conf.lrs_dir,'figs'); 5 | fig_name = fullfile(fig_dir,'speed0.png'); 6 | 7 | switch n 8 | case 1 9 | fig_name = fullfile(fig_dir,'speed1.png'); 10 | case 2 11 | fig_name = fullfile(fig_dir,'speed2.png'); 12 | case 3 13 | fig_name = fullfile(fig_dir,'speed3.png'); 14 | case 4 15 | fig_name = fullfile(fig_dir,'speed4.png'); 16 | case 5 17 | fig_name = fullfile(fig_dir,'speed5.png'); 18 | end 19 | 20 | img_speed = imread(fig_name,'BackgroundColor',[0.94 0.94 0.94]); 21 | imshow(img_speed,'parent',handle); 22 | end -------------------------------------------------------------------------------- /video background subtraction/gui/gui_show_video.m: -------------------------------------------------------------------------------- 1 | function gui_show_video(videoHandle, outputHandle, logMessageHandle) 2 | fullFileName = get(videoHandle,'String'); 3 | gui_show_video_file(fullFileName, outputHandle, logMessageHandle); 4 | end 5 | -------------------------------------------------------------------------------- /video background subtraction/gui/main.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/gui/main.fig -------------------------------------------------------------------------------- /video background subtraction/gui/main_about.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/gui/main_about.fig -------------------------------------------------------------------------------- /video background subtraction/gui/main_edit_video.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/gui/main_edit_video.fig -------------------------------------------------------------------------------- /video background subtraction/hard_threshold.m: -------------------------------------------------------------------------------- 1 | %% 2dmatrix hard_threshold(2dmatrix) 2 | % S - sparse 2dmatrix 3 | % O - outliers 2dmatrix 4 | % 5 | function O = hard_threshold(S) 6 | displog('Applying hard threshold...'); 7 | 8 | % beta = 0.5*(3*std(S(:))/20)^2; % min beta, lower bound: suppose SNR <= 20 9 | beta = 0.5*(std(S(:)))^2; % begin beta, start from a big value 10 | 11 | % direct hard thresholding if no smoothness 12 | O = double(0.5*S.^2 > beta); 13 | end 14 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/@double/gammaln.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/@double/gammaln.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/@mutable/display.m: -------------------------------------------------------------------------------- 1 | function display(mut) 2 | 3 | display(mut.obj) 4 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/@mutable/fieldnames.m: -------------------------------------------------------------------------------- 1 | function names = fieldnames(s) 2 | %FIELDNAMES Get mutable structure field names. 3 | % names = fieldnames(s) returns a cell array of strings containing the 4 | % structure field names associated with the mutable structure s. 5 | % 6 | % See also GETFIELD, SETFIELD, RMFIELD, ISFIELD. 7 | 8 | % Written by Tom Minka 9 | % (c) Microsoft Corporation. All rights reserved. 10 | 11 | names = {}; 12 | ke = s.obj.get('_fields').elements; 13 | while ke.hasMoreElements 14 | names{end+1} = ke.nextElement; 15 | end 16 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/@mutable/getfield.m: -------------------------------------------------------------------------------- 1 | function v = getfield(s,field) 2 | %GETFIELD Get mutable structure field contents. 3 | % f = getfield(s,'field') returns the contents of the specified field. 4 | % This is equivalent to the syntax f = s.field. 5 | % 6 | % See also SETFIELD, RMFIELD, ISFIELD, FIELDNAMES. 7 | 8 | % Written by Tom Minka 9 | % (c) Microsoft Corporation. All rights reserved. 10 | 11 | v = s.obj.get(field); 12 | if isempty(v) 13 | error(sprintf('Reference to non-existent field ''%s''.',field)); 14 | end 15 | v = fromJava(v); 16 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/@mutable/immutable.m: -------------------------------------------------------------------------------- 1 | function v = immutable(mut) 2 | %IMMUTABLE Convert to an ordinary (immutable) object. 3 | % immutable(v) returns an immutable copy of the mutable object v, i.e. 4 | % converts v into an ordinary Matlab value. 5 | % 6 | % Examples: 7 | % x = mutable([1 2 3]); 8 | % sum(x) % fails 9 | % sum(immutable(x)) % returns 6 10 | 11 | % Written by Tom Minka 12 | % (c) Microsoft Corporation. All rights reserved. 13 | 14 | v = fromJava(mut.obj); 15 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/@mutable/isfield.m: -------------------------------------------------------------------------------- 1 | function tf = isfield(s,f) 2 | %ISFIELD True if field is in mutable structure. 3 | % isfield(s,'field') returns true if 'field' is the name of a field in the 4 | % mutable structure s. 5 | % 6 | % See also GETFIELD, SETFIELD, RMFIELD, FIELDNAMES. 7 | 8 | % Written by Tom Minka 9 | % (c) Microsoft Corporation. All rights reserved. 10 | 11 | tf = s.obj.containsKey(f); 12 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/@mutable/rmfield.m: -------------------------------------------------------------------------------- 1 | function s = rmfield(s,field) 2 | %RMFIELD Remove fields from a mutable structure. 3 | % rmfield(s,'field') removes the specified field from the mutable structure s. 4 | % rmfield(s,fields) removes more than one field at a time when FIELDS is a 5 | % cell array of strings. 6 | % 7 | % See also SETFIELD, GETFIELD, ISFIELD, FIELDNAMES. 8 | 9 | % Written by Tom Minka 10 | % (c) Microsoft Corporation. All rights reserved. 11 | 12 | fields = s.obj.get('_fields'); 13 | if iscellstr(field) 14 | for i = 1:length(field) 15 | s.obj.remove(field{i}); 16 | fields.removeElement(field{i}); 17 | end 18 | else 19 | s.obj.remove(field); 20 | fields.removeElement(field); 21 | end 22 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/@mutable/setfield.m: -------------------------------------------------------------------------------- 1 | function s = setfield(s,field,v) 2 | %SETFIELD Set mutable structure field contents. 3 | % setfield(s,'field',v) sets the contents of the specified field to the 4 | % value V. This is equivalent to the syntax S.field = V. 5 | % 6 | % See also GETFIELD, RMFIELD, ISFIELD, FIELDNAMES. 7 | 8 | % Written by Tom Minka 9 | % (c) Microsoft Corporation. All rights reserved. 10 | 11 | jv = s.obj; 12 | if ~jv.containsKey(field) 13 | % add a new field 14 | jv.get('_fields').addElement(field); 15 | end 16 | jv.put(field,asJava(v)); 17 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/addflops.c: -------------------------------------------------------------------------------- 1 | #include "mex.h" 2 | #include "flops.h" 3 | 4 | void mexFunction(int nlhs, mxArray *plhs[], 5 | int nrhs, const mxArray *prhs[]) 6 | { 7 | if(nrhs != 1) mexErrMsgTxt("Usage: addflops(count)"); 8 | if(mxGetNumberOfElements(prhs[0]) != 1) 9 | mexErrMsgTxt("flop count is not scalar"); 10 | addflops((unsigned)*mxGetPr(prhs[0])); 11 | } 12 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/addflops.m: -------------------------------------------------------------------------------- 1 | function f = addflops(fl) 2 | % ADDFLOPS Increment the global flopcount variable. 3 | % ADDFLOPS(fl) is equivalent to FLOPS(FLOPS+FL), but more efficient. 4 | 5 | global flopcount; 6 | if ~isempty(flopcount) 7 | flopcount = flopcount + fl; 8 | end 9 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/addflops.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/addflops.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/argfilter.m: -------------------------------------------------------------------------------- 1 | function args = argfilter(args,keep) 2 | %ARGFILTER Remove unwanted arguments. 3 | % ARGFILTER(ARGS,KEEP), where ARGS = {'arg1',value1,'arg2',value2,...}, 4 | % returns a new argument list where only the arguments named in KEEP are 5 | % retained. KEEP is a character array or cell array of strings. 6 | 7 | % Written by Tom Minka 8 | 9 | if ischar(keep) 10 | keep = cellstr(keep); 11 | end 12 | i = 1; 13 | while i < length(args) 14 | if ~ismember(args{i},keep) 15 | args = args(setdiff_sorted(1:length(args),[i i+1])); 16 | else 17 | i = i + 2; 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/argmax.m: -------------------------------------------------------------------------------- 1 | function index = argmax(x) 2 | %ARGMAX Index of maximum element. 3 | % ARGMAX(X) returns an index I such that X(I) == MAX(X(:)). 4 | % 5 | % See also MAX, ARGMIN. 6 | 7 | [ignore,index] = max(x(:)); 8 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/argmax2.m: -------------------------------------------------------------------------------- 1 | function [i,j] = argmax2(x) 2 | %ARGMAX2 Index of maximum element of matrix. 3 | % [i,j] = ARGMAX2(x) returns indices (i,j) such that x(i,j) == max(x(:)). 4 | % 5 | % See also ARGMAX. 6 | 7 | [colmax,i] = max(x); 8 | [ignore,j] = max(colmax); 9 | i = i(j); 10 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/argmin.m: -------------------------------------------------------------------------------- 1 | function index = argmin(x) 2 | %ARGMIN Index of minimum element. 3 | % ARGMIN(X) returns an index I such that X(I) == MIN(X(:)). 4 | % 5 | % See also MIN, ARGMAX. 6 | 7 | [ignore,index] = min(x(:)); 8 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/argmin2.m: -------------------------------------------------------------------------------- 1 | function [i,j] = argmin2(x) 2 | %ARGMIN2 Index of minimum element of matrix. 3 | % [i,j] = ARGMIN2(x) returns indices (i,j) such that x(i,j) == min(x(:)). 4 | % 5 | % See also ARGMIN, ARGMAX2. 6 | 7 | [colmin,i] = min(x); 8 | [ignore,j] = min(colmin); 9 | i = i(j); 10 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/col_sum.m: -------------------------------------------------------------------------------- 1 | function s = col_sum(x) 2 | % COL_SUM Sum for each column. 3 | % A more readable alternative to sum(x,1). 4 | s = sum(x,1); 5 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/cols.m: -------------------------------------------------------------------------------- 1 | function c = cols(x) 2 | % COLS The number of columns. 3 | % COLS is a more readable alternative to size(x,2). 4 | c = size(x,2); 5 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/digamma.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/digamma.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/find_sameobject.m: -------------------------------------------------------------------------------- 1 | function i = find_sameobject(x,v) 2 | % Returns the index of the first element of x which is the same object as v. 3 | % x is a cell array. 4 | 5 | % Written by Tom Minka 6 | % (c) Microsoft Corporation. All rights reserved. 7 | 8 | for i = 1:length(x) 9 | if sameobject(x{i},v) 10 | return 11 | end 12 | end 13 | i = length(x)+1; 14 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/finddiag.m: -------------------------------------------------------------------------------- 1 | function i = finddiag(A,k) 2 | %FINDDIAG Index elements on the diagonal. 3 | % FINDDIAG(A) returns the indices of the diagonal of A. 4 | % FINDDIAG(A,K) returns the indices of the K-th diagonal of A. 5 | % 6 | % See also DIAG, SETDIAG. 7 | 8 | % Written by Tom Minka 9 | % (c) Microsoft Corporation. All rights reserved. 10 | 11 | if nargin < 2 12 | k = 0; 13 | end 14 | n = length(A); 15 | if k >= 0 16 | i = (k*n+1):(n+1):(n^2); 17 | else 18 | i = (1-k):(n+1):(n*(n+k)); 19 | end 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops.c: -------------------------------------------------------------------------------- 1 | #include "mex.h" 2 | #include "flops.h" 3 | 4 | void addflops(unsigned fl) 5 | { 6 | #if 0 7 | mxArray *flopcount = mexGetArray("flopcount","global"); 8 | if(flopcount && !mxIsEmpty(flopcount))) { 9 | *mxGetPr(flopcount) += fl; 10 | mexPutArray(flopcount,"global"); 11 | } 12 | #else 13 | /* Matlab 6.5 */ 14 | mxArray *flopcount = mexGetVariable("global","flopcount"); 15 | if(flopcount && !mxIsEmpty(flopcount)) { 16 | *mxGetPr(flopcount) += fl; 17 | mexPutVariable("global","flopcount",flopcount); 18 | } 19 | #endif 20 | } 21 | 22 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops.h: -------------------------------------------------------------------------------- 1 | #define FLOPS_DIV 8 2 | #define FLOPS_SQRT 8 3 | #define FLOPS_EXP 40 4 | #define FLOPS_LOG 20 5 | 6 | void addflops(unsigned fl); 7 | 8 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops.m: -------------------------------------------------------------------------------- 1 | function f = flops(fl) 2 | % FLOPS Get or set the global flopcount variable. 3 | % FLOPS returns the current flopcount. 4 | % FLOPS(F) sets flopcount to F. 5 | % 6 | % 0 flops: -x ' repmat 7 | % 1 flop each: + - .* 8 | % 2 flops each: < > == ~= 9 | % For complex numbers, + is 2 flops, * is 6 flops. 10 | % col_sum(x) takes (rows(x)-1)*cols(x) flops (use FLOPS_COL_SUM). 11 | % row_sum(x) takes rows(x)*(cols(x)-1) flops (use FLOPS_ROW_SUM). 12 | % Use FLOPS_DIV for ./ 13 | % Use FLOPS_RANDNORM for randn 14 | % Use FLOPS_SQRT for sqrt 15 | % Use FLOPS_ABS for abs 16 | % Use FLOPS_POW for .^ 17 | % Use FLOPS_EXP for exp 18 | % Use FLOPS_LOG for log, sin, and other special functions. 19 | % 20 | % See FLOPS_MUL, FLOPS_SOLVE, FLOPS_INV, FLOPS_CHOL, FLOPS_DET, ... 21 | 22 | global flopcount; 23 | if nargin == 1 24 | flopcount = fl; 25 | if nargout == 1 26 | f = fl; 27 | end 28 | else 29 | f = flopcount; 30 | end 31 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/flops.obj -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_abs.m: -------------------------------------------------------------------------------- 1 | function f = flops_abs 2 | % FLOPS_ABS Flops for absolute value 3 | % FLOPS_ABS returns the number of flops needed to compute the absolute value 4 | % of a scalar. 5 | 6 | % This flop count is based on timing the Pentium 4. 7 | 8 | f = 4; 9 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_chol.m: -------------------------------------------------------------------------------- 1 | function f = flops_chol(n) 2 | % FLOPS_CHOL Flops for Cholesky decomposition. 3 | % FLOPS_CHOL(n) returns the number of flops for chol(rand(n,n)). 4 | 5 | % Formula comes from the Numerical Recipes algorithm. 6 | % Number of multiplies+adds is: 7 | % sum(i=1..n) sum(j=i..n) sum(k=i-1..1) 2 = sum(i=1..n) 2*(n-i+1)*(i-1) 8 | % = (n^3-n)/3 = maple('simplify(sum(2*(n-x+1)*(x-1),x=1..n));') 9 | % Number of divides is: 10 | % sum(i=1..n) (n-i+1) - n = (n^2-n)/2 11 | 12 | % matlab5 counts n^3/3 only 13 | f = (n.^3-n)/3 + (n.^2-n)/2*flops_div + n*flops_sqrt; 14 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_col_sum.m: -------------------------------------------------------------------------------- 1 | function f = flops_col_sum(n,m) 2 | % FLOPS_COL_SUM Flops for column sums. 3 | % FLOPS_COL_SUM(a) returns the number of flops for col_sum(a). 4 | % FLOPS_COL_SUM(n,m) returns the number of flops for col_sum(ones(n,m)). 5 | 6 | if nargin == 1 7 | m = cols(n); 8 | n = rows(n); 9 | end 10 | f = (n-1)*m; 11 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_det.m: -------------------------------------------------------------------------------- 1 | function f = flops_det(n) 2 | % FLOPS_DET Flops for matrix determinant. 3 | % FLOPS_DET(n) returns the number of flops for det(rand(n,n)). 4 | 5 | if n == 1 6 | f = 1; 7 | else 8 | % this is from logdet 9 | f = flops_chol(n) + n; 10 | end 11 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_digamma.m: -------------------------------------------------------------------------------- 1 | function fl = flops_digamma 2 | % FLOPS_DIGAMMA Flops for gammaln, digamma, and trigamma 3 | 4 | % from the implementation of digamma 5 | fl = 12*(4+flops_div)+flops_log+flops_div+13; 6 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_div.m: -------------------------------------------------------------------------------- 1 | function f = flops_div 2 | % FLOPS_DIV Flops for division. 3 | % FLOPS_DIV returns the number of flops needed to divide two scalars. 4 | 5 | % This count is based on timing the Pentium 4. 6 | % A better approach would look at an ideal implementation of division 7 | % hardware (Hennessy and Patterson comes to mind) and count how many adders 8 | % and multipliers are needed. 9 | 10 | f = 8; 11 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_exp.m: -------------------------------------------------------------------------------- 1 | function f = flops_exp 2 | % FLOPS_EXP Flops for exponential 3 | % FLOPS_EXP returns the number of flops needed to compute the exponential 4 | % of a scalar. 5 | 6 | % This flop count is based on timing the Pentium 4. 7 | % A neutral flop count is based on source code for C exp() function at 8 | % http://www.opencores.org/cvsweb.shtml/or1k/newlib/newlib/libm/mathfp/s_exp.c 9 | 10 | % if you change this, you should also change flops_pow. 11 | f = 40; % P4 12 | %f = 20; % neutral 13 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_inv.m: -------------------------------------------------------------------------------- 1 | function f = flops_inv(n) 2 | % FLOPS_INV Flops for matrix inversion. 3 | % FLOPS_INV(n) returns the number of flops for inv(rand(n,n)). 4 | % For n=1,2 the number of flops is exact. 5 | % For n>2, the number of flops is estimated by assuming the matrix is 6 | % decomposed via LU or Cholesky and then inverted by back-substitution. 7 | % See flops_solve. 8 | 9 | % Written by Tom Minka 10 | 11 | if n == 2 12 | % inv([a b; c d]) = [d -b; -c a]/(ad-bc) 13 | % 3 flops for determinant, 1 divide, 4 multiplies, 1 negation 14 | % thanks to Zhang Xiaoying for pointing out this special case. 15 | f = 3+flops_div + 5; 16 | else 17 | f = flops_solve(n,n,n); 18 | end 19 | 20 | 21 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_log.m: -------------------------------------------------------------------------------- 1 | function f = flops_log 2 | % FLOPS_LOG Flops for logarithm 3 | % FLOPS_LOG returns the number of flops needed to compute the logarithm 4 | % of a scalar. 5 | 6 | % This flop count is based on timing the Pentium 4. 7 | % A neutral flop count is based on source code for C log() function at 8 | % http://www.opencores.org/cvsweb.shtml/or1k/newlib/newlib/libm/mathfp/s_log.c 9 | % s_sine.c is 23 flops. 10 | 11 | % if you change this, you should also change flops_pow. 12 | f = 20; % P4 13 | %f = 20; % neutral 14 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_lu.m: -------------------------------------------------------------------------------- 1 | function f = flops_lu(n) 2 | % FLOPS_LU Flops for LU decomposition. 3 | % FLOPS_LU(n) returns the number of flops to compute lu(rand(n,n)). 4 | % The matrix is assumed to be symmetric positive definite, so that no pivoting is required. 5 | 6 | % Number of flops for the algorithm in Cormen et al: 7 | % Number of multiplies+adds is: 8 | % sum(k=1:n) sum(i=k+1:n) sum(j=k+1:n) 3 9 | % = sum(k=1:n) 3(n-k)^2 10 | % = sum(k=0:(n-1)) 3 k^2 11 | % = n(n-0.5)(n-1) 12 | % Number of divides is: n-1 13 | f = n*(n-0.5)*(n-1) + (n-1)*flops_div; 14 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_mul.m: -------------------------------------------------------------------------------- 1 | function f = flops_mul(n,m,c) 2 | % FLOPS_MUL Flops for real matrix multiplication. 3 | % FLOPS_MUL(a,b) returns the number of flops for a*b. 4 | % FLOPS_MUL(n,m,c) returns the number of flops for ones(n,m)*ones(m,c). 5 | % This is more accurate than the flopcount returned by matlab. 6 | 7 | if nargin == 2 8 | a = n; 9 | b = m; 10 | n = rows(a); 11 | m = cols(a); 12 | c = cols(b); 13 | end 14 | f = n*c*(2*m-1); 15 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_randnorm.m: -------------------------------------------------------------------------------- 1 | function f = flops_randnorm(n, m, S, V) 2 | % FLOPS_RANDNORM Flops for randnorm. 3 | % Arguments same as randnorm. 4 | 5 | flops_randn = 18; 6 | if nargin == 1 7 | f = n*flops_randn; 8 | return; 9 | end 10 | d = rows(m); 11 | f = d*n*flops_randn; 12 | if nargin > 2 13 | if nargin == 4 14 | if d == 1 15 | f = f + flops_sqrt*cols(S); 16 | else 17 | f = f + flops_chol(d); 18 | end 19 | end 20 | f = f + flops_mul(d,d,n); 21 | end 22 | f = f + d*n; 23 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_row_sum.m: -------------------------------------------------------------------------------- 1 | function f = flops_row_sum(n,m) 2 | % FLOPS_ROW_SUM Flops for row sums. 3 | % FLOPS_ROW_SUM(a) returns the number of flops for row_sum(a). 4 | % FLOPS_ROW_SUM(n,m) returns the number of flops for row_sum(ones(n,m)). 5 | 6 | if nargin == 1 7 | m = cols(n); 8 | n = rows(n); 9 | end 10 | f = n*(m-1); 11 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_sample.m: -------------------------------------------------------------------------------- 1 | function f = flops_sample(p,n) 2 | % FLOPS_SAMPLE Flops for sample(p,n) 3 | % Flopcount based on systematic sampling. 4 | 5 | % old algorithm: 6 | % The flopcount for sample is the same as the value returned by sample, 7 | % so the expected flops is E[x]. 8 | % Note that the result is typically not an integer. 9 | 10 | if nargin == 1 11 | n = 1; 12 | end 13 | %f = n*sum((1:length(p)).*p); 14 | f = 2*(n + length(p)); 15 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_solve_tri.m: -------------------------------------------------------------------------------- 1 | function f = flops_solve_tri(n,m,k) 2 | % FLOPS_SOLVE_TRI Flops for triangular left division. 3 | % FLOPS_SOLVE_TRI(T,b) returns the number of flops for solve_tri(T,b). 4 | % FLOPS_SOLVE_TRI(n,m,k) returns the number of flops for 5 | % solve_tril(tril(rand(n,m)),rand(n,k)). 6 | % 7 | % Example: (n=2,m=2,k=1) 8 | % [g;h] = [a 0; b c]\[e; f] has 9 | % g = e/a 10 | % h = (f - b*g)/c 11 | % which is 2 multiply+add and 2 divisions = 18 flops. 12 | 13 | if nargin == 2 14 | T = n; 15 | b = m; 16 | f = flops_solve_tri(rows(T),cols(T),cols(b)); 17 | return; 18 | end 19 | if n ~= m 20 | error('n ~= m case is not implemented'); 21 | end 22 | % lower triangular case: 23 | % number of multiplies+adds is 24 | % sum(i=1..n) sum(k=1..i-1) 2 = sum(i=1..n) 2*(i-1) = n^2-n 25 | % number of divides is n 26 | f = (n*n + n*(flops_div-1))*k; 27 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_spadd.m: -------------------------------------------------------------------------------- 1 | function f = flops_spadd(a,b) 2 | % FLOPS_SPADD Flops for sparse matrix addition. 3 | % FLOPS_SPADD(a,b) returns the number of flops for a+b, where addition of zero 4 | % doesn't count. 5 | % For example: 6 | % flops_spadd(0,4) is 0. 7 | % flops_spadd(eye(3), ones(3)) is 3. 8 | 9 | nza = (a ~= 0); 10 | nzb = (b ~= 0); 11 | f = sum(sum(nza & nzb)); 12 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_spmul.m: -------------------------------------------------------------------------------- 1 | function f = flops_spmul(a,b) 2 | % FLOPS_SPMUL Flops for sparse matrix multiplication. 3 | % FLOPS_SPMUL(a,b) returns the number of flops for a*b, where multiplication 4 | % and addition of zero doesn't count. 5 | % For example: 6 | % flops_spmul(0,4) is 0. 7 | % flops_spmul([1 0 1], [2;3;4]) is 3. 8 | % flops_spmul(eye(3), [2;3;4]) is 3. 9 | 10 | nza = (a ~= 0); 11 | nzb = (b ~= 0); 12 | f = nza*nzb; 13 | f = 2*f - (f ~= 0); 14 | f = sum(sum(f)); 15 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/flops_sqrt.m: -------------------------------------------------------------------------------- 1 | function f = flops_sqrt 2 | % FLOPS_SQRT Flops for square root 3 | % FLOPS_SQRT returns the number of flops needed to compute the square root 4 | % of a scalar. 5 | 6 | % This flop count is based on timing the Pentium 4. 7 | % The neutral flop count is based on source code for C sqrt() function at 8 | % http://www.opencores.org/cvsweb.shtml/or1k/newlib/newlib/libm/mathfp/s_sqrt.c 9 | 10 | % if you change this, you should also change flops_pow. 11 | f = 8; % P4 12 | %f = 15; % neutral 13 | 14 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/getaddress.c: -------------------------------------------------------------------------------- 1 | /* Written by Tom Minka 2 | * (c) Microsoft Corporation. All rights reserved. 3 | */ 4 | 5 | #include "mex.h" 6 | 7 | void mexFunction(int nlhs, mxArray *plhs[], 8 | int nrhs, const mxArray *prhs[]) 9 | { 10 | double *p; 11 | if(nrhs != 1) { 12 | mexErrMsgTxt("usage: getaddress(a)"); 13 | } 14 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 15 | p = mxGetPr(plhs[0]); 16 | *p = (double)(long)mxGetData(prhs[0]); 17 | } 18 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/glob2regexp.m: -------------------------------------------------------------------------------- 1 | function pattern = glob2regexp(pattern) 2 | %GLOB2REGEXP Convert a glob pattern into a regexp pattern. 3 | % GLOB2REGEXP(PATTERN) returns a regexp pattern which matches the same strings 4 | % as the given glob pattern. 5 | % 6 | % Examples: 7 | % glob2regexp('my*file?.txt') 8 | % returns '^my.*file.\.txt$' 9 | 10 | pattern = strrep(pattern,'.','\.'); 11 | pattern = strrep(pattern,'*','.*'); 12 | pattern = strrep(pattern,'?','.'); 13 | pattern = ['^' pattern '$']; 14 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/YR_colors.m: -------------------------------------------------------------------------------- 1 | function colors = YR_colors(n) 2 | % YR_colors A good sequential colormap. 3 | % YR_colors(n) returns an RGB matrix of n colors (default 64). 4 | % These colors form a sequential colormap (colors easily perceived to lie 5 | % on a sequence). 6 | % 7 | % Example: 8 | % colormap(YR_colors) 9 | % 10 | % See also YlGnBu_colors 11 | 12 | % Written by Tom Minka 13 | 14 | if nargin < 1 15 | n = 64; 16 | end 17 | 18 | lt = 0.97; 19 | dk = 0.03; 20 | k = ceil(n/3); 21 | lts = repmat(lt,1,k); 22 | dks = repmat(dk,1,k); 23 | span = linspace(lt,dk,k+1); 24 | span = span(1:(end-1)); 25 | r = [lts lts span]; 26 | g = [lts span dks]; 27 | b = [span dks dks]; 28 | colors = [r;g;b]'; 29 | colors = flipud(colors); 30 | i = round(linspace(1,rows(colors),n)); 31 | colors = colors(i,:); 32 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/YlGnBu_colors.m: -------------------------------------------------------------------------------- 1 | function colors = YlGnBu_colors(n) 2 | % YlGnBu_colors A good sequential colormap. 3 | % YlGnBu_colors(n) returns an RGB matrix of n colors (default 4). 4 | % These colors form a sequential colormap (colors easily perceived to lie 5 | % on a sequence). 6 | % 7 | % Example: 8 | % colormap(YlGnBu_colors(32)) 9 | % 10 | % See also YR_colors 11 | 12 | % Written by Tom Minka 13 | 14 | if nargin < 1 15 | n = 4; 16 | end 17 | 18 | if n == 4 19 | colors = [1 1 0.8; 0.63 0.855 0.706; 0.255 0.714 0.765; 0.22 0.42 0.69]; 20 | else 21 | error('can''t make that many levels'); 22 | end 23 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/category_colors.m: -------------------------------------------------------------------------------- 1 | function colors = category_colors(n) 2 | % category_colors A good colormap for distinct categories. 3 | % category_colors(n) returns an RGB matrix of n colors. 4 | % 5 | % See also YlGnBu_colors. 6 | 7 | % Written by Tom Minka 8 | 9 | 10 | colors = [0 0 0;255 0 0;0 205 0;0 0 255;0 255 255;255 0 255;255 128 0;128 128 0;0 128 128;128 0 128;255 179 179;179 255 179;179 179 255]/255; 11 | colors = [0 0 0;255 0 0;0 205 0;0 0 255;0 255 255;255 0 255;255 128 0;128 128 0;0 128 128;128 0 128]/255; 12 | i = rem((1:n)-1,rows(colors))+1; 13 | colors = colors(i,:); 14 | 15 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/cut_diverging.m: -------------------------------------------------------------------------------- 1 | function c = cut_diverging(x,n) 2 | % CUT_DIVERGING Index of sign-balanced quantiles 3 | % cut_diverging(x,n) is just like cut_quantile(x,n) except the negative and 4 | % positive numbers are each divided into n/2 quantiles. 5 | % In other words, it cuts x into n parts so that half go to x<0. 6 | % 7 | % Examples: 8 | % cut_diverging(-2:3,2) 9 | % cut_diverging(-2:3,3) 10 | 11 | n1 = floor(n/2); 12 | n2 = n - n1; 13 | ineg = find(x(:) < 0); 14 | i0 = find(x(:) == 0); 15 | ipos = find(x(:) > 0); 16 | c = zeros(size(x)); 17 | c(i0) = n1+1; 18 | c(ineg) = cut_quantile(x(ineg),n1); 19 | c(ipos) = cut_quantile(x(ipos),n2-1)+n1+1; 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/cut_quantile.m: -------------------------------------------------------------------------------- 1 | function [c,b] = cut_quantile(x,n) 2 | % CUT_QUANTILE Index of quantiles. 3 | % cut_quantile(x,n) returns a matrix of quantile numbers, same size as x, 4 | % ranging 1..n (n is the desired number of quantiles). 5 | % The values with number 1 are in the first quantile, etc. 6 | % [c,b] = cut_quantile(x,n) returns the quantile values selected 7 | % 8 | % Example: 9 | % cut_quantile(1:10,4) 10 | 11 | probs = linspace(0,1,n+1); 12 | b = quantile(unique(x(:)),probs); 13 | 14 | c = zeros(size(x)); 15 | for b_iter = 1:(length(b)-1) 16 | c(x >= b(b_iter)) = b_iter; 17 | end 18 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/draw_circle.m: -------------------------------------------------------------------------------- 1 | function h = draw_circle(x, r, outline_color, fill_color) 2 | % draw filled circles at centers x with radii r. 3 | % x is a matrix of columns. r is a row vector. 4 | 5 | n = 40; % resolution 6 | radians = [0:(2*pi)/(n-1):2*pi]; 7 | unitC = [sin(radians); cos(radians)]; 8 | 9 | % extend r if necessary 10 | if length(r) < cols(x) 11 | r = [r repmat(r(length(r)), 1, cols(x)-length(r))]; 12 | end 13 | 14 | h = []; 15 | % hold is needed for fill() 16 | held = ishold; 17 | hold on 18 | for i=1:cols(x) 19 | y = unitC*r(i) + repmat(x(:, i), 1, n); 20 | if nargin < 4 21 | h = [h line(y(1,:), y(2,:), 'Color', outline_color)]; 22 | else 23 | h = [h fill(y(1,:), y(2,:), fill_color, 'EdgeColor', outline_color)]; 24 | end 25 | end 26 | if ~held 27 | hold off 28 | end 29 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/draw_ellipse.m: -------------------------------------------------------------------------------- 1 | function h = draw_ellipse(x, c, outline_color, fill_color) 2 | % DRAW_ELLIPSE(x, c, outline_color, fill_color) 3 | % Draws ellipses at centers x with covariance matrix c. 4 | % x is a matrix of columns. c is a positive definite matrix. 5 | % outline_color and fill_color are optional. 6 | 7 | n = 40; % resolution 8 | radians = [0:(2*pi)/(n-1):2*pi]; 9 | unitC = [sin(radians); cos(radians)]; 10 | r = chol(c)'; 11 | 12 | if nargin < 3 13 | outline_color = 'g'; 14 | end 15 | 16 | h = []; 17 | for i=1:cols(x) 18 | y = r*unitC + repmat(x(:, i), 1, n); 19 | if nargin < 4 20 | h = [h line(y(1,:), y(2,:), 'Color', outline_color)]; 21 | else 22 | h = [h fill(y(1,:), y(2,:), fill_color, 'EdgeColor', outline_color)]; 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/draw_ellipse_axes.m: -------------------------------------------------------------------------------- 1 | function h = draw_ellipse_axes(x, c, linespec) 2 | % DRAW_ELLIPSE_AXES(x, c, linespec) 3 | % Draws the major and minor axes of ellipses. 4 | % Ellipses are centered at x with covariance matrix c. 5 | % x is a matrix of columns. c is a positive definite matrix. 6 | % linespec is optional. 7 | 8 | [v,e] = eig(c); 9 | v = v*sqrt(e); 10 | 11 | h = []; 12 | for j = 1:cols(v) 13 | x1 = repmat(x(1,:),2,1) + repmat([-1;1]*v(1,j),1,cols(x)); 14 | x2 = repmat(x(2,:),2,1) + repmat([-1;1]*v(2,j),1,cols(x)); 15 | h = [h line(x1,x2)]; 16 | end 17 | if nargin > 2 18 | set_linespec(h,linespec); 19 | end 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/draw_line_clip.m: -------------------------------------------------------------------------------- 1 | function h = draw_line_clip(m,b,a, linespec, varargin) 2 | %DRAW_LINE_CLIP Draw a line defined by an equation. 3 | % DRAW_LINE_CLIP(M,B,A) draws a line, clipped to the current axes, 4 | % defined by a*y = m*x + b. 5 | % DRAW_LINE_CLIP(M,B,A,LINESPEC) also specifies the line style and color. 6 | 7 | if nargin < 4 8 | linespec = 'b'; 9 | end 10 | v = axis; 11 | x1 = v(1); 12 | x2 = v(2); 13 | warning off 14 | y1 = (m*x1 + b)/a; 15 | y2 = (m*x2 + b)/a; 16 | warning on 17 | if y1 < v(3) 18 | y1 = v(3); 19 | x1 = (a*y1 - b)/m; 20 | end 21 | if y1 > v(4) 22 | y1 = v(4); 23 | x1 = (a*y1 - b)/m; 24 | end 25 | if y2 < v(3); 26 | y2 = v(3); 27 | x2 = (a*y2 - b)/m; 28 | end 29 | if y2 > v(4); 30 | y2 = v(4); 31 | x2 = (a*y2 - b)/m; 32 | end 33 | h = line([x1 x2], [y1 y2]); 34 | set_linespec(h,linespec); 35 | if length(varargin) > 0 36 | set(h,varargin{:}); 37 | end 38 | if nargout < 1 39 | clear h 40 | end 41 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/linechart.m: -------------------------------------------------------------------------------- 1 | function linechart(y,color,varargin) 2 | % LINECHART(Y,COLOR,VARARGIN) provides extra arguments to LABELED_CURVES. 3 | % Examples: 4 | % linechart(y,color) 5 | % See also LABELED_CURVES. 6 | 7 | % sort 8 | f = fieldnames(y); 9 | f = f{1}; 10 | v = getfield(y,char(f)); 11 | [dummy,order] = sort(v); 12 | for f = fieldnames(y)' 13 | v = getfield(y,char(f)); 14 | y = setfield(y,char(f),v(order)); 15 | end 16 | x = 1:length(v); 17 | x = x(order); 18 | %fprintf('columns are');fprintf(' %d',x);fprintf('\n'); 19 | 20 | labeled_curves(1:length(x),y,'color',color,varargin{:}); 21 | set(gca,'XTick',1:length(x),'XTickLabel',num2str(x')); 22 | axis_pct; 23 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/mobile_points.m: -------------------------------------------------------------------------------- 1 | function h = mobile_points(n, linespec) 2 | % Places n random points in the style given by linespec (e.g. 'bo'). 3 | % Points can be dragged with the mouse. 4 | 5 | if nargin < 2 6 | linespec = 'o'; 7 | end 8 | ax = axis; 9 | % random placement 10 | x = rand(1,n)*(ax(2)-ax(1)) + ax(1); 11 | y = rand(1,n)*(ax(4)-ax(3)) + ax(3); 12 | h = []; 13 | for i = 1:n 14 | h = [h line(x(i), y(i), 'linestyle', 'none')]; 15 | end 16 | set_linespec(h,linespec); 17 | set(h, 'ButtonDownFcn', 'move_obj(1)'); 18 | if nargout < 1 19 | clear h; 20 | end 21 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/mobile_text.m: -------------------------------------------------------------------------------- 1 | function h = mobile_text(varargin) 2 | % MOBILE_TEXT('str1', 'str2', ...) places each string in a random position 3 | % on the current axes. The strings can be dragged around with the mouse. 4 | % Returns handles to the text objects, for setting colors, etc. 5 | 6 | strs = varargin; 7 | n = length(strs); 8 | ax = axis; 9 | % random placement 10 | x = rand(1,n)*(ax(2)-ax(1)) + ax(1); 11 | y = rand(1,n)*(ax(4)-ax(3)) + ax(3); 12 | h = []; 13 | for i = 1:n 14 | h = [h text(x(i),y(i),strs{i})]; 15 | end 16 | set(h,'ButtonDownFcn','move_obj(1)'); 17 | if nargout == 0 18 | clear h 19 | end 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/plot_errorbars.m: -------------------------------------------------------------------------------- 1 | function plot_errorbars(means,stderrs,rownames) 2 | % plot_errorbars(means,stderrs,rownames) 3 | % makes a plot where each mean is displayed on a row labelled with its 4 | % rowname and a horizontal line connecting (mean-stderr,mean+stderr) 5 | 6 | n = size(means,1); 7 | h=plot(means,1:n,'o'); 8 | set(h,'linewidth',2) 9 | x = zeros(2,n); 10 | x(1,:) = means-stderrs; 11 | x(2,:) = means+stderrs; 12 | y = repmat(1:n,2,1); 13 | h = line(x,y); 14 | set_linespec(h,'b-'); 15 | set(h,'linewidth',2) 16 | axis_pct 17 | set(gca,'ytick',1:n,'yticklabel',rownames,'ydir','reverse') 18 | set(gca,'tickdir','out') 19 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/quantile.m: -------------------------------------------------------------------------------- 1 | function b = quantile(x,probs) 2 | % QUANTILE Quantiles of a data vector. 3 | % quantile(x,probs) behaves like the R function of the same name. 4 | % 5 | % Example: 6 | % quantile(3:4,[0.3 0.6]) 7 | 8 | x = sort(x); 9 | x = x(:)'; % workaround matlab indexing bug 10 | pos = probs*(length(x)-1) + 1; 11 | pos_lower = floor(pos); 12 | pos_upper = ceil(pos); 13 | pos_frac = pos - pos_lower; 14 | b = x(pos_lower).*(1-pos_frac) + x(pos_upper).*pos_frac; 15 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/send_to_back.m: -------------------------------------------------------------------------------- 1 | function send_to_back(handles) 2 | % send_to_back(handles) puts the given objects underneath the other objects in the figure. 3 | 4 | children = get(gca,'children'); 5 | children = [setdiff(children,handles); handles]; 6 | set(gca,'children',children); 7 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/set_linespec.m: -------------------------------------------------------------------------------- 1 | function set_linespec(h,linespec) 2 | % SET_LINESPEC Set the color and line style of a graphics object. 3 | % SET_LINESPEC(h,linespec) will set the color and line style of a graphics 4 | % object, using the linespec convention of 'plot', e.g. 5 | % set_linespec(h,'g:') 6 | % set_linespec(h,'r--') 7 | 8 | % break linespec into color and linestyle. 9 | [linestyle, color, marker, msg] = colstyle(linespec); 10 | if ~isempty(msg) 11 | error(msg) 12 | end 13 | if length(color) > 0 14 | if strcmp(get(h,'Type'),'patch') 15 | set(h,'EdgeColor',color); 16 | else 17 | set(h,'color',color); 18 | end 19 | end 20 | if length(linestyle) > 0 21 | set(h,'linestyle',linestyle); 22 | end 23 | if length(marker) > 0 24 | set(h,'marker',marker); 25 | end 26 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/test_draw.m: -------------------------------------------------------------------------------- 1 | n = 2; 2 | % cov 3 | c = randn(n); 4 | c = c'*c; 5 | c = [1 0.5; 0.5 1]; 6 | 7 | figure(1);clf 8 | h = draw_circle(rand(2,n), rand(1,n), 'b', 'g'); 9 | h = draw_circle(rand(2,n), rand(1,n), 'c'); 10 | x = rand(2,n); 11 | h = draw_ellipse(x, c, 'r'); 12 | h = draw_ellipse_axes(x, c, 'r:'); 13 | axis equal 14 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/graphics/test_hhist.m: -------------------------------------------------------------------------------- 1 | % demonstrate use of hhist 2 | 3 | figure; 4 | x = sample([0.1 0.2 0.3 0.4], 1000); 5 | hhist(x); 6 | 7 | figure; 8 | % verify density for product of indep normals 9 | x = prod(randn(2,100000)); 10 | ts = linspace(-1,1,1000); 11 | z = hhist(x, ts); 12 | h = plot(ts, z, ts, besselk(0,abs(ts))*1/pi); 13 | %set(h(2),'LineWidth',2) 14 | axis_pct 15 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/ind2subv.m: -------------------------------------------------------------------------------- 1 | function sub = ind2subv(siz,index) 2 | %IND2SUBV Subscript vector from linear index. 3 | % IND2SUBV(SIZ,IND) returns a vector of the equivalent subscript values 4 | % corresponding to a single index into an array of size SIZ. 5 | % If IND is a vector, then the result is a matrix, with subscript vectors 6 | % as rows. 7 | 8 | % Written by Tom Minka 9 | % Part of Tom Minka's lightspeed package. 10 | % (c) Microsoft Corporation. All rights reserved. 11 | 12 | n = length(siz); 13 | cum_size = cumprod(siz(:)'); 14 | prev_cum_size = [1 cum_size(1:end-1)]; 15 | index = index(:) - 1; 16 | sub = rem(repmat(index,1,n),repmat(cum_size,length(index),1)); 17 | sub = floor(sub ./ repmat(prev_cum_size,length(index),1))+1; 18 | 19 | % slow way 20 | %for dim = n:-1:1 21 | % sub(:,dim) = floor(index/cum_size(dim))+1; 22 | % index = rem(index,cum_size(dim)); 23 | %end 24 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/int_hist.m: -------------------------------------------------------------------------------- 1 | function h = int_hist(x, n) 2 | % INT_HIST(x, n) is a histogram of all integer values 1..n in x. 3 | % If n is not given, max(x) is used. 4 | 5 | % Hans Olsson's one-liner from matlab faq 6 | h = full(sum(sparse(1:length(x(:)),x(:),1))); 7 | if nargin == 2 8 | if n > length(h) 9 | % pad with zeros 10 | h = [h zeros(1,n-length(h))]; 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/int_hist.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/int_hist.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/intersect_sorted.m: -------------------------------------------------------------------------------- 1 | function c = intersect_sorted(a,b) 2 | %INTERSECT_SORTED Set intersection between sorted sets. 3 | % INTERSECT_SORTED(A,B) when A and B are vectors returns the values common 4 | % to both A and B. A and B must be sorted and unique, and the result will be 5 | % sorted and unique. 6 | 7 | % Written by Tom Minka 8 | % (c) Microsoft Corporation. All rights reserved. 9 | 10 | c = a(ismember_sorted(a,b)); 11 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/inv_posdef.m: -------------------------------------------------------------------------------- 1 | function x = inv_posdef(A) 2 | % INV_POSDEF Invert positive definite matrix. 3 | % INV_POSDEF(A) is like INV(A) but faster and more numerically stable. 4 | % See test_inv_posdef for a timing test. 5 | 6 | % Written by Tom Minka 7 | 8 | U = cholproj(A); 9 | iU = inv_triu(U); 10 | x = iU*iU'; 11 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/inv_triu.m: -------------------------------------------------------------------------------- 1 | function x = inv_triu(U) 2 | % INV_TRIU Invert upper triangular matrix. 3 | 4 | % Singularity test: 5 | % inv_triu([1 1; 0 0]) 6 | 7 | x = solve_triu(U,eye(size(U))); 8 | %x = inv(U); 9 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/invnormcdf.m: -------------------------------------------------------------------------------- 1 | function x = invnormcdf(p) 2 | %INVNORMCDF(P) Normal quantile function 3 | % X = INVNORMCDF(P) returns the P-th quantile of the standard normal distribution. 4 | % In other words, it returns X such that P = NORMCDF(X). 5 | 6 | x = erfinv(2*p-1)*sqrt(2); 7 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/ismember_sorted.m: -------------------------------------------------------------------------------- 1 | function [tf,loc] = ismember_sorted(a,s) 2 | %ISMEMBER_SORTED True for member of sorted set. 3 | % ISMEMBER_SORTED(A,S) for the vector A returns an array of the same size as A 4 | % containing 1 where the elements of A are in the set S and 0 otherwise. 5 | % A and S must be sorted and cannot contain NaN. 6 | % 7 | % [TF,LOC] = ISMEMBER_SORTED(A,S) also returns an index array LOC where 8 | % LOC(i) is the index in S which matches A(i) (highest if there are ties) 9 | % or 0 if there is no such index. 10 | % 11 | % See also ISMEMBER, MATCH_SORTED, INTERSECT_SORTED, SETDIFF_SORTED, UNION_SORTED. 12 | 13 | % Written by Tom Minka 14 | % (c) Microsoft Corporation. All rights reserved. 15 | 16 | % The internal function ismembc comes from ismember.m 17 | % It requires non-sparse arrays. 18 | a = full(a); 19 | s = full(s); 20 | if nargout < 2 21 | tf = ismembc(a,s); 22 | else 23 | loc = ismembc2(a,s); 24 | tf = (loc > 0); 25 | end 26 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/ismember_sorted_rows.m: -------------------------------------------------------------------------------- 1 | function [tf,loc] = ismember_sorted_rows(a,s) 2 | %ISMEMBER_SORTED_ROWS True for member of sorted set of rows. 3 | % TF = ISMEMBER_SORTED_ROWS(A,S) for the matrix A returns a column vector TF 4 | % where TF(i) = 1 if A(i,:) is in S and 0 otherwise. 5 | % A and S must be row-sorted and cannot contain NaN. 6 | % 7 | % [TF,LOC] = ISMEMBER_SORTED_ROWS(A,S) also returns an index array LOC where 8 | % LOC(i) is the index in S which matches A(i) (highest if there are ties) 9 | % or 0 if there is no such index. 10 | % 11 | % See also ISMEMBER, MATCH_SORTED_ROWS, INTERSECT_SORTED_ROWS, SETDIFF_SORTED_ROWS, UNION_SORTED_ROWS. 12 | 13 | % Written by Tom Minka 14 | % (c) Microsoft Corporation. All rights reserved. 15 | 16 | if nargout < 2 17 | tf = ismember(a,s,'rows'); 18 | else 19 | [tf,loc] = ismember(a,s,'rows'); 20 | end 21 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/isposdef.m: -------------------------------------------------------------------------------- 1 | function b = isposdef(a) 2 | % ISPOSDEF Test for positive definite matrix. 3 | % ISPOSDEF(A) returns 1 if A is positive definite, 0 otherwise. 4 | % Using chol is much more efficient than computing eigenvectors. 5 | 6 | % Written by Tom Minka 7 | 8 | [R,p] = chol(a); 9 | b = (p == 0); 10 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/logdet.m: -------------------------------------------------------------------------------- 1 | function y = logdet(A) 2 | %LOGDET Logarithm of determinant for positive-definite matrix 3 | % logdet(A) returns log(det(A)) where A is positive-definite. 4 | % This is faster and more stable than using log(det(A)). 5 | % Note that logdet does not check if A is positive-definite. 6 | % If A is not positive-definite, the result will not be the same as log(det(A)). 7 | 8 | % Written by Tom Minka 9 | % (c) Microsoft Corporation. All rights reserved. 10 | 11 | U = chol(A); 12 | y = 2*sum(log(diag(U))); 13 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/logmulexp.m: -------------------------------------------------------------------------------- 1 | function s = logmulexp(a,b) 2 | %LOGMULEXP Matrix multiply in the log domain. 3 | % logmulexp(a,b) returns log(exp(a)*exp(b)) while avoiding numerical underflow. 4 | % The * is matrix multiplication. 5 | 6 | % Written by Tom Minka 7 | % (c) Microsoft Corporation. All rights reserved. 8 | 9 | s = repmat(a,cols(b),1) + kron(b',ones(rows(a),1)); 10 | s = reshape(logsumexp(s,2),rows(a),cols(b)); 11 | 12 | %s = kron(a',ones(1,cols(b))) + repmat(b,1,rows(a)); 13 | %s = reshape(logsumexp(s),cols(b),rows(a))'; 14 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/logsumexp.m: -------------------------------------------------------------------------------- 1 | function s = logsumexp(a, dim) 2 | % Returns log(sum(exp(a),dim)) while avoiding numerical underflow. 3 | % Default is dim = 1 (columns). 4 | % logsumexp(a, 2) will sum across rows instead of columns. 5 | % Unlike matlab's "sum", it will not switch the summing direction 6 | % if you provide a row vector. 7 | 8 | % Written by Tom Minka 9 | % (c) Microsoft Corporation. All rights reserved. 10 | 11 | if nargin < 2 12 | dim = 1; 13 | end 14 | 15 | % subtract the largest in each column 16 | [y, i] = max(a,[],dim); 17 | dims = ones(1,ndims(a)); 18 | dims(dim) = size(a,dim); 19 | a = a - repmat(y, dims); 20 | s = y + log(sum(exp(a),dim)); 21 | i = find(~isfinite(y)); 22 | if ~isempty(i) 23 | s(i) = y(i); 24 | end 25 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/match.m: -------------------------------------------------------------------------------- 1 | function loc = match(x,tab) 2 | %MATCH Location of matches in a set. 3 | % MATCH(x,tab) returns loc such that tab(loc(i)) = x(i). 4 | % If x(i) is not in tab, loc(i) = 0. 5 | % 6 | % This function is a special case of ISMEMBER. 7 | 8 | [dummy,loc] = ismember(x,tab); 9 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/match_sorted.m: -------------------------------------------------------------------------------- 1 | function loc = match_sorted(a,s) 2 | %MATCH_SORTED Location of matches in a sorted set. 3 | % MATCH_SORTED(A,S) returns LOC such that S(LOC(i)) = A(i). 4 | % If A(i) is not in S, LOC(i) = 0. 5 | % S must be sorted and unique. 6 | % 7 | % This function is a special case of ISMEMBER_SORTED. 8 | 9 | % Written by Tom Minka 10 | % (c) Microsoft Corporation. All rights reserved. 11 | 12 | loc = ismembc2(a,s); 13 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/match_sorted_rows.m: -------------------------------------------------------------------------------- 1 | function loc = match_sorted_rows(a,s) 2 | %MATCH_SORTED_ROWS Location of matches in sorted rows. 3 | % MATCH_SORTED_ROWS(A,S) returns LOC such that S(LOC(i),:) = A(i,:). 4 | % If A(i,:) is not in S, LOC(i) = 0. 5 | % S must be sorted and unique. 6 | % 7 | % This function is a special case of ISMEMBER_SORTED_ROWS. 8 | 9 | % Written by Tom Minka 10 | % (c) Microsoft Corporation. All rights reserved. 11 | 12 | [tf,loc] = ismember_sorted_rows(a,s); 13 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/mexutil.h: -------------------------------------------------------------------------------- 1 | #include "mex.h" 2 | 3 | mxArray *mxCreateNumericArrayE(mwSize ndim, const mwSize *dims, 4 | mxClassID classid, mxComplexity ComplexFlag); 5 | mxArray *mxCreateNumericMatrixE(mwSize m, mwSize n, mxClassID classid, 6 | mxComplexity ComplexFlag); 7 | mxArray *mxCreateDoubleMatrixE(mwSize m, mwSize n, 8 | mxComplexity ComplexFlag); 9 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/mexutil.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/mexutil.obj -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/mysqueeze.m: -------------------------------------------------------------------------------- 1 | function x = mysqueeze(x) 2 | % Like squeeze(x), but row vectors become columns. 3 | 4 | % Written by Thomas P Minka 5 | 6 | s = size(x); 7 | dim = find(s==1); 8 | if ~isempty(dim) 9 | s(dim) = []; 10 | % [1 1] handles special cases 11 | x = reshape(x,[s 1 1]); 12 | end 13 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/ndgridmat.m: -------------------------------------------------------------------------------- 1 | function x = ndgridmat(varargin) 2 | %NDGRIDMAT Matrix of grid points. 3 | % y = NDGRIDMAT(x1,x2,...) returns one matrix containing all grid points 4 | % as rows. It is the same as concatenating the results of NDGRID. 5 | % First dimension varies fastest: 6 | % y(1,:) = [x1(1) x2(1) ...] 7 | % y(2,:) = [x1(2) x2(1) ...] 8 | 9 | % Written by Tom Minka 10 | % (c) Microsoft Corporation. All rights reserved. 11 | 12 | d = length(varargin); 13 | if d == 1 14 | x = varargin{1}(:); 15 | return; 16 | end 17 | 18 | len = zeros(1,d); 19 | for i = 1:d 20 | len(i) = length(varargin{i}); 21 | end 22 | n = prod(len); 23 | x = zeros(n,d); 24 | k = 1; 25 | for i = 1:d 26 | xi = varargin{i}(:); 27 | % might use reparray here 28 | x(:,i) = repmat(kron(xi, ones(k,1)), n/k/len(i), 1); 29 | k = k * len(i); 30 | end 31 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/ndlogsumexp.m: -------------------------------------------------------------------------------- 1 | function x = ndlogsumexp(x,dim) 2 | % NDLOGSUMEXP Sum over multiple dimensions in the log domain. 3 | % ndlogsumexp(X,DIM) sums out the dimensions in DIM (using logsumexp), 4 | % and squeezes the result. 5 | 6 | % Written by Tom Minka 7 | % (c) Microsoft Corporation. All rights reserved. 8 | 9 | sz = size(x); 10 | for i=1:length(dim) 11 | x = logsumexp(x, dim(i)); 12 | end 13 | nbig = prod(sz); 14 | nsmall = prod(size(x)); 15 | addflops((nbig-nsmall)*(1+flops_exp) + nsmall*flops_log); 16 | %x = mysqueeze(x); 17 | sz(dim) = []; 18 | x = reshape(x,[sz 1 1]); 19 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/ndmax.m: -------------------------------------------------------------------------------- 1 | function x = ndmax(x,dim) 2 | % NDMAX Multi-dimensional maximization. 3 | % NDMAX(X,DIM) takes the maximum element along the dimensions in DIM, 4 | % and squeezes the result. 5 | 6 | % Written by Thomas P Minka 7 | % (c) Microsoft Corporation. All rights reserved. 8 | 9 | sz = size(x); 10 | for i=1:length(dim) 11 | x = max(x, [], dim(i)); 12 | end 13 | x = mysqueeze(x); 14 | addflops(2*(prod(sz)-prod(size(x)))); 15 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/ndsum.m: -------------------------------------------------------------------------------- 1 | function x = ndsum(x,dim) 2 | % NDSUM Multi-dimensional summation. 3 | % NDSUM(X,DIM) sums out the dimensions in DIM, and squeezes the result. 4 | 5 | % Written by Tom Minka 6 | % (c) Microsoft Corporation. All rights reserved. 7 | 8 | if 0 9 | % permutation takes too long 10 | x = permute_to_front(x,dim); 11 | sz = size(x); 12 | msz = sz(1:length(dim)); 13 | ksz = sz(length(dim)+1:end); 14 | x = reshape(x,[prod(msz) ksz]); 15 | x = sum(x); 16 | x = mysqueeze(x); 17 | else 18 | sz = size(x); 19 | for i=1:length(dim) 20 | x = sum(x, dim(i)); 21 | end 22 | addflops(prod(sz)-numel(x)); 23 | %x = mysqueeze(x); 24 | sz(dim) = []; 25 | x = reshape(x,[sz 1 1]); 26 | end 27 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/normcdf.m: -------------------------------------------------------------------------------- 1 | function p = normcdf(x,m,s) 2 | %NORMCDF Normal Cumulative Density Function. 3 | % P = NORMCDF(X) returns the probability that a standard normal variate will 4 | % be less than X. 5 | % 6 | % P = NORMCDF(X,M,S) returns the probability that a normal variate with 7 | % mean M and standard deviation S will be less than x. 8 | 9 | if nargin > 1 10 | if nargin == 3 11 | x = (x-m)./s; 12 | else 13 | error('Usage: normcdf(x,m,s)'); 14 | end 15 | end 16 | 17 | p = 0.5*erf(x/sqrt(2)) + 0.5; 18 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/normcdflogit.m: -------------------------------------------------------------------------------- 1 | function e = normcdflogit(x) 2 | % NORMCDFLOGIT log(normcdf/(1-normcdf)) 3 | % More accurate than explicitly evaluating log(normcdf/(1-normcdf)), and 4 | % retains more precision than normcdfln when x is large. 5 | 6 | % Written by Tom Minka 7 | % (c) Microsoft Corporation. All rights reserved. 8 | 9 | e = x; 10 | small = -7; 11 | large = 7; 12 | i = find(x >= small & x <= large); 13 | if ~isempty(i) 14 | e(i) = normcdf(x(i)); 15 | e(i) = log(e(i)./(1-e(i))); 16 | end 17 | i = find(x < small); 18 | if ~isempty(i) 19 | e(i) = normcdfln(x(i)); 20 | %e(i) = e(i) - log(1-exp(e(i))); 21 | end 22 | i = find(x > large); 23 | if ~isempty(i) 24 | e(i) = -normcdfln(-x(i)); 25 | %e(i) = log(1-exp(-e(i))) + e(i); 26 | end 27 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/randbeta.m: -------------------------------------------------------------------------------- 1 | function x = randbeta(a,b) 2 | % RANDBETA Sample from Beta distribution 3 | % 4 | % X = RANDBETA(A,B) returns a matrix, the same size as A and B, where X(i,j) 5 | % is sampled from a Beta(A(i,j),B(i,j)) distribution. 6 | % A or B can be scalar when the other is a matrix, otherwise they must be 7 | % the same size. 8 | 9 | if length(a) == 1 10 | a = repmat(a,size(b)); 11 | elseif length(b) == 1 12 | b = repmat(b,size(a)); 13 | end 14 | x = randgamma(a); 15 | x = x./(x + randgamma(b)); 16 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/randbinom.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/randbinom.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/randgamma.m: -------------------------------------------------------------------------------- 1 | function x = randgamma(a) 2 | % RANDGAMMA Sample from Gamma distribution 3 | % 4 | % X = RANDGAMMA(A) returns a matrix, the same size as A, where X(i,j) 5 | % is a sample from a Gamma(A(i,j)) distribution. 6 | % 7 | % Gamma(a) has density function p(x) = x^(a-1)*exp(-x)/gamma(a). 8 | 9 | % This function is implemented in MEX (randgamma.c) 10 | error('You must run install_lightspeed first'); 11 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/randgamma.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/randgamma.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/random.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | Rand 3 | ResetSeed 4 | SetSeed 5 | GetSeed 6 | RandN 7 | GammaRand 8 | BinoRand 9 | BetaRand 10 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/random.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/random.dll -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/random.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/random.exp -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/random.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/random.lib -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/random.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/random.obj -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/randomseed.m: -------------------------------------------------------------------------------- 1 | function seed = randomseed(seed) 2 | % RANDOMSEED Get or set the random seed. 3 | % SEED = RANDOMSEED returns the current random seed for lightspeed random 4 | % number routines. SEED is a vector of 3 integers. 5 | % RANDOMSEED(NEW_SEED) sets a new random seed. 6 | % The seed determines the sequence of numbers that will be generated. 7 | % Only the routines randgamma, randbinom, and sample_hist are affected. 8 | % 9 | % Example: 10 | % randomseed([4 5 6]) 11 | % randgamma(repmat(3,1,3)) % 3 random numbers 12 | % randomseed([4 5 6]) 13 | % randgamma(repmat(3,1,3)) % the same 3 numbers 14 | 15 | error('You must first run install_lightspeed.m'); 16 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/randomseed.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/randomseed.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/randwishart.m: -------------------------------------------------------------------------------- 1 | function cholX = randwishart(a,d) 2 | %RANDWISHART Sample from Wishart distribution. 3 | % 4 | % cholX = RANDWISHART(A,D) returns a DxD upper triangular matrix such that 5 | % cholX'*cholX is a sample from a Wishart distribution with shape parameter 6 | % A and unit scale. 7 | % 8 | % The probability density function has the form: 9 | % p(X) = |X|^(a-(d+1)/2)*exp(-tr(X))/Gamma_d(a) 10 | % where Gamma_d is the multivariate Gamma function. 11 | 12 | % Written by Tom Minka 13 | % (c) Microsoft Corporation. All rights reserved. 14 | 15 | sqrth = 0.70710678118655; % sqrt(0.5) 16 | cholX = triu(randn(d,d))*sqrth; 17 | i = 0:(d-1); 18 | cholX(finddiag(cholX)) = sqrt(randgamma(a - i*0.5)); 19 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/repmat.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/repmat.log -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/repmat.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/repmat.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/row_sum.m: -------------------------------------------------------------------------------- 1 | function s = row_sum(x) 2 | % ROW_SUM Sum for each row. 3 | % A faster and more readable alternative to sum(x,2). 4 | 5 | % unfortunately, this removes any sparseness of x. 6 | s = x*ones(cols(x),1); 7 | 8 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/rows.m: -------------------------------------------------------------------------------- 1 | function r = rows(x) 2 | % ROWS The number of rows. 3 | % ROWS is a more readable alternative to size(x,1). 4 | r = size(x,1); 5 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/sameobject.c: -------------------------------------------------------------------------------- 1 | /* mex sameobject.c 2 | */ 3 | /* Written by Tom Minka 4 | * (c) Microsoft Corporation. All rights reserved. 5 | */ 6 | 7 | #include "mex.h" 8 | 9 | void mexFunction(int nlhs, mxArray *plhs[], 10 | int nrhs, const mxArray *prhs[]) 11 | { 12 | double *p; 13 | if(nrhs != 2) { 14 | mexErrMsgTxt("usage: sameobject(a,b)"); 15 | } 16 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 17 | p = mxGetPr(plhs[0]); 18 | *p = (mxGetData(prhs[0]) == mxGetData(prhs[1])); 19 | } 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/sameobject.m: -------------------------------------------------------------------------------- 1 | %SAMEOBJECT Object identity 2 | % SAMEOBJECT(A,B) returns 1 if A and B are the same object. 3 | % Specifically, whether their data pointers are the same. 4 | % 5 | % For example: 6 | % a = 4; 7 | % b = a; 8 | % sameobject(a,b) % returns 1 9 | % sameobject(a,4) % returns 0 10 | 11 | % Written by Thomas P Minka 12 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/sameobject.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/sameobject.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/sample_hist.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/sample_hist.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/sample_vector.m: -------------------------------------------------------------------------------- 1 | function x = sample_vector(p,col) 2 | %SAMPLE_VECTOR Sample from multiple categorical distributions. 3 | % X = SAMPLE_VECTOR(P) returns a row vector of cols(P) integers, where 4 | % X(I) = SAMPLE(P(:,I)). 5 | % 6 | % X = SAMPLE_VECTOR(P,COL) returns a row vector of length(COL) integers, where 7 | % X(I) = SAMPLE(P(:,COL(I))). 8 | % This is equivalent to SAMPLE_VECTOR(P(:,COL)), but faster. 9 | 10 | % Written by Tom Minka 11 | % (c) Microsoft Corporation. All rights reserved. 12 | 13 | cdf = cumsum(p); 14 | if nargin >= 2 15 | cdf = cdf(:,col); 16 | end 17 | if any(cdf(end,:) <= 0) 18 | error('distribution is all zeros'); 19 | end 20 | u = rand(1,cols(cdf)).*cdf(end,:); 21 | x = col_sum(cdf < repmat(u,rows(cdf),1)) + 1; 22 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/scale_cols.m: -------------------------------------------------------------------------------- 1 | function y = scale_cols(x, s) 2 | % SCALE_COLS Scale each column of a matrix. 3 | % SCALE_COLS(x,s) returns matrix y, same size as x, such that 4 | % y(:,i) = x(:,i)*s(i) 5 | % It is more efficient than x*diag(s), but consumes a similar amount of memory. 6 | % Warning: It consumes a lot of memory when x is sparse. 7 | 8 | y = x.*repmat(s(:).', rows(x), 1); 9 | %y = x.*(ones(rows(x),1)*s(:)'); 10 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/scale_rows.m: -------------------------------------------------------------------------------- 1 | function y = scale_rows(x,s) 2 | % SCALE_ROWS Scale each row of a matrix. 3 | % SCALE_ROWS(x,s) returns matrix y, same size as x, such that 4 | % y(i,:) = s(i)*x(i,:) 5 | % It is more efficient than diag(s)*x. 6 | 7 | y = repmat(s(:), 1, cols(x)).*x; 8 | %y = (s(:)*ones(1,cols(x))).*x; 9 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/setdiag.m: -------------------------------------------------------------------------------- 1 | function A = setdiag(A,v,k) 2 | %SETDIAG Modify the diagonal(s) of a matrix. 3 | % SETDIAG(A,V) returns a copy of A where the main diagonal is set to V. 4 | % V can be a scalar or vector. 5 | % SETDIAG(A,V,K) sets the K-th diagonal to V. The K-th diagonal has length 6 | % N-ABS(K). 7 | % 8 | % See also DIAG, FINDDIAG. 9 | 10 | % Written by Tom Minka 11 | % (c) Microsoft Corporation. All rights reserved. 12 | 13 | if nargin < 3 14 | k = 0; 15 | end 16 | A(finddiag(A,k)) = v; 17 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/setdiff_sorted.m: -------------------------------------------------------------------------------- 1 | function c = setdiff_sorted(a,b) 2 | %SETDIFF_SORTED Set difference between sorted sets. 3 | % SETDIFF_SORTED(A,B) when A and B are vectors returns the values 4 | % in A that are not in B. A and B must be sorted and unique, and the result 5 | % will be sorted and unique. 6 | 7 | c = a(~ismember_sorted(a,b)); 8 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/setnonzeros.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/setnonzeros.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/shortsize.m: -------------------------------------------------------------------------------- 1 | function s = shortsize(x) 2 | % shortsize(x) returns a vector of the non-unit dimensions of x. 3 | % 4 | % Examples: 5 | % shortsize(1:n) = n 6 | % shortsize((1:n)') = n 7 | % shortsize(zeros(4,1,2)) = [4 2] 8 | % shortsize([]) = [0 0] 9 | 10 | s = size(x); 11 | s(s==1) = []; 12 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/sizeJava.m: -------------------------------------------------------------------------------- 1 | function sz = sizeJava(jv) 2 | % sizeJava(jv) returns the size of a java array, in a manner corresponding 3 | % to 'size' on matlab arrays. 4 | 5 | % Written by Tom Minka 6 | % (c) Microsoft Corporation. All rights reserved. 7 | 8 | sz(1) = size(jv,1); 9 | sz(2) = size(jv(1,:),1); 10 | if sz(2) == 0 11 | % workaround matlab's bug 12 | sz(2) = 1; 13 | end 14 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/solve_tril.m: -------------------------------------------------------------------------------- 1 | function x = solve_tril(T,b) 2 | % SOLVE_TRIL Left division by lower triangular matrix. 3 | % SOLVE_TRIL(T,b) is the same as T\b but requires T to be lower triangular 4 | % and runs faster. 5 | 6 | error('You must run install_lightspeed in order to use this function.') 7 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/solve_tril.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/solve_tril.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/solve_triu.m: -------------------------------------------------------------------------------- 1 | function x = solve_triu(T,b) 2 | % SOLVE_TRIU Left division by upper triangular matrix. 3 | % SOLVE_TRIU(T,b) is the same as T\b but requires T to be upper triangular 4 | % and runs faster. 5 | 6 | error('You must run install_lightspeed in order to use this function.') 7 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/solve_triu.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/solve_triu.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/sqdist.m: -------------------------------------------------------------------------------- 1 | function m = sqdist(p, q, A) 2 | % SQDIST Squared Euclidean or Mahalanobis distance. 3 | % SQDIST(p,q) returns m(i,j) = (p(:,i) - q(:,j))'*(p(:,i) - q(:,j)). 4 | % SQDIST(p,q,A) returns m(i,j) = (p(:,i) - q(:,j))'*A*(p(:,i) - q(:,j)). 5 | 6 | % Written by Tom Minka 7 | 8 | [d, pn] = size(p); 9 | [d, qn] = size(q); 10 | 11 | if pn == 0 || qn == 0 12 | m = zeros(pn,qn); 13 | return 14 | end 15 | 16 | if nargin == 2 17 | 18 | pmag = col_sum(p .* p); 19 | qmag = col_sum(q .* q); 20 | m = repmat(qmag, pn, 1) + repmat(pmag', 1, qn) - 2*p'*q; 21 | %m = ones(pn,1)*qmag + pmag'*ones(1,qn) - 2*p'*q; 22 | 23 | else 24 | 25 | Ap = A*p; 26 | Aq = A*q; 27 | pmag = col_sum(p .* Ap); 28 | qmag = col_sum(q .* Aq); 29 | m = repmat(qmag, pn, 1) + repmat(pmag', 1, qn) - 2*p'*Aq; 30 | 31 | end 32 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/struct2arglist.m: -------------------------------------------------------------------------------- 1 | function c = struct2arglist(s) 2 | %STRUCT2ARGLIST Convert structure to cell array of fields/values. 3 | % STRUCT2ARGLIST(S) returns a cell array {'field1',value1,'field2',value2,...} 4 | % It is the opposite of MAKESTRUCT. 5 | % 6 | % Example: 7 | % function f(varargin) 8 | % opt.FontSize = 10; 9 | % opt = setfields(opt,makestruct(varargin),'ignore'); 10 | % varargin = struct2arglist(opt); 11 | % g(varargin{:}); 12 | % 13 | % See also MAKESTRUCT. 14 | 15 | % Written by Tom Minka 16 | % (c) Microsoft Corporation. All rights reserved. 17 | 18 | f = fieldnames(s); 19 | c = cell(1,2*length(f)); 20 | for i = 1:length(f) 21 | c{2*i-1} = f{i}; 22 | c{2*i} = s.(f{i}); 23 | end 24 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/subv2ind.m: -------------------------------------------------------------------------------- 1 | function index = subv2ind(siz,sub) 2 | %SUBV2IND Linear index from subscript vector. 3 | % SUBV2IND(SIZ,SUB) returns an equivalent single index corresponding to a 4 | % subscript vector for an array of size SIZ. 5 | % If SUB is a matrix, with subscript vectors as rows, then the result is a 6 | % column vector. 7 | % 8 | % This is the opposite of IND2SUBV, so that 9 | % SUBV2IND(SIZ,IND2SUBV(SIZ,IND)) == IND. 10 | % 11 | % See also IND2SUBV, SUB2IND. 12 | 13 | % Written by Tom Minka 14 | % Part of Tom Minka's lightspeed package. 15 | % (c) Microsoft Corporation. All rights reserved. 16 | 17 | prev_cum_size = [1 cumprod(siz(1:end-1))]; 18 | %index = (sub-1)*prev_cum_size' + 1; 19 | index = sub*prev_cum_size' - sum(prev_cum_size) + 1; 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_digamma.m: -------------------------------------------------------------------------------- 1 | x = [9 2.140641477955609996536345; ... 2 | 2.5 0.7031566406452431872257; ... 3 | 0.1 -10.42375494041107679516822; ... 4 | 7e-4 -1429.147493371120205005198; ... 5 | 7e-5 -14286.29138623969227538398; ... 6 | 7e-6 -142857.7200612932791081972; ... 7 | 2e-6 -500000.5772123750382073831; ... 8 | 1e-6 -1000000.577214019968668068; ... 9 | 7e-7 -1428572.005785942019703646; ... 10 | -0.5 .03648997397857652055902367; ... 11 | -1.1 10.15416395914385769902271 ... 12 | ]; 13 | for i = 1:rows(x) 14 | actual = digamma(x(i,1)); 15 | expected = x(i,2); 16 | e = abs(actual - expected)/expected; 17 | if e > 1e-12 18 | error(['digamma(' x(i,1) ') = ' actual ' should be ' expected]) 19 | end 20 | end 21 | if digamma(-1) ~= -Inf 22 | error('digamma(-1) should be -Inf'); 23 | end 24 | if digamma(0) ~= -Inf 25 | error('digamma(0) should be -Inf'); 26 | end 27 | if ~isnan(digamma(-Inf)) 28 | error('digamma(-Inf) should be NaN'); 29 | end 30 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_duplicated.m: -------------------------------------------------------------------------------- 1 | % demonstrates the difference in speed between duplicated and unique. 2 | 3 | tim = []; 4 | for iter = 1:100 5 | x = [1:100 1:100]'; 6 | tic;for iter2 = 1:100;u1=unique(x);end;tim(1,iter)=toc; 7 | tic;for iter2 = 1:100;u=x(~duplicated(x));end;tim(2,iter)=toc; 8 | assert(isequal(u1,u)); 9 | 10 | x = reshape(x,10,20)'; 11 | tic;for iter2 = 1:100;u1=unique(x,'rows');end;tim(3,iter)=toc; 12 | tic;for iter2 = 1:100;u=x(~duplicated(x),:);end;tim(4,iter)=toc; 13 | assert(isequal(u1,u)); 14 | end 15 | tim = row_sum(tim); 16 | fprintf(' unique: %gs\nduplicated: %gs\n unique rows: %gs\nduplicated rows: %gs\n',tim); 17 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_int_hist.m: -------------------------------------------------------------------------------- 1 | M = [repmat(1:10,1,10) 7*ones(1,17) 57]; 2 | 3 | niter = 1000; 4 | tic; for i = 1:niter int_hist(M); end; toc 5 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_inv_posdef.m: -------------------------------------------------------------------------------- 1 | N = 100; 2 | niter = 100; 3 | A = rand(N); 4 | A = A*A'; 5 | tic; for i = 1:niter inv(A); end; t1=toc; 6 | tic; for i = 1:niter inv_posdef(A); end; t2=toc; 7 | fprintf('inv: \t%g\ninv_posdef: \t%g (%g times faster)\n',t1,t2,t1/t2); 8 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_java.m: -------------------------------------------------------------------------------- 1 | fromJava(toJava(7)) 2 | fromJava(toJava(7:10)) 3 | fromJava(toJava('hello')) 4 | fromJava(toJava([])) 5 | fromJava(toJava({'hello' 7})) 6 | fromJava(toJava({})) 7 | fromJava(toJava(struct('x',3,'y',4))) 8 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_lightspeed.m: -------------------------------------------------------------------------------- 1 | disp('Starting tests...') 2 | test_digamma 3 | test_gammaln 4 | test_trigamma 5 | test_int_hist 6 | %test_inv_posdef 7 | test_java 8 | test_logmulexp 9 | test_logsumexp 10 | test_mutable 11 | %test_ndsum 12 | %test_normcdf 13 | test_normpdf 14 | test_randgamma 15 | test_randbeta 16 | test_randbinom 17 | test_randwishart 18 | test_repmat 19 | test_row_sum 20 | test_sameobject 21 | test_scale 22 | test_solve_tri 23 | test_sorted 24 | test_sparse 25 | test_sqdist 26 | disp('All tests completed') 27 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_logmulexp.m: -------------------------------------------------------------------------------- 1 | a = rand(3,1); 2 | b = rand(1,4); 3 | 4 | log(exp(a)*exp(b)) 5 | logmulexp(a,b) 6 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_logsumexp.m: -------------------------------------------------------------------------------- 1 | x = [-Inf; -Inf]; 2 | if(logsumexp(x) ~= -Inf) 3 | error('logsumexp([-Inf; -Inf]) should be -Inf'); 4 | end 5 | %logsumexpv(x) 6 | 7 | x = rand(1000,1); 8 | tic; for iter = 1:1000 logsumexp(x); end; toc 9 | %tic; for iter = 1:1000 logsumexpv(x); end; toc 10 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_matfile.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/tests/test_matfile.mat -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_max.m: -------------------------------------------------------------------------------- 1 | tim = []; 2 | for k = 1:6 3 | x = rand(1,1024*k/2); 4 | %x = 1:(1024*k/4); 5 | niter = floor(12000/k); 6 | 7 | %tic; for i = 1:niter ismembc(b,a); end; tim(k,1) = toc; 8 | tic; for i = 1:niter max(x); end; tim(k,1) = toc; 9 | tic; for i = 1:niter min(x); end; tim(k,2) = toc; 10 | tic; for i = 1:niter all(x); end; tim(k,3) = toc; 11 | tic; for i = 1:niter any(x); end; tim(k,4) = toc; 12 | tic; for i = 1:niter x+x; end; tim(k,5) = toc; 13 | end 14 | figure(1),clf 15 | plot(tim) 16 | xlabel('trial') 17 | ylabel('time (sec)') 18 | legend('max','min','all','any','plus'); 19 | %tim(end,1) 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_mutable.m: -------------------------------------------------------------------------------- 1 | x = mutable; 2 | x(1) = 5; 3 | y = x; 4 | x(1) = 4; 5 | if y(1) ~= 4 6 | error('y(1) ~= 4') 7 | end 8 | 9 | x = mutable(struct); 10 | y = x; 11 | x.a = 4; 12 | if y.a ~= 4 13 | error('y.a ~= 4') 14 | end 15 | fprintf('Test passed.\n'); 16 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_ndsum.m: -------------------------------------------------------------------------------- 1 | x = rand([2 3 4]); 2 | maxdiff(ndsum(x,[1 3]),ndsumC(x,[1 3])) 3 | 4 | if 1 5 | % special cases 6 | maxdiff(ndsum(x,1:3),ndsumC(x,1:3)) 7 | maxdiff(ndsum(x,[]),ndsumC(x,[])) 8 | end 9 | 10 | tim = []; 11 | for k = 1:3 12 | sz = repmat(10*k,1,5); 13 | x = rand(sz); 14 | niter = floor(20/k); 15 | 16 | %tic; for i = 1:niter sum(x,4); end; tim(k,3) = toc; 17 | tic; for i = 1:niter ndsum(x,[2 4]); end; tim(k,1) = toc; 18 | tic; for i = 1:niter ndsumC(x,[2 4]); end; tim(k,2) = toc; 19 | end 20 | figure(1) 21 | clf 22 | plot(tim) 23 | xlabel('trial') 24 | ylabel('time (sec)') 25 | %legend('ndsum', 'ndsumC', 'sum', 2) 26 | legend('ndsum', 'ndsumC', 2) 27 | axis_pct 28 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_randbeta.m: -------------------------------------------------------------------------------- 1 | a=randbeta(1,ones(1,100000)); 2 | histc(a,0:.2:1) 3 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_randbinom.m: -------------------------------------------------------------------------------- 1 | % Computes the speed difference between Matlab's binornd and 2 | % Lightspeed's randbinom. 3 | 4 | if ~exist('binornd') 5 | disp('binornd not found. skipping test_randbinom.'); 6 | else 7 | 8 | p = 0.13; 9 | n = 123; 10 | tim = []; 11 | 12 | nsamples = 1e4; 13 | y = zeros(nsamples,1); 14 | tic 15 | for i = 1:nsamples 16 | y(i) = randbinom(p,n); 17 | end 18 | tim(1) = toc; 19 | %g = int_hist(y+1,n+1)/nsamples; 20 | tic 21 | for i = 1:nsamples 22 | y(i) = binornd(n,p); 23 | end 24 | tim(2) = toc; 25 | fprintf('Time for binornd: %g\n', tim(2)); 26 | fprintf('Time for randbinom: %g (%g times faster)\n', tim(1), tim(2)/tim(1)); 27 | 28 | if 0 29 | % test validity of the sampler (use nsamples = 1e5) 30 | x = 0:n; 31 | f = binopdf(x,n,p); 32 | plot(x,f,x,g) 33 | legend('true','estimated') 34 | end 35 | 36 | end 37 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_randgamma.m: -------------------------------------------------------------------------------- 1 | a = 3.75; 2 | x = randgamma(repmat(a,1,10000)); 3 | 4 | % E[x] 5 | mean(x) 6 | a 7 | 8 | % E[log(x)] 9 | mean(log(x)) 10 | digamma(a) 11 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_randomseed.m: -------------------------------------------------------------------------------- 1 | randomseed(0); 2 | x = randgamma(repmat(3,1,3)); 3 | randomseed(0); 4 | x2 = randgamma(repmat(3,1,3)); 5 | assert(all(x == x2)); 6 | seed = randomseed; 7 | x = randgamma(repmat(3,1,3)); 8 | randomseed([4 5 6]); 9 | randomseed(seed); 10 | x2 = randgamma(repmat(3,1,3)); 11 | assert(all(x == x2)); 12 | fprintf('randomseed test passed.\n'); 13 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_randwishart.m: -------------------------------------------------------------------------------- 1 | N = 10000; 2 | a = 2.7; 3 | d = 3; 4 | m = zeros(d,d); 5 | m2 = zeros(d,d); 6 | s = 0; 7 | for i = 1:N 8 | L = randwishart(a,d); 9 | X = L'*L; 10 | m = m + X; 11 | s = s + logdet(X); 12 | m2 = m2 + X.*X; 13 | end 14 | i = 0:(d-1); 15 | sTrue = sum(digamma(a - i*0.5)); 16 | m = m/N; 17 | s = s/N; 18 | v = m2/N - m.*m; 19 | fprintf('Wishart(%g) mean: (should be %g*I)\n', a, a); 20 | disp(m) 21 | fprintf(' E[logdet]: %g (should be %g)\n', s, sTrue); 22 | vTrue = a*(eye(d) + 1)/2; 23 | fprintf('variance:\t\t\t\t\t\t\t\t\ttrue:\n'); 24 | disp([v vTrue]) 25 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_repmat_struct.m: -------------------------------------------------------------------------------- 1 | % thanks to Marek Petrik for finding this bug 2 | a.state = 1; 3 | a.action = 0; 4 | x = repmat(a, 1, 10); 5 | if length(fieldnames(x)) ~= 2 6 | error('repmat struct failed') 7 | end 8 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_row_sum.m: -------------------------------------------------------------------------------- 1 | % timing test for row_sum 2 | 3 | % each trial should take the same amount of time 4 | % if not, then you are not managing the cache properly 5 | tim = []; 6 | for k = 1:6 7 | x = randn(1024*k/4, 400); 8 | niter = floor(120/k); 9 | 10 | tic; for i = 1:niter sum(x,2); end; tim(k,1) = toc; 11 | tic; for i = 1:niter row_sum(x); end; tim(k,2) = toc; 12 | tic; for i = 1:niter x*ones(cols(x),1); end; tim(k,3) = toc; 13 | tic; for i = 1:niter sum(x')'; end; tim(k,4) = toc; 14 | end 15 | figure(1) 16 | clf 17 | plot(tim) 18 | xlabel('trial') 19 | ylabel('time (sec)') 20 | legend('sum(x,2)', 'rowsum', 'product', 'sum(x'')''', 2) 21 | tim(end,1) 22 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_sameobject.m: -------------------------------------------------------------------------------- 1 | function test_sameobject 2 | % Result should be 1 in both cases below. 3 | 4 | a = rand(4); 5 | b = a; 6 | if sameobject(a,b) ~= 1 7 | error('failed'); 8 | end 9 | if helper(a,a) ~= 1 10 | error('failed'); 11 | end 12 | disp('Test passed.') 13 | 14 | function x = helper(a,b) 15 | 16 | x = sameobject(a,b); 17 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_sample.m: -------------------------------------------------------------------------------- 1 | d = 10; 2 | p = rand(d,1); 3 | ns = ceil(10.^linspace(0,4,20)); 4 | for i = 1:length(ns) 5 | n = ns(i); 6 | tic 7 | for iter = 1:10 8 | x = sample(p,n); 9 | end 10 | tim(i) = toc; 11 | end 12 | loglog(ns,tim,'-',ns,tim,'.'); 13 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_scale.m: -------------------------------------------------------------------------------- 1 | d = 500; 2 | A = randn(d); 3 | b = randn(d,1); 4 | niter = 100; 5 | fprintf('cols:') 6 | tic; for i = 1:niter scale_cols(A,b); end; toc 7 | fprintf('rows:') 8 | tic; for i = 1:niter scale_rows(A,b); end; toc 9 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_sorted.m: -------------------------------------------------------------------------------- 1 | % demonstrates the difference in speed between sorted and non-sorted set 2 | % operations. 3 | 4 | tim = []; 5 | for iter = 1:100 6 | a = 1:10; 7 | s = 1:1000; 8 | tic;for iter2=1:100;tf1=ismember(a,s);end;tim(1,iter)=toc; 9 | tic;for iter2=1:100;tf=ismember_sorted(a,s);end;tim(2,iter)=toc; 10 | if ~all(tf==tf1) 11 | error('ismember_sorted failed') 12 | end 13 | 14 | tic;for iter2=1:100;tf1=setdiff(a,s);end;tim(3,iter)=toc; 15 | tic;for iter2=1:100;tf=setdiff_sorted(a,s);end;tim(4,iter)=toc; 16 | if ~all(tf==tf1) 17 | error('setdiff_sorted failed') 18 | end 19 | end 20 | tim = row_sum(tim); 21 | fprintf(' ismember: %gs\nismember_sorted: %gs (%g times faster)\n setdiff: %gs\nsetdiff_sorted: %gs (%g times faster)\n',[tim(1) tim(2) tim(1)/tim(2) tim(3) tim(4) tim(3)/tim(4)]); 22 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_sparse.m: -------------------------------------------------------------------------------- 1 | if 0 2 | s = sparse([1 2],[1 2],[2 3]); 3 | %awf_sparse(int32([1 2]),int32([1 2]),[2 3]) 4 | setnonzeros(s,[4 5]) 5 | return 6 | end 7 | 8 | n = 1000; 9 | s = rand(n,n); 10 | [i,j,v] = find(s); 11 | [m,n] = size(s); 12 | tic, for iter = 1:10, s = sparse(i,j,v,m,n); end; t1=toc; 13 | fprintf('time for sparse = %g\n', t1); 14 | %tic, for iter = 1:10, s = awf_sparse(int32(i),int32(j),v); end; t1=toc; 15 | %fprintf('time for awf_sparse = %g\n', t1); 16 | tic, for iter = 1:10, s = setnonzeros(s,v); end; t2=toc; 17 | fprintf('time for setnonzeros = %g (%g times faster)\n', t2, t1/t2); 18 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_sqdist.m: -------------------------------------------------------------------------------- 1 | x = [1 2; 3 4]; 2 | A = x*x'; 3 | sqdist(x,x) 4 | sqdist(x,x,A) 5 | 6 | niter = 2; 7 | x = randn(300); 8 | A = x*x'; 9 | fprintf('Euclidean:') 10 | tic; for iter = 1:niter sqdist(x,x); end; toc 11 | fprintf('Mahalanobis:') 12 | tic; for iter = 1:niter sqdist(x,x,A); end; toc 13 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tests/test_trigamma.m: -------------------------------------------------------------------------------- 1 | x = [9 .117512014694031425134547; ... 2 | 2.5 .4903577561002348649728011; ... 3 | 0.1 101.4332991507927588172155; ... 4 | 7e-4 2040817.969783389022409943; ... 5 | 7e-5 204081634.2978270192803090; ... 6 | 7e-6 20408163266.95103968719027; ... 7 | 7e-7 2040816326532.257177281929; ... 8 | -0.5 8.934802200544679309417246; ... 9 | -1.1 102.7489862404689390536693 ... 10 | ]; 11 | for i = 1:rows(x) 12 | actual = trigamma(x(i,1)); 13 | expected = x(i,2); 14 | e = abs(actual - expected)/expected; 15 | if e > 1e-12 16 | error(['trigamma(' x(i,1) ') = ' actual ' should be ' expected]) 17 | end 18 | end 19 | if trigamma(-1) ~= -Inf 20 | error('trigamma(-1) should be -Inf'); 21 | end 22 | if trigamma(0) ~= -Inf 23 | error('trigamma(0) should be -Inf'); 24 | end 25 | if ~isnan(trigamma(-Inf)) 26 | error('trigamma(-Inf) should be NaN'); 27 | end 28 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/tetragamma.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/tetragamma.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/trigamma.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/trigamma.mexw64 -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/util.h: -------------------------------------------------------------------------------- 1 | #define mxCopy(a,n,e) memcpy(mxCalloc(n,e), a, (n)*(e)) 2 | 3 | double Rand(void); 4 | double RandN(void); 5 | double GammaRand(double a); 6 | double BetaRand(double a, double b); 7 | int BinoRand(double p, int n); 8 | 9 | void ResetSeed(void); 10 | void SetSeed(long new_ix, long new_iy, long new_iz); 11 | void GetSeed(long *ix_out, long *iy_out, long *iz_out); 12 | 13 | double logSum(double a, double b); 14 | double pochhammer(double x, int n); 15 | double di_pochhammer(double x, int n); 16 | double tri_pochhammer(double x, int n); 17 | double gammaln2(double x, double d); 18 | double gammaln(double x); 19 | double digamma(double x); 20 | double trigamma(double x); 21 | double tetragamma(double x); 22 | 23 | unsigned *ismember_sorted(double *a, unsigned a_len, double *s, unsigned s_len); 24 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/util.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/+lightspeed/util.obj -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/vec.m: -------------------------------------------------------------------------------- 1 | function v = vec(a) 2 | 3 | v = a(:); 4 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/wishpdf.m: -------------------------------------------------------------------------------- 1 | function p = wishpdf(varargin) 2 | %WISHPDF Wishart probability density function. 3 | % WISHPDF(X,A) returns the density at X under a Wishart distribution with 4 | % shape parameter A and unit scale parameter. 5 | % X is a positive definite matrix and A is scalar. 6 | % WISHPDF(X,A,B) specifies the scale parameter of the distribution (a 7 | % positive definite matrix with the same size as X). 8 | % 9 | % The probability density function has the form: 10 | % p(X) = |X|^(a-(d+1)/2)*exp(-tr(X*B))*|B|^a/Gamma_d(a) 11 | % where Gamma_d is the multivariate Gamma function. 12 | % 13 | % WISHPDF(X,A,B,'inv') returns the density at X under an inverse Wishart 14 | % distribution. The probability density function for an inverse Wishart is: 15 | % p(X) = |X|^(-a-(d+1)/2)*exp(-tr(inv(X)*B))*|B|^a/Gamma_d(a) 16 | 17 | % Written by Tom Minka 18 | % (c) Microsoft Corporation. All rights reserved. 19 | 20 | p = exp(wishpdfln(varargin{:})); 21 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/wishpdfln.m: -------------------------------------------------------------------------------- 1 | function lp = wishpdfln(x,a,b,inverse) 2 | %WISHPDFLN Logarithm of Wishart probability density function. 3 | % See WISHPDF for argument description. 4 | 5 | % Written by Tom Minka 6 | % (c) Microsoft Corporation. All rights reserved. 7 | 8 | if nargin < 3 9 | B = []; 10 | end 11 | if nargin < 4 12 | inverse = 0; 13 | end 14 | 15 | if inverse 16 | X = inv(X); 17 | end 18 | if isempty(B) 19 | XB = X; 20 | logDetB = 0; 21 | else 22 | XB = X*B; 23 | logDetB = logdet(B); 24 | end 25 | d = rows(x); 26 | d2 = (d+1)/2; 27 | if inverse 28 | d2 = -d2; 29 | end 30 | logDetXB = (a-d2)*logdet(XB); 31 | lp = logDetXB - trace(XB) + d2*logDetB - gammaln(a,d); 32 | -------------------------------------------------------------------------------- /video background subtraction/libs/+lightspeed/xones.c: -------------------------------------------------------------------------------- 1 | /* Simple test of using initialized vs. uninitialized arrays. 2 | * The uninitialized version runs nearly twice as fast. 3 | */ 4 | /* 5 | mex -c mexutil.c 6 | mex xones.c mexutil.obj 7 | */ 8 | 9 | #include "mexutil.h" 10 | 11 | void mexFunction(int nlhs, mxArray *plhs[], 12 | int nrhs, const mxArray *prhs[]) 13 | { 14 | int m,n,i,sz; 15 | double *p; 16 | if(nrhs != 2) mexErrMsgTxt("xones(m,n)"); 17 | if(mxGetNumberOfElements(prhs[0]) != 1) 18 | mexErrMsgTxt("m is not scalar"); 19 | if(mxGetNumberOfElements(prhs[1]) != 1) 20 | mexErrMsgTxt("n is not scalar"); 21 | m = (int)*mxGetPr(prhs[0]); 22 | n = (int)*mxGetPr(prhs[1]); 23 | sz = m*n; 24 | #if 0 25 | plhs[0] = mxCreateDoubleMatrix(m,n,mxREAL); 26 | p = (double*)mxGetPr(plhs[0]); 27 | #else 28 | plhs[0] = mxCreateDoubleMatrixE(m,n,mxREAL); 29 | p = (double*)mxGetPr(plhs[0]); 30 | #endif 31 | for(i=0;i R{dim1,dim2*dim3} = R{60,80x52} = R{60,4160} 9 | V1 = reshape(V,size(V,1),[]); 10 | % imshow(V1,[]) 11 | 12 | %%% mode-2 matricization (#cols) 13 | % V2 -> R{dim2,dim1*dim3} = R{80,60x52} = R{60,3120} 14 | V2 = permute(V,[2 1 3]); 15 | V2 = reshape(V2,size(V,2),[]); 16 | % imshow(V2,[]) 17 | 18 | %%% mode-3 matricization (#deph) 19 | % V3 -> R{dim3,dim1*dim2} = R{52,60x80} = R{60,4800} 20 | V3 = permute(V,[3 1 2]); 21 | V3 = reshape(V3,size(V,3),[]); 22 | % imshow(V3,[]) 23 | end 24 | 25 | -------------------------------------------------------------------------------- /video background subtraction/libs/mtt/tensor_product.m: -------------------------------------------------------------------------------- 1 | function [C] = tensor_product(A,B) 2 | Au = tensor_unfold(A); 3 | Bu = tensor_unfold(B); 4 | 5 | Auc = circmat(Au,size(A)); 6 | 7 | AucBu = Auc*Bu; 8 | 9 | C = tensor_fold(AucBu,size(A)); 10 | end 11 | 12 | -------------------------------------------------------------------------------- /video background subtraction/libs/mtt/tensor_slices_frontal.m: -------------------------------------------------------------------------------- 1 | %% [A1_] = tensor_slices_frontal(A) 2 | % 3 | function [A1_] = tensor_slices_frontal(A) 4 | [n1, n2, n3] = size(A); 5 | for i = 1:n3 6 | A1_{i} = A(:,:,i); 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /video background subtraction/libs/mtt/tensor_slices_horizontal.m: -------------------------------------------------------------------------------- 1 | %% [A3_] = tensor_slices_horizontal(A) 2 | % 3 | function [A3_] = tensor_slices_horizontal(A) 4 | [n1, n2, n3] = size(A); 5 | for i = 1:n1 6 | a = A(i,:,:); 7 | A3_{i} = reshape(a,[n2 n3]); 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /video background subtraction/libs/mtt/tensor_slices_lateral.m: -------------------------------------------------------------------------------- 1 | %% [A2_] = tensor_slices_lateral(A) 2 | % 3 | function [A2_] = tensor_slices_lateral(A) 4 | [n1, n2, n3] = size(A); 5 | for i = 1:n2 6 | a = A(:,i,:); 7 | A2_{i} = reshape(a,[n1 n3]); 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /video background subtraction/libs/mtt/tensor_t_svd.m: -------------------------------------------------------------------------------- 1 | %% [U,S,V] = tensor_t_svd(A) 2 | % 3 | function [U,S,V] = tensor_t_svd(A) 4 | D = fft(A,[],3); 5 | %D = A; 6 | n3 = size(A,3); 7 | 8 | for i = 1:n3 %nframes 9 | [Ux,Sx,Vx] = svd(D(:,:,i)); 10 | Uy(:,:,i) = Ux; 11 | Sy(:,:,i) = Sx; 12 | Vy(:,:,i) = Vx; 13 | end 14 | 15 | U = ifft(Uy,[],3); 16 | S = ifft(Sy,[],3); 17 | V = ifft(Vy,[],3); 18 | %U = Uy; 19 | %S = Sy; 20 | %V = Vy; 21 | end 22 | -------------------------------------------------------------------------------- /video background subtraction/libs/mtt/tensor_transpose.m: -------------------------------------------------------------------------------- 1 | %% [At] = tensor_transpose(A) 2 | % p-transpose, p<[2 1 3]> 3 | function [At] = tensor_transpose(A) 4 | At = permute(A, [2 1 3]); 5 | end 6 | -------------------------------------------------------------------------------- /video background subtraction/libs/mtt/tensor_tucker_prod.m: -------------------------------------------------------------------------------- 1 | %% [B] = tensor_tucker_prod(A,M) 2 | % 3 | function [B] = tensor_tucker_prod(A,M) 4 | B = A; 5 | for k = 1:length(A.size) 6 | B = ttm(B, M{k}, k); 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /video background subtraction/libs/mtt/tensor_unfold.m: -------------------------------------------------------------------------------- 1 | %% [Au] = tensor_unfold(A) 2 | % 3 | function [Au] = tensor_unfold(A) 4 | [n1, n2, n3] = size(A); 5 | Au = zeros(n1*n3,n2); 6 | idx = 1; 7 | for i = 1:n3 8 | A_{i} = A(:,:,i); 9 | Au(idx:idx+n1-1,:) = A_{i}; 10 | idx = idx + n1; 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /video background subtraction/libs/mtt/tensor_unfolding.m: -------------------------------------------------------------------------------- 1 | %% [An] = tensor_unfolding(A) 2 | % matricization 3 | function [An] = tensor_unfolding(A,mode) 4 | An = double(tenmat(tensor(A),mode)); 5 | end 6 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/.gitattributes: -------------------------------------------------------------------------------- 1 | *.manifest -crlf -diff -merge 2 | *.vcproj binary 3 | *.sln binary 4 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/apps/recognition/extendDescriptorsWithGeometry.m: -------------------------------------------------------------------------------- 1 | function descrs = extendDescriptorsWithGeometry(type, frames, descrs) 2 | % EXTENDDESCRIPTORSWITHGEOMETRY Extend feature descriptors with geometric components 3 | % DESCRS = EXTENDDESCRIPTORSWITHGEOMETRY(TYPE, FRAMES, DESCRS) 4 | % extends the descriptorss DESCRS with either nothing (TYPE = 5 | % 'none') or XY (TYPE = 'xy') from the FRAMES matrix. Note that, 6 | % for this to make sense, DESCRS and FRAMES should be properly normalized. 7 | 8 | % Author: Andrea Vedaldi 9 | 10 | % Copyright (C) 2013 Andrea Vedaldi 11 | % All rights reserved. 12 | % 13 | % This file is part of the VLFeat library and is made available under 14 | % the terms of the BSD license (see the COPYING file). 15 | 16 | 17 | switch lower(type) 18 | case 'none' 19 | case 'xy' 20 | z = frames(1:2,:) ; 21 | descrs = cat(1, descrs, z) ; 22 | otherwise 23 | error('Uknown geometric extension ''%s''.', type) ; 24 | end 25 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/data/box.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/data/box.pgm -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/data/river1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/data/river1.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/data/river2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/data/river2.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/data/roofs1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/data/roofs1.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/data/roofs2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/data/roofs2.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/data/spots.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/data/spots.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/api.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/dtd/xhtml1/xhtml.soc: -------------------------------------------------------------------------------- 1 | OVERRIDE YES 2 | -- Oasis entity catalog for Extensible HTML 1.0 -- 3 | 4 | PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "xhtml1-strict.dtd" 5 | PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "xhtml1-transitional.dtd" 6 | PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "xhtml1-frameset.dtd" 7 | 8 | -- ISO latin 1 entity set for Extensible HTML (XML 1.0 format) -- 9 | 10 | PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "xhtml-lat1.ent" 11 | PUBLIC "-//W3C//ENTITIES Symbols for XHTML//EN" "xhtml-symbol.ent" 12 | PUBLIC "-//W3C//ENTITIES Special for XHTML//EN" "xhtml-special.ent" 13 | 14 | SGMLDECL "xhtml1.dcl" 15 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/PASCAL2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/PASCAL2.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/caltech-collage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/caltech-collage.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/down.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/fulkerson.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/fulkerson.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/git.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/git.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/help.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/lenc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/lenc.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/liop-neighbours-sampling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/liop-neighbours-sampling.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/liop-patch-layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/liop-patch-layout.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/perdoch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/perdoch.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/perrone.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/perrone.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/placeholder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/placeholder.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/sarbortova.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/sarbortova.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/sift-mosaic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/sift-mosaic.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/sulc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/sulc.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-vs-additional-deps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-vs-additional-deps.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-vs-additional-include.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-vs-additional-include.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-vs-additional-libdir.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-vs-additional-libdir.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-vs-all-configurations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-vs-all-configurations.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-vs-empty-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-vs-empty-project.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-vs-new-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-vs-new-project.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-vs-nodll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-vs-nodll.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-vs-ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-vs-ok.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-vs-post-step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-vs-post-step.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-vs-project-properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-vs-project-properties.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-xcode-copy-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-xcode-copy-2.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-xcode-copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-xcode-copy.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-xcode-dylib.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-xcode-dylib.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-xcode-edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-xcode-edit.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-xcode-err.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-xcode-err.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-xcode-info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-xcode-info.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-xcode-new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-xcode-new.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/using-xcode-ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/using-xcode-ok.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/vedaldi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/vedaldi.jpg -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/vl_blue.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/vl_blue.ico -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/vl_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/vl_blue.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/vl_blue.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/vl_blue.pxm -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/vl_blue_large.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/vl_blue_large.pxm -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/images/yandex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/docsrc/images/yandex.png -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/license.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

VLFeat is distributed under the BSD license:

5 |
6 |
7 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/docsrc/notfound.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

The page you attempted to view no longer exists, never existed, or 5 | is not currently available.

6 | 7 |

Try searching for what you need:

8 | 9 | 10 | 11 | 12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/src/check.h: -------------------------------------------------------------------------------- 1 | /** @file check.h 2 | ** @brief Unit test utilties 3 | ** @author Andrea Vedaldi 4 | **/ 5 | 6 | #ifndef __CHECK_H__ 7 | #define __CHECK_H__ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | static void 14 | check_impl (int condition, 15 | const char * file, 16 | int line, 17 | const char * format, ...) 18 | { 19 | va_list args; 20 | va_start(args, format) ; 21 | if (! condition) { 22 | fprintf(stderr, "%s:%d: check failed: ", file, line) ; 23 | vfprintf(stderr, format, args) ; 24 | fprintf(stderr, "\n") ; 25 | exit (1) ; 26 | } 27 | va_end(args) ; 28 | } 29 | 30 | #define check(condition, ...) \ 31 | check_impl(condition, __FILE__, __LINE__, "" __VA_ARGS__) 32 | 33 | #define check_signoff() \ 34 | fprintf(stdout, "%s passed\n", __FILE__) 35 | 36 | /* __CHECK_H__ */ 37 | #endif 38 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/src/test_gauss_elimination.c: -------------------------------------------------------------------------------- 1 | /** file: test_gauss_elimination.cpp */ 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | int 9 | main(int argc VL_UNUSED, char**argv VL_UNUSED) 10 | { 11 | double A [] = { 1, 12, 3, 4 }; 12 | double b [] = { 1, -2 } ; 13 | double x [2] ; 14 | double c [2] ; 15 | int i ; 16 | 17 | vl_solve_linear_system_2 (x, A, b) ; 18 | 19 | c[0] = A[0] * x[0] + A[2] * x[1] ; 20 | c[1] = A[1] * x[0] + A[3] * x[1] ; 21 | 22 | for (i = 0 ; i < 2 ; ++i) { 23 | VL_PRINTF("[A x]_%-4d = %4g, b_%-4d = %4g\n", i+1, c[i], i+1, b[i]) ; 24 | } 25 | 26 | return 0 ; 27 | } 28 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/src/test_host.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 3 | All rights reserved. 4 | 5 | This file is part of the VLFeat library and is made available under 6 | the terms of the BSD license (see the COPYING file). 7 | */ 8 | 9 | #include 10 | 11 | int 12 | main(int argc VL_UNUSED, char ** argv VL_UNUSED) 13 | { 14 | char * string = vl_configuration_to_string_copy() ; 15 | assert (string) ; 16 | VL_PRINTF(string) ; 17 | vl_free(string) ; 18 | return 0 ; 19 | } 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/src/test_liop.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main(){ 9 | vl_int i ; 10 | VlLiopDesc * liop ; 11 | vl_size size = 11*11 ; 12 | float mat[] = { 13 | 6,6,6,6,6,6,6,6,6,6,6, 14 | 6,6,6,5,4,4,4,5,6,6,6, 15 | 6,6,5,4,3,3,3,4,5,6,6, 16 | 6,5,4,3,2,2,2,3,4,5,6, 17 | 6,4,3,2,2,1,2,2,3,4,6, 18 | 6,4,3,2,1,1,1,2,3,4,6, 19 | 6,4,3,2,2,1,2,2,3,4,6, 20 | 6,5,4,3,2,2,2,3,4,5,6, 21 | 6,6,5,4,3,3,3,4,5,6,6, 22 | 6,6,6,5,4,4,4,5,6,6,6, 23 | 6,6,6,6,6,6,6,6,6,6,6}; 24 | float * patch = vl_malloc(sizeof(float)*size); 25 | 26 | for(i = 0; i < (signed)size; i++){ 27 | patch[i] = mat[i]; 28 | } 29 | 30 | liop = vl_liopdesc_new(4,6,2,11); 31 | 32 | vl_liopdesc_delete(liop) ; 33 | vl_free(patch) ; 34 | } 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/src/test_nan.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 3 | All rights reserved. 4 | 5 | This file is part of the VLFeat library and is made available under 6 | the terms of the BSD license (see the COPYING file). 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | int 13 | main(int argc VL_UNUSED, char** argv VL_UNUSED) 14 | { 15 | VL_PRINTF ("Double NaN : `%g'\n", VL_NAN_D ) ; 16 | VL_PRINTF ("Double Inf : `%g'\n", VL_INFINITY_D) ; 17 | VL_PRINTF ("Double - Inf : `%g'\n", - VL_INFINITY_D) ; 18 | VL_PRINTF ("Single NaN : `%g'\n", VL_NAN_F ) ; 19 | VL_PRINTF ("Single Inf : `%g'\n", VL_INFINITY_F) ; 20 | VL_PRINTF ("Single - Inf : `%g'\n", - VL_INFINITY_F) ; 21 | 22 | VL_PRINTF ("Double: 0.0 < VL_INFINITY_D: %d\n", 0.0 < VL_INFINITY_D) ; 23 | VL_PRINTF ("Double: 0.0 > - VL_INFINITY_D: %d\n", 0.0 > - VL_INFINITY_D) ; 24 | 25 | return 0 ; 26 | } 27 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/src/test_qsort-def.c: -------------------------------------------------------------------------------- 1 | /** @file test_heap-def.c 2 | ** @brief Test heap-def.h 3 | ** @author Andrea Vedaldi 4 | **/ 5 | 6 | /* 7 | Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 8 | All rights reserved. 9 | 10 | This file is part of the VLFeat library and is made available under 11 | the terms of the BSD license (see the COPYING file). 12 | */ 13 | 14 | #define VL_QSORT_prefix my_qsort 15 | #define VL_QSORT_type float 16 | #include 17 | 18 | #include 19 | 20 | int 21 | main (int argc VL_UNUSED, char ** argv VL_UNUSED) 22 | { 23 | float values [] = {.4, 12.3, 44.0, 1.2, 3.4, 5.6} ; 24 | vl_size n = sizeof(values) / sizeof(values[0]) ; 25 | vl_uindex i ; 26 | 27 | for (i = 0 ; i < n ; ++i) printf("%5.2f ", values [i]) ; 28 | printf("\n") ; 29 | 30 | my_qsort_sort (values, n) ; 31 | 32 | for (i = 0 ; i < n ; ++i) printf("%5.2f ", values [i]) ; 33 | printf("\n") ; 34 | 35 | return 0 ; 36 | } 37 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/src/test_rand.c: -------------------------------------------------------------------------------- 1 | /** @file test_rand.c 2 | ** @author Andrea Vedaldi 3 | ** @breif Test vl/random.h 4 | **/ 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | int 12 | main (int argc VL_UNUSED, char *argv[] VL_UNUSED) 13 | { 14 | int i ; 15 | vl_uint32 init [4] = {0x123, 0x234, 0x345, 0x456} ; 16 | VlRand rand ; 17 | vl_rand_init (&rand) ; 18 | 19 | vl_rand_seed_by_array (&rand, init, sizeof(init)/sizeof(init[0])) ; 20 | 21 | printf("1000 outputs of vl_rand_uint32()\n"); 22 | for (i=0; i<1000; i++) { 23 | printf("%10" VL_FL_INT32 "u ", vl_rand_uint32(&rand)); 24 | if (i%5==4) printf("\n"); 25 | } 26 | 27 | printf("\n1000 outputs of vl_rand_real2()\n"); 28 | for (i=0; i<1000; i++) { 29 | printf("%10.8f ", vl_rand_real2(&rand)); 30 | if (i%5==4) printf("\n"); 31 | } 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/startup.m: -------------------------------------------------------------------------------- 1 | run('C:\Users\Administrator\Desktop\low rank and sparse\1\lrslibrary-master\libs\vlfeat\toolbox\vl_setup') 2 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/aib/vl_aibcutpush.m: -------------------------------------------------------------------------------- 1 | function y = vl_aibcutpush(map, x) 2 | % VL_AIBCUTPUSH Quantize based on VL_AIB cut 3 | % Y = VL_AIBCUTPUSH(MAP, X) maps the data X to elements of the AIB 4 | % cut specified by MAP. 5 | % 6 | % The function is equivalent to Y = MAP(X). 7 | % 8 | % See also: VL_HELP(), VL_AIB(). 9 | 10 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 11 | % All rights reserved. 12 | % 13 | % This file is part of the VLFeat library and is made available under 14 | % the terms of the BSD license (see the COPYING file). 15 | 16 | y = map(x) ; 17 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/aib/vl_aibhist.m: -------------------------------------------------------------------------------- 1 | % VL_AIBHIST Compute histogram over VL_AIB tree 2 | % H = VL_AIBHIST(PARENTS, DATA) computes the histogram of the data 3 | % points DATA on the VL_AIB tree defined by PARENTS. Each element of 4 | % DATA indexes one of the leaves of the VL_AIB tree. 5 | % 6 | % H = VL_AIBHIST(PARENTS, DATA, 'HIST') treats DATA as an histograms. 7 | % In this case each compoment of DATA is the number of occurences of 8 | % the VL_AIB leaves corresponding to that component. 9 | % 10 | % H has the same dimension of parents and counts how many data points 11 | % are descendent of the corresponding node of the VL_AIB tree. 12 | % 13 | % See also: VL_HELP(), VL_AIB(), VL_AIBCUTPUSH(). 14 | 15 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 16 | % All rights reserved. 17 | % 18 | % This file is part of the VLFeat library and is made available under 19 | % the terms of the BSD license (see the COPYING file). 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/demo/vl_demo_cmd.m: -------------------------------------------------------------------------------- 1 | function [err,msg] = vl_demo_cmd(name, args) 2 | % DEMO_CMD: Demo: Command line utility 3 | 4 | ext = '' ; 5 | switch mexext 6 | case 'mexmac' 7 | arch = 'mac' ; 8 | case 'mexmaci' 9 | arch = 'maci' ; 10 | case 'mexmaci64' 11 | arch = 'maci64'; 12 | case 'mexglx' 13 | arch = 'glnx86' ; 14 | case 'mexa64' 15 | arch = 'glnxa64' ; 16 | case 'dll' 17 | arch = 'win32' ; 18 | ext = '.exe' ; 19 | case 'mexw32' 20 | arch = 'win32' ; 21 | ext ='.exe' ; 22 | case 'mexw64' 23 | arch = 'win64' ; 24 | ext ='.exe' ; 25 | end 26 | 27 | cmd = fullfile(vl_root,'bin',arch,[name ext]) ; 28 | str = ['"' cmd '" ' args] ; 29 | disp(str); 30 | [err,msg] = system(str) ; 31 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/demo/vl_demo_gmm_2d_rand.m: -------------------------------------------------------------------------------- 1 | % VL_DEMO_GMM_2D_RAND Demonstrate clustering points with a GMM 2 | 3 | %% Create a random set of points 4 | numPoints = 5000 ; 5 | dimension = 2 ; 6 | numClusters = 20 ; 7 | data = rand(dimension, numPoints) ; 8 | 9 | %% Learn a GMM: fit the points at maximum likelihood 10 | vl_twister('state',0) ; 11 | [means, covariances, priors] = ... 12 | vl_gmm(data, numClusters, ... 13 | 'MaxNumIterations', 1000, ... 14 | 'Verbose') ; 15 | 16 | figure(1) ; clf ; hold on 17 | plot(data(1,:),data(2,:),'r.'); 18 | for i=1:numClusters 19 | vl_plotframe([means(:,i)' covariances(1,i) 0 covariances(2,i)], ... 20 | 'Color','blue','LineWidth',2); 21 | end 22 | 23 | title('GMM: Gaussian mixture initialized choosing random points') ; 24 | axis equal ; axis off ; 25 | vl_demo_print('gmm_2d_rand',0.6); 26 | 27 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/demo/vl_demo_ikmeans.m: -------------------------------------------------------------------------------- 1 | function vl_demo_ikmeans() 2 | % VL_DEMO_IKMEANS 3 | 4 | numData = 10000 ; 5 | dimension = 2 ; 6 | data = uint8(255*rand(dimension,numData)) ; 7 | numClusters = 3^3 ; 8 | 9 | [centers, assignments] = vl_ikmeans(data, numClusters); 10 | 11 | figure(1) ; clf ; axis off ; 12 | plotClusters(data, centers, assignments) ; 13 | vl_demo_print('ikmeans_2d',0.6); 14 | 15 | [tree, assignments] = vl_hikmeans(data,3,numClusters) ; 16 | figure(2) ; clf ; axis off ; 17 | plotClusters(data, [], [4 2 1] * double(assignments)) ; 18 | vl_demo_print('hikmeans_2d',0.6); 19 | 20 | function plotClusters(data, centers, assignments) 21 | hold on ; 22 | cc=jet(double(max(assignments(:)))); 23 | for i=1:max(assignments(:)) 24 | plot(data(1,assignments == i),data(2,assignments == i),'.','color',cc(i,:)); 25 | end 26 | if ~isempty(centers) 27 | plot(centers(1,:),centers(2,:),'k.','MarkerSize',20) 28 | end 29 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/demo/vl_demo_kmeans_2d.m: -------------------------------------------------------------------------------- 1 | N = 10000 ; 2 | dimension = 2 ; 3 | data = rand(dimension,N) ; 4 | numClusters = 20 ; 5 | cc=hsv(numClusters); 6 | 7 | [centers, assignments] = vl_kmeans(data, numClusters); 8 | 9 | figure 10 | hold on 11 | for i=1:numClusters 12 | plot(data(1,assignments == i),data(2,assignments == i),'.','color',cc(i,:)); 13 | end 14 | plot(centers(1,:),centers(2,:),'k.','MarkerSize',20) 15 | axis off 16 | vl_demo_print('kmeans_2d_rand',0.6); -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/demo/vl_demo_plots_rank.m: -------------------------------------------------------------------------------- 1 | %VL_DEMO_PLOTS_RANK Demonstates VL_ROC, VL_DET, VL_PR 2 | 3 | randn('state',0) ; 4 | numPos = 20 ; 5 | numNeg = 100 ; 6 | labels = [ones(1, numPos) -ones(1,numNeg)] ; 7 | scores = randn(size(labels)) + labels ; 8 | 9 | figure(1) ; clf ; 10 | vl_roc(labels,scores) ; 11 | vl_demo_print(1,'plots_rank_roc', 0.5) ; 12 | 13 | figure(2) ; clf ; 14 | subplot(2,2,1) ; vl_roc(labels,scores, 'plot', 'tntp') ; 15 | subplot(2,2,2) ; vl_roc(labels,scores, 'plot', 'tptn') ; 16 | subplot(2,2,3) ; vl_roc(labels,scores, 'plot', 'fptp') ; 17 | subplot(2,2,4) ; vl_roc(labels,scores, 'plot', 'fpfn') ; 18 | vl_figaspect(1) ; 19 | vl_demo_print(2,'plots_rank_roc_variants', 1) ; 20 | 21 | figure(3) ; clf ; 22 | vl_det(labels,scores) ; 23 | vl_demo_print(3,'plots_rank_det', 0.5) ; 24 | 25 | figure(4) ; clf ; 26 | vl_pr(labels,scores) ; 27 | vl_demo_print(4,'plots_rank_pr', 0.5) ; 28 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/demo/vl_demo_sift_edge.m: -------------------------------------------------------------------------------- 1 | % VL_DEMO_SIFT_EDGE Demo: SIFT: edge treshold 2 | 3 | randn('state',0) ; 4 | rand('state',0) ; 5 | 6 | I = zeros(100,500) ; 7 | for i=[10 20 30 40 50 60 70 80 90] 8 | d = round(i/3) ; 9 | I(50-d:50+d,i*5) = 1 ; 10 | end 11 | I = 2*pi*8^2 * vl_imsmooth(I,8) ; 12 | I = single(255 * I) ; 13 | 14 | figure(1) ; clf ; 15 | imagesc(I) ; colormap gray ; 16 | axis equal ; axis off ; axis tight ; 17 | hold on ; 18 | 19 | vl_demo_print('sift_edge_0') ; 20 | 21 | ter=[3.5 5 7.5 10] ; 22 | for te=ter 23 | f = vl_sift(I, ... 24 | 'PeakThresh', 0, ... 25 | 'EdgeThresh', te, ... 26 | 'FirstOctave', -1 ) ; 27 | h1 = vl_plotframe(f) ; 28 | set(h1,'color','k','linewidth',3) ; 29 | h2 = vl_plotframe(f) ; 30 | set(h2,'color','y','linewidth',2) ; 31 | 32 | vl_demo_print(sprintf('sift_edge_%d', find(te==ter))) ; 33 | delete(h1) ; 34 | delete(h2) ; 35 | end 36 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/demo/vl_demo_sift_or.m: -------------------------------------------------------------------------------- 1 | % VL_DEMO_SIFT_OR Demonstrates SIFT orientation detection 2 | 3 | I = vl_impattern('wedge') ; 4 | ur = 1:size(I,2) ; 5 | vr = 1:size(I,1) ; 6 | 7 | % distribute frames on a grid 8 | [u,v] = meshgrid(ur(5:10:end-4),vr(5:10:end-4)) ; 9 | f = [u(:)';v(:)'] ; 10 | K = size(f,2) ; 11 | f = [f ; 4 * ones(1,K) ; 0 * ones(1,K)] ; 12 | 13 | % detect orienntations 14 | f = vl_sift(single(I), 'frames', f, 'orientations') ; 15 | 16 | figure(1) ; clf ; 17 | imagesc(single(I)) ; colormap gray ; hold on ; 18 | vl_plotframe(f,'color','k','linewidth',3) ; 19 | vl_plotframe(f,'color','y','linewidth',2) ; 20 | axis equal ; axis off ; 21 | vl_demo_print('sift_or') ; 22 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/demo/vl_demo_svm_data.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/libs/vlfeat/toolbox/demo/vl_demo_svm_data.mat -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/geometry/vl_hat.m: -------------------------------------------------------------------------------- 1 | function H = vl_hat(om) 2 | % VL_HAT Hat operator 3 | % H = VL_HAT(OM) returns the skew symmetric matrix by taking the "hat" 4 | % of the 3D vector OM. 5 | % 6 | % See also: VL_IHAT(), VL_HELP(). 7 | 8 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 9 | % All rights reserved. 10 | % 11 | % This file is part of the VLFeat library and is made available under 12 | % the terms of the BSD license (see the COPYING file). 13 | 14 | H = [0 -om(3) om(2) ; 15 | om(3) 0 -om(1) ; 16 | -om(2) om(1) 0 ] ; 17 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/geometry/vl_ihat.m: -------------------------------------------------------------------------------- 1 | function om = vl_ihat( H ) 2 | % VL_IHAT Inverse vl_hat operator 3 | % OM = VL_IHAT(H) returns a vector OM such that VL_HAT(OM) = H. 4 | % H hast to be 3x3 skew-symmetric. 5 | % 6 | % See also: VL_HAT(), VL_HELP(). 7 | 8 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 9 | % All rights reserved. 10 | % 11 | % This file is part of the VLFeat library and is made available under 12 | % the terms of the BSD license (see the COPYING file). 13 | 14 | om = [H(3,2);H(1,3);H(2,1)] ; 15 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/imop/vl_dwaffine.m: -------------------------------------------------------------------------------- 1 | function [dWx,dWy] = vl_dwaffine(x,y) 2 | % VL_DWAFFINE Derivative of an affine warp 3 | % [DWX,DWY]=VL_DWAFFINE(X,Y) returns the derivative of the 2-D affine 4 | % warp [WX; WY] = [A T] [X; Y] with respect to the parameters A,T 5 | % computed at points X,Y. 6 | % 7 | % See also: VL_WAFFINE(), VL_HELP(). 8 | 9 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 10 | % All rights reserved. 11 | % 12 | % This file is part of the VLFeat library and is made available under 13 | % the terms of the BSD license (see the COPYING file). 14 | 15 | % dW = [ kron(x',I) I ] 16 | % | 17 | % = [ x1 0 x2 0 1 0 ] 18 | % [ 0 x1 0 x2 0 1 ] 19 | 20 | z = zeros(length(x(:)),1) ; 21 | o = ones(length(x(:)),1) ; 22 | 23 | dWx = [ x(:) z y(:) z o z ] ; 24 | dWy = [ z x(:) z y(:) z o ] ; 25 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/imop/vl_imintegral.m: -------------------------------------------------------------------------------- 1 | % VL_IMINTEGRAL Compute integral image 2 | % J = VL_IMINTEGRAL(I) calculates the integral image J of the image 3 | % I. I must a matrix with DOUBLE, SINGLE, UINT32, or INT32 storage 4 | % class. J is given by 5 | % 6 | % J(i,j) = sum(I(1:i,1:j)). 7 | % 8 | % J has the same size as I and the same storage class. 9 | % 10 | % Example:: 11 | % The following identity holds: 12 | % VL_IMINTEGRAL(ONES(3)) = [ 1 2 3 ; 13 | % 2 4 6 ; 14 | % 3 6 9 ] 15 | % 16 | % See also: VL_HELP(). 17 | 18 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 19 | % All rights reserved. 20 | % 21 | % This file is part of the VLFeat library and is made available under 22 | % the terms of the BSD license (see the COPYING file). 23 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/imop/vl_imreadbw.m: -------------------------------------------------------------------------------- 1 | function I = vl_imreadgray(file,varargin) 2 | % VL_IMREADGRAY Reads an image as gray-scale 3 | % I=VL_IMREADGRAY(FILE) reads the image from file FILE and converts the 4 | % result to a gray scale image (DOUBLE storage class ranging in 5 | % [0,1]). 6 | % 7 | % VL_IMREADGRAY(FILE,FMT) specifies the file format FMT (see IMREAD()). 8 | % 9 | % See also: RGB2DOUBLE(), VL_HELP(). 10 | 11 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 12 | % All rights reserved. 13 | % 14 | % This file is part of the VLFeat library and is made available under 15 | % the terms of the BSD license (see the COPYING file). 16 | 17 | I = imread(file) ; 18 | I = im2double(I) ; 19 | 20 | if(size(I,3) > 1) 21 | I = rgb2gray(I) ; 22 | end 23 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/imop/vl_imreadgray.m: -------------------------------------------------------------------------------- 1 | function I = vl_imreadgray(file,varargin) 2 | % VL_IMREADGRAY Reads an image as gray-scale 3 | % I=VL_IMREADGRAY(FILE) reads the image from file FILE and converts the 4 | % result to a gray scale image (DOUBLE storage class ranging in 5 | % [0,1]). 6 | % 7 | % VL_IMREADGRAY(FILE,FMT) specifies the file format FMT (see IMREAD()). 8 | % 9 | % See also: RGB2DOUBLE(), VL_HELP(). 10 | 11 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 12 | % All rights reserved. 13 | % 14 | % This file is part of the VLFeat library and is made available under 15 | % the terms of the BSD license (see the COPYING file). 16 | 17 | I = imread(file) ; 18 | I = im2double(I) ; 19 | 20 | if(size(I,3) > 1) 21 | I = rgb2gray(I) ; 22 | end 23 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/imop/vl_imsc.m: -------------------------------------------------------------------------------- 1 | function J=vl_imsc(I) 2 | % VL_IMSC Scale image 3 | % J=VL_IMSC(I) scales the range of the gray-scale or color image I to 4 | % fit in the interval [0,1]. 5 | % 6 | % See also: VL_HELP(). 7 | 8 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 9 | % All rights reserved. 10 | % 11 | % This file is part of the VLFeat library and is made available under 12 | % the terms of the BSD license (see the COPYING file). 13 | 14 | if ~isfloat(I) 15 | I = im2double(I) ; 16 | end 17 | 18 | J = I - min(I(:)) ; 19 | J = J / max(J(:)) ; 20 | J = max(min(J, 1), 0) ; 21 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/imop/vl_imup.m: -------------------------------------------------------------------------------- 1 | function J = vl_imup(I) 2 | % VL_IMUP Upsample an image by two 3 | % J=VL_IMUP(I) doubles the resolution of the image I by using 4 | % bilinear interpolation. 5 | % 6 | % See also: VL_IMDOWN(), VL_HELP(). 7 | 8 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 9 | % All rights reserved. 10 | % 11 | % This file is part of the VLFeat library and is made available under 12 | % the terms of the BSD license (see the COPYING file). 13 | 14 | [M,N,K] = size(I) ; 15 | 16 | J = zeros(2*M,2*N,K) ; 17 | 18 | J(1:2:end,1:2:end,:) = I ; 19 | 20 | J(2:2:end,1:2:end,:) = 0.5*(I+[I(2:end,:,:);I(end,:,:)]) ; 21 | J(1:2:end,2:2:end,:) = 0.5*(I+[I(:,2:end,:),I(:,end,:)]) ; 22 | J(2:2:end,2:2:end,:) = ... 23 | 0.25*(... 24 | J(2:2:end,1:2:end-1,:)+... 25 | J(1:2:end-1,2:2:end,:)+... 26 | [J(2:2:end,3:2:end,:),J(2:2:end,end-1,:)]+... 27 | [J(3:2:end,2:2:end,:);J(end-1,2:2:end,:)]) ; 28 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/info.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 2012a 6 | VLFeat 7 | toolbox 8 | ../doc/images/vl_blue.png 9 | ../doc/matlab/ 10 | ../doc/images/vl_blue.png 11 | 12 | 13 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/kmeans/vl_hikmeanspush.m: -------------------------------------------------------------------------------- 1 | % VL_HIKMEANSPUSH Push data down an integer K-means tree 2 | % PATH = VL_HIKMEANSPUSH(TREE,X) quanizes the data X with the 3 | % hierachical integer K-means tree TREE. This is obtained by 4 | % calculating the path of each datum from the root of TREE down to a 5 | % leaf. Here X has a datum for each column and each column of PATH 6 | % represents the corresponding root-to-leaf path. 7 | % 8 | % Example:: 9 | % PATH(:,1) = [2 1 4] means that the first datum follows 10 | % the branches number 2, 1 and 4 starting from the root of the 11 | % HIKM tree ending to a leaf. 12 | % 13 | % See also: VL_HIKMEANS(), VL_HELP(). 14 | 15 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 16 | % All rights reserved. 17 | % 18 | % This file is part of the VLFeat library and is made available under 19 | % the terms of the BSD license (see the COPYING file). 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/kmeans/vl_ikmeanshist.m: -------------------------------------------------------------------------------- 1 | function h = vl_ikmeanshist(K,asgn) 2 | % VL_IKMEANSHIST Compute histogram of quantized data 3 | % H = VL_IKMEANSHIST(K,ASGN) computes the histogram of the IKM clusters 4 | % activated by cluster assignments ASGN. 5 | % 6 | % See also: VL_IKMEANS(), VL_IKMEANSPUSH(), VL_HELP(). 7 | 8 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 9 | % All rights reserved. 10 | % 11 | % This file is part of the VLFeat library and is made available under 12 | % the terms of the BSD license (see the COPYING file). 13 | 14 | h = zeros(K,1) ; 15 | h = vl_binsum(h, 1, double(asgn)) ; 16 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/kmeans/vl_ikmeanspush.m: -------------------------------------------------------------------------------- 1 | % VL_IKMEANSPUSH Project data on integer K-means paritions 2 | % I = VL_IKMEANSPUSH(X,C) projects the data X to the integer K-meanns 3 | % clusters of centers C returning the cluster indeces I. 4 | % 5 | % See also: VL_IKMEANS(), VL_HELP(). 6 | 7 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 8 | % All rights reserved. 9 | % 10 | % This file is part of the VLFeat library and is made available under 11 | % the terms of the BSD license (see the COPYING file). 12 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/misc/vl_binsearch.m: -------------------------------------------------------------------------------- 1 | % VL_BINSEARCH Maps data to bins 2 | % IDX = VL_BINSEARCH(B, X) maps the elements of X to the bins 3 | % defined by B. B is a non-decreasing vector of M real numbers 4 | % defining bins [-inf, B(1)), [B(1), B(2)), ... [B(M) +inf] (note 5 | % that the last bin contains +inf). The bins are numbered from 0 to 6 | % M. X is a real (plain) array and IDX is an array with the same 7 | % dimensions of X, specifying the bin correpsonding to each element 8 | % of X. 9 | % 10 | % If B(1) = -inf the bin number 0 is removed and the bin number 1 is 11 | % [-inf B(2)). If B(M) = +inf, the last bin M is the singleton +inf. 12 | % 13 | % See also: VL_BINSUM(), VL_HELP(). 14 | 15 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 16 | % All rights reserved. 17 | % 18 | % This file is part of the VLFeat library and is made available under 19 | % the terms of the BSD license (see the COPYING file). 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/misc/vl_cummax.m: -------------------------------------------------------------------------------- 1 | % VL_CUMMAX Cumulative maximum 2 | % If X is a vector, VL_CUMMAX(X) is the vector with the cumulative 3 | % maximum of X. If X is a matrix, VL_CUMMAX(X) is the matrix of the 4 | % cumulative maximum of the columns of X. If X is a multi-dimensional 5 | % array, VL_CUMMAX(X) operates along the first non-singleton 6 | % dimension. 7 | % 8 | % The function is analogous to CUMSUM() and CUMPROD(), but it 9 | % computes the cumulative maximum rather than the cumulative sum or 10 | % product. 11 | % 12 | % The array X can be of any numeric class. 13 | % 14 | % Example:: 15 | % The cumulative maximum VL_CUMMAX([1 2 3 2 1]) is the vector 16 | % [1 2 3 3 3]. 17 | % 18 | % See also: CUMSUM(), CUMPROD(), VL_HELP(). 19 | 20 | % Author: Andrea Vedaldi 21 | 22 | % Copyright 23 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/misc/vl_getpid.m: -------------------------------------------------------------------------------- 1 | % VL_GETPID Get MATLAB process ID 2 | % VL_GETPID() returns MATLAB process ID. 3 | % 4 | % Algorithm:: 5 | % VL_GETPID() returns the result of the getpid() system call on 6 | % UNIX-like operating systems and of GetCurrentProcessID() on 7 | % Windows. 8 | % 9 | % See also: VL_HELP(). 10 | 11 | % Authors: Andrea Vedaldi 12 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/misc/vl_ihashfind.m: -------------------------------------------------------------------------------- 1 | % VL_IHASHFIND Find labels in an integer hash table 2 | % SEL = VL_IHASHFIND(ID, NEXT, K, X) returns a vector SEL of the 3 | % entires in the hash table ID,NEXT,K corresponding to the labels 4 | % stored as columns of X. 5 | % 6 | % The format is the same as for the functino VL_IHASHSUM(). 7 | % 8 | % See also: VL_IHASHSUM(). 9 | 10 | % Author: Andrea Vedaldi 11 | 12 | % Copyright (C) 2008-12 Andrea Vedaldi. 13 | % All rights reserved. 14 | % 15 | % This file is part of the VLFeat library and is made available under 16 | % the terms of the BSD license (see the COPYING file). 17 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/misc/vl_isoctave.m: -------------------------------------------------------------------------------- 1 | function x = vl_isoctave() 2 | % VL_ISOCTAVE Determines whether Octave is running 3 | % X = VL_ISOCTAVE() returns TRUE if the script is running in the 4 | % Octave environment (instead of MATLAB). 5 | 6 | persistent y ; 7 | 8 | if isempty(y) 9 | y = exist('OCTAVE_VERSION','builtin') ~= 0 ; 10 | end 11 | 12 | x = y ; 13 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/misc/vl_lbp.m: -------------------------------------------------------------------------------- 1 | % VL_LBP Local Binary Patterns 2 | % F = VL_LBP(IM, CELLSIZE) computes the Local Binary Pattern (LBP) 3 | % features for image I. 4 | % 5 | % IM is divided in cells of size CELLSIZE. F is a three-dimensional 6 | % array containing one histograms of quantized LBP features per 7 | % cell. The witdh of F is FLOOR(WIDTH/CELLSIZE), where WIDTH is the 8 | % width of the image. The same for the height. The third dimension 9 | % is 58. 10 | % 11 | % See also: LBP, VL_LBPFLIPLR(), 12 | % VL_HELP(). 13 | 14 | % Copyright (C) 2013 Andrea Vedaldi. 15 | % Copyright (C) 2010-11 Andrea Vedaldi. 16 | % All rights reserved. 17 | % 18 | % This file is part of the VLFeat library and is made available under 19 | % the terms of the BSD license (see the COPYING file). 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/misc/vl_matlabversion.m: -------------------------------------------------------------------------------- 1 | function v = vl_matlabversion 2 | % VL_MATLABVERSION Return MATLAB version as an integer 3 | % V = VL_MATLABVERSION() returns MATLAB version encoded as an 4 | % ingeger value. MATLAB version string has the format 5 | % 6 | % MAJOR.MINOR.SERVICEPACK 7 | % 8 | % The integer V has the value 9 | % 10 | % V = MAJOR * 10000 + MINOR * 100 + SERVICEPACK. 11 | % 12 | % For example, in MATLAB 7.10.0 (R2010a), V equals 70100. 13 | % 14 | % See also: VL_HELP(). 15 | 16 | v = [1e4 1e2 1e0] * sscanf(version, '%d.%d.%d') ; 17 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/misc/vl_numder.m: -------------------------------------------------------------------------------- 1 | function d = vl_numder(func, x, varargin) 2 | % VL_NUMDER Numerical derivative 3 | % D = VL_NUMDER(FUNC, X) computes the numerical derivative of the 4 | % function FUNC at point X. X is a real array and is passed as first 5 | % argument of FUNC. 6 | % 7 | % D = VL_NUMDER(FUNC, X, ARG1, ARG2, ...) passes ARG1, ARG2, ... as 8 | % additional arguments to the function FUNC. 9 | % 10 | % See also: VL_NUMDER2(), VL_HELP(). 11 | 12 | % TODO: uniform sacaling of axis is not a good idea 13 | 14 | dx = 1e-7 ; 15 | N = numel(x) ; 16 | fx = feval(func, x, varargin{:}) ; 17 | d = zeros(length(fx(:)),N) ; 18 | 19 | for n=1:N 20 | e = zeros(size(x)) ; e(n) = 1 ; 21 | fxn = feval(func, x+dx*e, varargin{:}) ; 22 | di = (fxn - fx) / dx ; 23 | d(:,n) = di(:) ; 24 | end 25 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/misc/vl_sampleinthist.m: -------------------------------------------------------------------------------- 1 | % VL_SAMPLINTHIST Sample integral histogram 2 | % HISTS = VL_SAMPLINTHIST(INTHIST, BOXES) samples the integral 3 | % histogram INTHIST to obtain the histograms of the specified 4 | % BOXES. 5 | % 6 | % INTHIST is a MxNxK array, where M x N are ``spatial'' dimensions, 7 | % and K is the number of histogram bins. INTHIST may be of class 8 | % UINT32 or DOUBLE. 9 | % 10 | % Each box is a four dimensional vector [IMIN JMIN IMAX JMAX]' of 11 | % class UINT32 and correspond to the index set [IMIN, IMAX] x [JMIN, 12 | % JMAX]. To specify an empty box, let IMIN > IMAX. 13 | % 14 | % HISTS stores one histogram per column (one for each box) and has K 15 | % rows, one for each histogram bin. HIST is of the same class of 16 | % INTHIST. 17 | % 18 | % See also: VL_INTHIST(), VL_IMINTEGRAL(), VL_HELP(). 19 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/misc/vl_simdctrl.m: -------------------------------------------------------------------------------- 1 | % VL_SIMDCTRL Toggle VLFeat SIMD optimizations 2 | % VL_SIMDCTRL() returns TRUE if VLFeat SIMD optimizations are enabled 3 | % and FALSE otherwise. 4 | % 5 | % VL_SIMDCTRL(TRUE) enables VLFeat SIMD optimizations. VL_SIMDCTRL(FALSE) 6 | % disables them. 7 | % 8 | % See also: VL_HELP(). 9 | 10 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 11 | % All rights reserved. 12 | % 13 | % This file is part of the VLFeat library and is made available under 14 | % the terms of the BSD license (see the COPYING file). 15 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/misc/vl_threads.m: -------------------------------------------------------------------------------- 1 | %VL_THREADS Control VLFeat computational threads 2 | % [NUM,MAXNUM] = VL_THREADS() returns the current number of 3 | % computational threads NUM and the maximum possible number MAXNUM. 4 | % 5 | % VL_THREADS(NUM) sets the current number of threads to the 6 | % specified value. NUM = VL_THREADS(NUM) does the same, but returns 7 | % the *previous* number of computational threads as well. 8 | % 9 | % See also: VL_HELP(). 10 | 11 | % Copyright (C) 2013 Andrea Vedaldi. 12 | % All rights reserved. 13 | % 14 | % This file is part of the VLFeat library and is made available under 15 | % the terms of the BSD license (see the COPYING file). 16 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/misc/vl_version.m: -------------------------------------------------------------------------------- 1 | % VL_VERSION Obtain VLFeat version information 2 | % VL_VERSION() prints VLFeat version number. VL_VERSION('VERBOSE') 3 | % prints additional information. 4 | % 5 | % STR = VL_VERSION(...) returns the ouptut in a string rather than 6 | % printing it. 7 | % 8 | % See also: VL_HELP(). 9 | 10 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 11 | % All rights reserved. 12 | % 13 | % This file is part of the VLFeat library and is made available under 14 | % the terms of the BSD license (see the COPYING file). 15 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/mser/vl_erfill.m: -------------------------------------------------------------------------------- 1 | % VL_ERFILL Fill extremal region 2 | % MEMBERS=VL_ERFILL(I,ER) returns the list MEMBERS of the pixels which 3 | % belongs to the extremal region represented by the pixel ER. 4 | % 5 | % The selected region is the one that contains pixel ER and of 6 | % intensity I(ER). 7 | % 8 | % I must be of class UINT8 and ER must be a (scalar) index of the 9 | % region representative point. 10 | % 11 | % See also: VL_MSER(), VL_HELP(). 12 | 13 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 14 | % All rights reserved. 15 | % 16 | % This file is part of the VLFeat library and is made available under 17 | % the terms of the BSD license (see the COPYING file). 18 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/mser/vl_ertr.m: -------------------------------------------------------------------------------- 1 | function f = vl_ertr(f) ; 2 | % VL_ERTR Transpose exremal regions frames 3 | % F = VL_ERTR(F) transposes the frames F as returned by VL_MSER(). This 4 | % conversion is required as the VL_MSER algorithm considers the column 5 | % index I as the frist image index, while according standard image 6 | % convention the first coordinate is the abscissa X. 7 | % 8 | % See also: VL_MSER(), VL_HELP(). 9 | 10 | if size(f,1) ~= 5 11 | error('F is not in the right format') ; 12 | end 13 | 14 | % adjust convention 15 | f = f([2 1 5 4 3],:) ; 16 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/plotop/vl_cf.m: -------------------------------------------------------------------------------- 1 | function h = vl_cf(h0) 2 | % VL_CF Creates a copy of a figure 3 | % VL_CF() creates a copy of the current figure and returns VL_CF(H0) 4 | % creates a copy of the figure(s) whose handle is H0. H = 5 | % VL_CF(...) returns the handles of the copies. 6 | % 7 | % See also: VL_HELP(). 8 | 9 | % Authors: Andrea Vedaldi 10 | 11 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 12 | % All rights reserved. 13 | % 14 | % This file is part of the VLFeat library and is made available under 15 | % the terms of the BSD license (see the COPYING file). 16 | 17 | if nargin < 1 18 | h0 = gcf ; 19 | end 20 | 21 | h=zeros(size(h0)) ; 22 | for i=1:numel(h0) 23 | h(i) = copyobj(h0(i),get(h0(i),'Parent')) ; 24 | end 25 | 26 | if nargout < 1 27 | clear h ; 28 | end 29 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/plotop/vl_figaspect.m: -------------------------------------------------------------------------------- 1 | function vl_figaspect(a) 2 | % VL_FIGASPECT Set figure aspect ratio 3 | % VL_FIGASPECT(A) sets the current figure aspect ratio to A. It 4 | % leaves the length of the shortest side unaltered. Both the 5 | % screen and paper positions are affected. 6 | % 7 | % See also: VL_PRINTSIZE(), VL_HELP(). 8 | 9 | % Authors: Andrea Vedaldi 10 | 11 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 12 | % All rights reserved. 13 | % 14 | % This file is part of the VLFeat library and is made available under 15 | % the terms of the BSD license (see the COPYING file). 16 | 17 | pos = get(gcf, 'Position') ; 18 | 19 | if a >= 1 20 | pos(3) = a * pos(4) ; 21 | else 22 | pos(4) = pos(3) / a ; 23 | end 24 | 25 | set(gcf,'Position',pos) ; 26 | 27 | pos = get(gcf, 'PaperPosition') ; 28 | 29 | if a >= 1 30 | pos(3) = a * pos(4) ; 31 | else 32 | pos(4) = pos(3) / a ; 33 | end 34 | 35 | set(gcf,'PaperPosition', pos) ; 36 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/plotop/vl_plotgrid.m: -------------------------------------------------------------------------------- 1 | function h=vl_plotgrid(x,y,varargin) 2 | % VL_PLOTGRID Plot a 2-D grid 3 | % VL_PLOTGRID(X,Y) plots a grid with vertices (X,Y). X and Y are MxN 4 | % matrices, with one entry per vertex. 5 | % 6 | % H=VL_PLOTGRID(...) returns the handle to the grid object. 7 | % 8 | % See also: VL_HELP(). 9 | 10 | washold = ishold ; 11 | 12 | [M,N] = size(x) ; 13 | 14 | hold on ; 15 | 16 | xh = [x' ; nan*ones(1,M) ] ; 17 | yh = [y' ; nan*ones(1,M) ] ; 18 | 19 | xh = xh(:) ; 20 | yh = yh(:) ; 21 | 22 | xv = [x ; nan*ones(1,N) ] ; 23 | yv = [y ; nan*ones(1,N) ] ; 24 | 25 | xv = xv(:) ; 26 | yv = yv(:) ; 27 | 28 | lineprop = {} ; 29 | if length(varargin) > 0 30 | lineprop = vl_linespec2prop(varargin{1}) ; 31 | lineprop = {lineprop{:}, varargin{2:end}} ; 32 | end 33 | 34 | h = line([xh' xv'], [yh' yv'],lineprop{:}) ; 35 | 36 | if ~washold 37 | hold off ; 38 | end 39 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/quickshift/vl_flatmap.m: -------------------------------------------------------------------------------- 1 | function [map, C] = vl_flatmap(map) 2 | % VL_FLATMAP Flatten a tree, assigning the label of the root to each node 3 | % [LABELS CLUSTERS] = VL_FLATMAP(MAP) labels each tree of the forest contained 4 | % in MAP. LABELS contains the linear index of the root node in MAP, CLUSTERS 5 | % instead contains a label between 1 and the number of clusters. 6 | % 7 | % See also: VL_HELP(). 8 | 9 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 10 | % All rights reserved. 11 | % 12 | % This file is part of the VLFeat library and is made available under 13 | % the terms of the BSD license (see the COPYING file). 14 | 15 | % follow the parents list to the root nodes (where nothing changes) 16 | while 1 17 | map_ = map(map) ; 18 | if isequal(map_,map) ; break ; end 19 | map = map_ ; 20 | end 21 | 22 | [drop,drop,C] = unique(map) ; 23 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/quickshift/vl_imseg.m: -------------------------------------------------------------------------------- 1 | function Q = vl_imseg(I,labels) 2 | % VL_IMSEG Color an image based on the segmentation 3 | % ISEG = VL_IMSEG(I,LABELS) labels ISEG with the average color from I of 4 | % each cluster indicated by LABELS. 5 | % 6 | % See also: VL_HELP(). 7 | 8 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 9 | % All rights reserved. 10 | % 11 | % This file is part of the VLFeat library and is made available under 12 | % the terms of the BSD license (see the COPYING file). 13 | 14 | [M,N,K] = size(I) ; 15 | Q = 0*I ; 16 | for k=1:size(I,3) 17 | acc = zeros(M,N) ; 18 | nrm = zeros(M,N) ; 19 | acc = vl_binsum(acc, I(:,:,k), labels) ; 20 | nrm = vl_binsum(nrm, ones(M,N), labels) ; 21 | acc = acc ./ (nrm+eps) ; 22 | Q(:,:,k) = acc(labels) ; 23 | end 24 | 25 | Q = min(1,Q); 26 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/special/vl_ddgaussian.m: -------------------------------------------------------------------------------- 1 | function y = vl_ddgaussian(x) 2 | % VL_DDGAUSSIAN Second derivative of the Gaussian density function 3 | % Y=VL_DDGAUSSIAN(X) computes the second derivative of the standard 4 | % Gaussian density. 5 | % 6 | % To obtain the second derivative of the Gaussian density of 7 | % standard deviation S, do 8 | % 9 | % Y = 1/S^3 * VL_DDGAUSSIAN(X/S) . 10 | % 11 | % See also: VL_GAUSSIAN(), VL_DGAUSSIAN(), VL_HELP(). 12 | 13 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 14 | % All rights reserved. 15 | % 16 | % This file is part of the VLFeat library and is made available under 17 | % the terms of the BSD license (see the COPYING file). 18 | 19 | y = (x.^2 - 1)/sqrt(2*pi) .* exp(-0.5*x.^2) ; 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/special/vl_dgaussian.m: -------------------------------------------------------------------------------- 1 | function y = vl_dgaussian(x) 2 | % VL_DGAUSSIAN Derivative of the Gaussian density function 3 | % Y=VL_DGAUSSIAN(X) evaluates the derivative of the standard Gaussian 4 | % density. 5 | % 6 | % To obtain the Gaussian density of standard deviation S, do 7 | % 8 | % Y = 1/S^2 * VL_DGAUSSIAN(X/S) . 9 | % 10 | % See also: VL_GAUSSIAN(), VL_DDGAUSSIAN(), VL_HELP(). 11 | 12 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 13 | % All rights reserved. 14 | % 15 | % This file is part of the VLFeat library and is made available under 16 | % the terms of the BSD license (see the COPYING file). 17 | 18 | y = -x/sqrt(2*pi) .* exp(-0.5*x.^2) ; 19 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/special/vl_dsigmoid.m: -------------------------------------------------------------------------------- 1 | function y = vl_dsigmoid(x) 2 | % VL_DSIGMOID Derivative of the sigmoid function 3 | % Y = VL_DSIGMOID(X) returns the derivative of VL_SIGMOID(X). This is 4 | % calculated as - VL_SIGMOID(X) * (1 - VL_SIGMOID(X)). 5 | % 6 | % See also: VL_SIGMOID(X), VL_HELP(). 7 | 8 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 9 | % All rights reserved. 10 | % 11 | % This file is part of the VLFeat library and is made available under 12 | % the terms of the BSD license (see the COPYING file). 13 | 14 | t = vl_sigmoid(x) ; 15 | y = t .* (1 - t) ; 16 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/special/vl_gaussian.m: -------------------------------------------------------------------------------- 1 | function y = vl_gaussian(x) 2 | % VL_GAUSSIAN Standard Gaussian density function 3 | % Y=VL_GAUSSIAN(X) computes the standard (zero mean, unit variance) 4 | % Gaussian density. 5 | % 6 | % To obtain the Gaussian density of standard deviation S do 7 | % 8 | % Y = 1/S * VL_GAUSSIAN(X/S). 9 | % 10 | % See also: VL_DGAUSSIAN(), VL_DDGAUSSIAN(), VL_HELP(). 11 | 12 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 13 | % All rights reserved. 14 | % 15 | % This file is part of the VLFeat library and is made available under 16 | % the terms of the BSD license (see the COPYING file). 17 | 18 | y = 1/sqrt(2*pi)*exp(-0.5*x.^2) ; 19 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/special/vl_rcos.m: -------------------------------------------------------------------------------- 1 | function y = vl_rcos(r,x) 2 | % VL_RCOS RCOS function 3 | % Y = VL_RCOS(R,X) computes the RCOS function with roll-off R. 4 | % 5 | % See also: VL_HELP(). 6 | 7 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 8 | % All rights reserved. 9 | % 10 | % This file is part of the VLFeat library and is made available under 11 | % the terms of the BSD license (see the COPYING file). 12 | 13 | x = abs(x) ; 14 | if(r > 0) 15 | y = (x < (1 - r)) + ... 16 | 0.5 * (1 + cos((1 - r - x)/r*pi)) .* ... 17 | (x <= 1) .* (x >= 1 - r) ; 18 | else 19 | y = (abs(x) <= 1) ; 20 | end 21 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/special/vl_sigmoid.m: -------------------------------------------------------------------------------- 1 | function y = vl_sigmoid(x) 2 | % VL_SIGMOID Sigmoid function 3 | % Y = VL_SIGMOID(X) returns 4 | % 5 | % Y = 1 ./ (1 + EXP(X)) ; 6 | % 7 | % Remark:: 8 | % Useful properties of the sigmoid function are: 9 | % 10 | % - 1 - VL_SIGMOID(X) = VL_SIGMOID(-X) 11 | % - Centered sigmoid: 2 * VL_SIGMOID(X) - 1 ; 12 | % - VL_SIGMOID(X) = (EXP(X/2) - EXP(X/2)) / (EXP(X/2) + EXP(X/2)) 13 | % 14 | % See also: VL_DSIGMOID(), VL_HELP(). 15 | 16 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 17 | % All rights reserved. 18 | % 19 | % This file is part of the VLFeat library and is made available under 20 | % the terms of the BSD license (see the COPYING file). 21 | 22 | y = 1 ./ (1 + exp(-x)) ; 23 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/vl_root.m: -------------------------------------------------------------------------------- 1 | function path = vl_root 2 | % VL_ROOT Obtain VLFeat root path 3 | % PATH = VL_ROOT() returns the path to the VLFeat installation. 4 | % 5 | % See also: VL_SETUP(), VL_HELP(). 6 | 7 | % Authors: Andrea Vedaldi and Brian Fulkerson 8 | 9 | % Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 10 | % All rights reserved. 11 | % 12 | % This file is part of the VLFeat library and is made available under 13 | % the terms of the BSD license (see the COPYING file). 14 | 15 | [a,b,c] = fileparts(mfilename('fullpath')) ; 16 | [a,b,c] = fileparts(a) ; 17 | path = a ; 18 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/xtest/vl_assert_almost_equal.m: -------------------------------------------------------------------------------- 1 | function vl_assert_almost_equal(x, y, varargin) 2 | epsilon = 1e-6 ; 3 | if length(varargin) > 0 4 | if isnumeric(varargin{1}) 5 | epsilon = varargin{1} ; 6 | varargin(1) = [] ; 7 | end 8 | end 9 | assert(isequal(class(x), class(y)), varargin{:}) ; 10 | assert(isequal(size(x), size(y)), varargin{:}) ; 11 | if isstruct(x) 12 | fx = fieldnames(x) ; 13 | fy = fieldnames(y) ; 14 | assert(isequal(fx,fy), varargin{:}) ; 15 | for i=1:numel(fx) 16 | vl_assert_almost_equal(x.(fx{i}), y.(fy{i}), epsilon, varargin{:}) ; 17 | end 18 | else 19 | i = isnan(x) ; 20 | j = isnan(y) ; 21 | assert(isequal(i,j), varargin{:}) ; 22 | assert(max(abs(x(~i) - y(~i))) < epsilon, varargin{:}) ; 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/xtest/vl_assert_equal.m: -------------------------------------------------------------------------------- 1 | function vl_assert_equal(x, y, varargin) 2 | assert(isequalwithequalnans(x,y),varargin{:}) ; 3 | end 4 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/xtest/vl_assert_exception.m: -------------------------------------------------------------------------------- 1 | function vl_assert_exception(func, errorId, errorMessage) 2 | % VL_ASSERT_EXCEPTION 3 | 4 | try 5 | func() ; 6 | catch 7 | e = lasterror ; 8 | if nargin >= 2 9 | assert(isequal(e.identifier, errorId), ... 10 | 'Exception ID ''%s'' is not ''%s''.', ... 11 | e.identifier, errorId) ; 12 | end 13 | if nargin >= 3 14 | assert(isequal(e.message, errorMessage), ... 15 | 'Exception message ''%s'' is not ''%s''.', ... 16 | e.message, errorMessage) ; 17 | end 18 | return ; 19 | end 20 | assert(0, 'The function did not generate an exception.') ; 21 | end 22 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/xtest/vl_test_colsubset.m: -------------------------------------------------------------------------------- 1 | function results = vl_test_colsubset(varargin) 2 | % VL_TEST_COLSUBSET 3 | vl_test_init ; 4 | 5 | function s = setup() 6 | s.x = [5 2 3 6 4 7 1 9 8 0] ; 7 | 8 | function test_beginning(s) 9 | vl_assert_equal(1:5, vl_colsubset(1:10, 5, 'beginning')) ; 10 | vl_assert_equal(1:5, vl_colsubset(1:10, .5, 'beginning')) ; 11 | 12 | function test_ending(s) 13 | vl_assert_equal(6:10, vl_colsubset(1:10, 5, 'ending')) ; 14 | vl_assert_equal(6:10, vl_colsubset(1:10, .5, 'ending')) ; 15 | 16 | function test_largest(s) 17 | vl_assert_equal([5 6 7 9 8], vl_colsubset(s.x, 5, 'largest')) ; 18 | vl_assert_equal([5 6 7 9 8], vl_colsubset(s.x, .5, 'largest')) ; 19 | 20 | function test_smallest(s) 21 | vl_assert_equal([2 3 4 1 0], vl_colsubset(s.x, 5, 'smallest')) ; 22 | vl_assert_equal([2 3 4 1 0], vl_colsubset(s.x, .5, 'smallest')) ; 23 | 24 | function test_random(s) 25 | assert(numel(intersect(s.x, vl_colsubset(s.x, 5, 'random'))) == 5) ; 26 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/xtest/vl_test_grad.m: -------------------------------------------------------------------------------- 1 | function results = vl_test_grad(varargin) 2 | % VL_TEST_GRAD 3 | vl_test_init ; 4 | 5 | function s = setup() 6 | s.I = rand(150,253) ; 7 | s.I_small = rand(2,2) ; 8 | 9 | function test_equiv(s) 10 | vl_assert_equal(gradient(s.I), vl_grad(s.I)) ; 11 | 12 | function test_equiv_small(s) 13 | vl_assert_equal(gradient(s.I_small), vl_grad(s.I_small)) ; 14 | 15 | function test_equiv_forward(s) 16 | Ix = diff(s.I,2,1) ; 17 | Iy = diff(s.I,2,1) ; 18 | 19 | vl_assert_equal(gradient(s.I_small), vl_grad(s.I_small)) ; 20 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/xtest/vl_test_hikmeans.m: -------------------------------------------------------------------------------- 1 | function results = vl_test_hikmeans(varargin) 2 | % VL_TEST_IKMEANS 3 | vl_test_init ; 4 | 5 | function s = setup() 6 | rand('state',0) ; 7 | s.data = uint8(rand(2,1000) * 255) ; 8 | 9 | function test_basic(s) 10 | [tree, assign] = vl_hikmeans(s.data,3,100) ; 11 | assign_ = vl_hikmeanspush(tree, s.data) ; 12 | vl_assert_equal(assign,assign_) ; 13 | 14 | function test_elkan(s) 15 | [tree, assign] = vl_hikmeans(s.data,3,100,'method','elkan') ; 16 | assign_ = vl_hikmeanspush(tree, s.data) ; 17 | vl_assert_equal(assign,assign_) ; 18 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/xtest/vl_test_ihashsum.m: -------------------------------------------------------------------------------- 1 | function results = vl_test_ihashsum(varargin) 2 | % VL_TEST_IHASHSUM 3 | vl_test_init ; 4 | 5 | function s = setup() 6 | rand('state',0) ; 7 | s.data = uint8(round(16*rand(2,100))) ; 8 | sel = find(all(s.data==0)) ; 9 | s.data(1,sel)=1 ; 10 | 11 | function test_hash(s) 12 | D = size(s.data,1) ; 13 | K = 5 ; 14 | h = zeros(1,K,'uint32') ; 15 | id = zeros(D,K,'uint8'); 16 | next = zeros(1,K,'uint32') ; 17 | [h,id,next] = vl_ihashsum(h,id,next,K,s.data) ; 18 | 19 | sel = vl_ihashfind(id,next,K,s.data) ; 20 | count = double(h(sel)) ; 21 | 22 | [drop,i,j] = unique(s.data','rows') ; 23 | for k=1:size(s.data,2) 24 | count_(k) = sum(j == j(k)) ; 25 | end 26 | vl_assert_equal(count,count_) ; 27 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/xtest/vl_test_ikmeans.m: -------------------------------------------------------------------------------- 1 | function results = vl_test_ikmeans(varargin) 2 | % VL_TEST_IKMEANS 3 | vl_test_init ; 4 | 5 | function s = setup() 6 | rand('state',0) ; 7 | s.data = uint8(rand(2,1000) * 255) ; 8 | 9 | function test_basic(s) 10 | [centers, assign] = vl_ikmeans(s.data,100) ; 11 | assign_ = vl_ikmeanspush(s.data, centers) ; 12 | vl_assert_equal(assign,assign_) ; 13 | 14 | function test_elkan(s) 15 | [centers, assign] = vl_ikmeans(s.data,100,'method','elkan') ; 16 | assign_ = vl_ikmeanspush(s.data, centers) ; 17 | vl_assert_equal(assign,assign_) ; 18 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/xtest/vl_test_imwbackward.m: -------------------------------------------------------------------------------- 1 | function results = vl_test_imwbackward(varargin) 2 | % VL_TEST_IMWBACKWARD 3 | vl_test_init ; 4 | 5 | function s = setup() 6 | s.I = im2double(imread(fullfile(vl_root,'data','spots.jpg'))) ; 7 | 8 | function test_identity(s) 9 | xr = 1:size(s.I,2) ; 10 | yr = 1:size(s.I,1) ; 11 | [x,y] = meshgrid(xr,yr) ; 12 | vl_assert_almost_equal(s.I, vl_imwbackward(xr,yr,s.I,x,y)) ; 13 | 14 | function test_invalid_args(s) 15 | xr = 1:size(s.I,2) ; 16 | yr = 1:size(s.I,1) ; 17 | [x,y] = meshgrid(xr,yr) ; 18 | vl_assert_exception(@() vl_imwbackward(xr,yr,single(s.I),x,y), 'vl:invalidArgument') ; 19 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/xtest/vl_test_mser.m: -------------------------------------------------------------------------------- 1 | function results = vl_test_mser(varargin) 2 | % VL_TEST_MSER 3 | vl_test_init ; 4 | 5 | function s = setup() 6 | s.im = im2uint8(rgb2gray(vl_impattern('roofs1'))) ; 7 | 8 | function test_mser(s) 9 | [regions,frames] = vl_mser(s.im) ; 10 | mask = vl_erfill(s.im, regions(1)) ; 11 | 12 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/xtest/vl_test_phow.m: -------------------------------------------------------------------------------- 1 | function results = vl_test_phow(varargin) 2 | % VL_TEST_PHOPW 3 | vl_test_init ; 4 | 5 | function s = setup() 6 | s.I = im2double(imread(fullfile(vl_root,'data','spots.jpg'))) ; 7 | s.I = single(s.I) ; 8 | 9 | function test_gray(s) 10 | [f,d] = vl_phow(s.I, 'color', 'gray') ; 11 | assert(size(d,1) == 128) ; 12 | 13 | function test_rgb(s) 14 | [f,d] = vl_phow(s.I, 'color', 'rgb') ; 15 | assert(size(d,1) == 128*3) ; 16 | 17 | function test_hsv(s) 18 | [f,d] = vl_phow(s.I, 'color', 'hsv') ; 19 | assert(size(d,1) == 128*3) ; 20 | 21 | function test_opponent(s) 22 | [f,d] = vl_phow(s.I, 'color', 'opponent') ; 23 | assert(size(d,1) == 128*3) ; 24 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/xtest/vl_test_plotbox.m: -------------------------------------------------------------------------------- 1 | function results = vl_test_plotbox(varargin) 2 | % VL_TEST_PLOTBOX 3 | vl_test_init ; 4 | 5 | function test_basic(s) 6 | figure(1) ; clf ; 7 | vl_plotbox([-1 -1 1 1]') ; 8 | xlim([-2 2]) ; 9 | ylim([-2 2]) ; 10 | close(1) ; 11 | 12 | function test_multiple(s) 13 | figure(1) ; clf ; 14 | randn('state', 0) ; 15 | vl_plotbox(randn(4,10)) ; 16 | close(1) ; 17 | 18 | function test_style(s) 19 | figure(1) ; clf ; 20 | randn('state', 0) ; 21 | vl_plotbox(randn(4,10), 'r-.', 'LineWidth', 3) ; 22 | close(1) ; 23 | 24 | 25 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/toolbox/xtest/vl_test_slic.m: -------------------------------------------------------------------------------- 1 | function results = vl_test_slic(varargin) 2 | % VL_TEST_SLIC 3 | vl_test_init ; 4 | 5 | function s = setup() 6 | s.im = im2single(vl_impattern('roofs1')) ; 7 | 8 | function test_slic(s) 9 | segmentation = vl_slic(s.im, 10, 0.1) ; 10 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/vl/rodrigues.h: -------------------------------------------------------------------------------- 1 | /** @file rodrigues.h 2 | ** @brief Rodrigues formulas 3 | ** @author Andrea Vedaldi 4 | **/ 5 | 6 | /* 7 | Copyright (C) 2007-13 Andrea Vedaldi and Brian Fulkerson. 8 | All rights reserved. 9 | 10 | This file is part of the VLFeat library and is made available under 11 | the terms of the BSD license (see the COPYING file). 12 | */ 13 | 14 | /** @file rodrigues.h 15 | 16 | @section rodrigues Rodrigues formulas 17 | 18 | - Use ::vl_rodrigues to compute the Rodrigues formula and its derivative. 19 | - Use ::vl_irodrigues to compute the inverse Rodrigues formula and 20 | its derivative. 21 | 22 | **/ 23 | 24 | #ifndef VL_RODRIGUES 25 | #define VL_RODRIGUES 26 | 27 | #include "generic.h" 28 | 29 | VL_EXPORT void vl_rodrigues (double* R_pt, double* dR_pt, const double* om_pt) ; 30 | VL_EXPORT void vl_irodrigues (double* om_pt, double* dom_pt, const double* R_pt) ; 31 | 32 | /* VL_RODRIGUES */ 33 | #endif 34 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/vl/slic.h: -------------------------------------------------------------------------------- 1 | /** @file slic.h 2 | ** @brief SLIC superpixels (@ref slic) 3 | ** @author Andrea Vedaldi 4 | **/ 5 | 6 | /* 7 | Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. 8 | All rights reserved. 9 | 10 | This file is part of the VLFeat library and is made available under 11 | the terms of the BSD license (see the COPYING file). 12 | */ 13 | 14 | #ifndef VL_SLIC_H 15 | #define VL_SLIC_H 16 | 17 | #include "generic.h" 18 | 19 | VL_EXPORT void 20 | vl_slic_segment (vl_uint32 * segmentation, 21 | float const * image, 22 | vl_size width, 23 | vl_size height, 24 | vl_size numChannels, 25 | vl_size regionSize, 26 | float regularization, 27 | vl_size minRegionSize) ; 28 | 29 | /* VL_SLIC_H */ 30 | #endif 31 | -------------------------------------------------------------------------------- /video background subtraction/libs/vlfeat/vlfeat.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vlfeat", "vlfeat.vcxproj", "{07367665-DCDA-4044-94CE-ABC01CC4119D}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {07367665-DCDA-4044-94CE-ABC01CC4119D}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {07367665-DCDA-4044-94CE-ABC01CC4119D}.Debug|Win32.Build.0 = Debug|Win32 14 | {07367665-DCDA-4044-94CE-ABC01CC4119D}.Release|Win32.ActiveCfg = Release|Win32 15 | {07367665-DCDA-4044-94CE-ABC01CC4119D}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /video background subtraction/lrs_conf.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuezc/LRSD-TNNSR/9f4138da05253e6cf0d1cbd141911f7068ad59d6/video background subtraction/lrs_conf.mat -------------------------------------------------------------------------------- /video background subtraction/lrs_gui.m: -------------------------------------------------------------------------------- 1 | clc; main; -------------------------------------------------------------------------------- /video background subtraction/lrs_load_conf.m: -------------------------------------------------------------------------------- 1 | load('lrs_conf.mat'); -------------------------------------------------------------------------------- /video background subtraction/run_alg.m: -------------------------------------------------------------------------------- 1 | lower_R = 1; upper_R = 1; 2 | fprintf('now is running admm optimization method to recovery low-rank image and sparse image\n'); 3 | 4 | [Z,E] = admm_v(M,lower_R,upper_R); 5 | 6 | L = Z; 7 | S = E; -------------------------------------------------------------------------------- /video background subtraction/utils/convert_video2d_to_avi.m: -------------------------------------------------------------------------------- 1 | %%% convert_video2d_to_avi(2dmatrix,int,int,int) 2 | % I - Input matrix 3 | % nFrames - Number of frames 4 | % vidHeight - Video height 5 | % vidWidth - Video width 6 | % 7 | function convert_video2d_to_avi(I,nFrames,vidHeight,vidWidth,filename) 8 | %warning('off','all'); 9 | 10 | if(~isempty(I)) 11 | movobj_I(1:nFrames) = struct('cdata', [], 'colormap', []); 12 | else 13 | error('Invalid input matrix!'); 14 | end 15 | 16 | for i = 1 : nFrames 17 | % 18 | % Convert input to rgb image 19 | % 20 | Input = reshape(I(:,i),vidHeight,vidWidth); 21 | Input = mat2gray(Input); 22 | Input = im2uint8(Input); 23 | rgbImage = repmat(Input,[1 1 3]); 24 | movobj_I(i).cdata = rgbImage; 25 | end 26 | 27 | disp(['Saving results at: ' filename]); 28 | movie2avi(movobj_I, filename, 'compression', 'None'); 29 | disp('OK'); 30 | 31 | %warning('on','all'); 32 | end 33 | -------------------------------------------------------------------------------- /video background subtraction/utils/convert_video3d_to_2d.m: -------------------------------------------------------------------------------- 1 | %%% [2d_matrix, int, int, int] = convert_video3d_to_2d(3d_matrix) 2 | % 3 | function [M,m,n,p] = convert_video3d_to_2d(V) 4 | [m,n,p] = size(V); 5 | 6 | if(isa(V,'uint8')) 7 | M = uint8(zeros(m*n,p)); 8 | else 9 | M = zeros(m*n,p); 10 | end 11 | 12 | for i = 1:p 13 | M(:,i) = reshape(V(:,:,i),[],1); 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /video background subtraction/utils/convert_video3d_to_avi.m: -------------------------------------------------------------------------------- 1 | %%% void convert_video3d_to_avi(V,filename) 2 | % 3 | function convert_video3d_to_avi(V,filename) 4 | movobj(1:size(V,3)) = struct('cdata',[], 'colormap',[]); 5 | for i = 1:size(V,3) 6 | frame = V(:,:,i); 7 | frame = mat2gray(frame); 8 | frame = im2uint8(frame); 9 | rgb = repmat(frame,[1 1 3]); 10 | movobj(i).cdata = rgb; 11 | end 12 | movie2avi(movobj, filename, 'compression', 'None'); 13 | end 14 | -------------------------------------------------------------------------------- /video background subtraction/utils/convert_video4d_to_avi.m: -------------------------------------------------------------------------------- 1 | %%% void convert_video4d_to_avi(V,filename) 2 | % 3 | function convert_video4d_to_avi(video,filename) 4 | movobj(1:size(video,4)) = struct('cdata',[], 'colormap',[]); 5 | 6 | for i = 1:size(video,4) 7 | frame = video(:,:,:,i); 8 | 9 | if(size(frame,3) == 1) 10 | frame = repmat(frame,[1 1 3]); 11 | end 12 | 13 | movobj(i).cdata = frame; 14 | end 15 | 16 | movie2avi(movobj, filename, 'compression', 'None'); 17 | end 18 | -------------------------------------------------------------------------------- /video background subtraction/utils/convert_video_to_2d.m: -------------------------------------------------------------------------------- 1 | %%% [2dmatrix] = convert_video_to_2d(struct) 2 | % 3 | function [I] = convert_video_to_2d(video) 4 | I = uint8(zeros(video.width*video.height,video.nrFramesTotal)); 5 | 6 | for i = 1:video.nrFramesTotal 7 | frame = video.frames(i).cdata; 8 | if(size(frame,3) == 3) 9 | frame = rgb2gray(frame); 10 | end 11 | I(:,i) = reshape(frame,[],1); 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /video background subtraction/utils/convert_video_to_3d.m: -------------------------------------------------------------------------------- 1 | %%% [3dmatrix] = convert_video_to_3d(struct) 2 | % 3 | function [V] = convert_video_to_3d(video) 4 | for i = 1:video.nrFramesTotal 5 | frame = video.frames(i).cdata; 6 | if(size(frame,3) == 3) 7 | frame = rgb2gray(frame); 8 | end 9 | V(:,:,i) = frame; 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /video background subtraction/utils/convert_video_to_3dtensor.m: -------------------------------------------------------------------------------- 1 | %%% [tensor] = convert_video_to_3dtensor(struct) 2 | % 3 | function [T] = convert_video_to_3dtensor(video) 4 | V = convert_video_to_3d(video); 5 | T = tensor(V); 6 | end 7 | -------------------------------------------------------------------------------- /video background subtraction/utils/convert_video_to_4d.m: -------------------------------------------------------------------------------- 1 | %%% [4dmatrix] = convert_video_to_4d(struct) 2 | % 3 | function [V] = convert_video_to_4d(video) 4 | for i = 1:video.nrFramesTotal 5 | frame = video.frames(i).cdata; 6 | V(:,:,:,i) = frame; 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /video background subtraction/utils/crop_4dvideo.m: -------------------------------------------------------------------------------- 1 | %%% [video_aux] = crop_4dvideo(video,r,s) 2 | % 3 | function [video_aux] = crop_4dvideo(video,r,s) 4 | if(s == -1) 5 | s = size(video,4); 6 | end 7 | 8 | k = 1; 9 | for i = r : s 10 | video_aux(:,:,:,k) = video(:,:,:,i); 11 | k = k + 1; 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /video background subtraction/utils/displog.m: -------------------------------------------------------------------------------- 1 | %% void displog(string) 2 | % msg - string 3 | % 4 | function displog(msg) 5 | disp([datestr(now, 'HH:MM:SS') ' ' msg]); 6 | end 7 | -------------------------------------------------------------------------------- /video background subtraction/utils/gen_file_name.m: -------------------------------------------------------------------------------- 1 | %% string gen_file_name(string,string) 2 | % fileName - string 3 | % extra - string 4 | % newFileName - string 5 | % 6 | function [newFileName] = gen_file_name(fileName,extra) 7 | %ext = get_file_extension(fileName); 8 | %newFileName = [fileName(1:length(fileName)-4) extra ext]; 9 | [pathstr,name,ext] = fileparts(fileName); 10 | newFileName = fullfile(pathstr,[name extra ext]); 11 | end 12 | -------------------------------------------------------------------------------- /video background subtraction/utils/get_file_extension.m: -------------------------------------------------------------------------------- 1 | %% string get_file_extension(string) 2 | % filePath - string 3 | % ext - string 4 | % 5 | function [ext] = get_file_extension(fileName) 6 | %ext = fileName(length(fileName)-2:length(fileName)); 7 | [~,~,ext] = fileparts(fileName); 8 | ext = ext(2:end); 9 | end 10 | -------------------------------------------------------------------------------- /video background subtraction/utils/isemptydir.m: -------------------------------------------------------------------------------- 1 | function x = isemptydir(p,k) 2 | if(isdir(p)) 3 | f = dir(p); 4 | x = ~(length(f) > k); 5 | else 6 | error('Error: %s is not a directory'); 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /video background subtraction/utils/nma_rescale.m: -------------------------------------------------------------------------------- 1 | function C = nma_rescale(A,new_min,new_max) 2 | %Nasser M. Abbasi 011212 3 | %NO ERROR CHECKING DONE ON INPUT. Rescale a matrix or a vector A 4 | current_max = max(A(:)); 5 | current_min = min(A(:)); 6 | C =((A-current_min)*(new_max-new_min))/(current_max-current_min) + new_min; 7 | end -------------------------------------------------------------------------------- /video background subtraction/utils/resize_4dvideo.m: -------------------------------------------------------------------------------- 1 | %%% [video_aux] = resize_4dvideo(video,double) 2 | % f : [0,...,1,...,N] 3 | function [video_aux] = resize_4dvideo(video,f) 4 | [~, ~, ~, nFrames] = size(video); 5 | for i = 1 : nFrames 6 | frame = video(:,:,:,i); 7 | frame = imresize(frame,f); 8 | video_aux(:,:,:,i) = frame; 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /video background subtraction/utils/show_2dvideo.m: -------------------------------------------------------------------------------- 1 | %%% show_2dvideo(2dmatrix,int,int) 2 | % 3 | function show_2dvideo(M,m,n) 4 | for i = 1 : size(M,2) 5 | I = reshape(M(:,i),m,n); 6 | imshow(I,[],'InitialMagnification','fit'); 7 | disp(i); 8 | pause(0.01); 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /video background subtraction/utils/show_3dvideo.m: -------------------------------------------------------------------------------- 1 | %%% void show_3dvideo(3dmatrix) 2 | % 3 | function show_3dvideo(V) 4 | for i = 1 : size(V,3) 5 | frame = V(:,:,i); 6 | imshow(frame,[],'InitialMagnification','fit'); 7 | disp(i); 8 | pause(0.01); 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /video background subtraction/utils/show_4dvideo.m: -------------------------------------------------------------------------------- 1 | %%% void show_4dvideo(4dmatrix) 2 | % 3 | function show_4dvideo(video) 4 | for i = 1 : size(video,4) 5 | frame = video(:,:,:,i); 6 | imshow(frame,[],'InitialMagnification','fit'); 7 | disp(i); 8 | pause(0.01); 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /video background subtraction/utils/show_Svideo.m: -------------------------------------------------------------------------------- 1 | %%% void show_Svideo(struct) 2 | % 3 | function show_Svideo(V) 4 | for i = 1 : size(V,2) 5 | frame = V{i}; 6 | imshow(frame,[],'InitialMagnification','fit'); 7 | disp(i); 8 | pause(0.01); 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /video background subtraction/utils/show_video.m: -------------------------------------------------------------------------------- 1 | %%% void show_video(struct) 2 | % 3 | function show_video(video) 4 | for i = 1 : video.nrFramesTotal 5 | frame = video.frames(i).cdata; 6 | imshow(frame,[],'InitialMagnification','fit'); 7 | disp(i); 8 | pause(0.01); 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /video background subtraction/utils/subsampling.m: -------------------------------------------------------------------------------- 1 | %% 2 | % [Idx, Omega] = subsampling(data, obs) 3 | % 4 | % data - matrix/tensor 5 | % obs - double (percentual of observed entries) [0...1] 6 | % 7 | % Idx - observed indexes 8 | % Omega - binary matrix/tensor 9 | % 10 | function [Idx, Omega] = subsampling(data, obs) 11 | if(nargin < 1 || nargin > 2) 12 | error('data must be defined'); 13 | end 14 | if(nargin == 1) 15 | obs = 0.5; % 50% of observed values (default) 16 | end 17 | nae = numel(double(data)); 18 | rp = randperm(nae)'; 19 | k = floor(obs*nae); 20 | Idx = rp(1:k); 21 | Omega = zeros(size(data)); 22 | Omega(Idx) = 1; 23 | end 24 | -------------------------------------------------------------------------------- /video background subtraction/utils/video2mat.m: -------------------------------------------------------------------------------- 1 | %%% void = video2mat(string, string) 2 | % input - string 3 | % output - string 4 | % 5 | % i.e: video2mat('dataset/video.avi', 'dataset/video.mat') 6 | % 7 | function video2mat(input, output) 8 | video = load_video_file(input); 9 | save(output,'video'); 10 | disp('Saved!'); 11 | end 12 | --------------------------------------------------------------------------------