vl_lbp.c
Go to the documentation of this file.
00001 
00007 /*
00008 Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
00009 All rights reserved.
00010 
00011 This file is part of the VLFeat library and is made available under
00012 the terms of the BSD license (see the COPYING file).
00013 */
00014 
00015 #include <mexutils.h>
00016 #include <vl/lbp.h>
00017 
00018 void
00019 mexFunction(int nout, mxArray *out[],
00020             int nin, const mxArray *in[])
00021 {
00022   float * image ;
00023   vl_size width, height ;
00024   vl_size cellSize = 16 ;
00025   enum {IN_I = 0, IN_CELLSIZE} ;
00026   enum {OUT_FEATURES = 0} ;
00027 
00028   /* -----------------------------------------------------------------
00029    *                                               Check the arguments
00030    * -------------------------------------------------------------- */
00031 
00032   if (nin > 2) {
00033     vlmxError(vlmxErrTooManyInputArguments, NULL) ;
00034   }
00035   if (nin < 2) {
00036     vlmxError(vlmxErrNotEnoughInputArguments, NULL) ;
00037   }
00038   if (nout > 1) {
00039     vlmxError(vlmxErrTooManyOutputArguments, NULL) ;
00040   }
00041 
00042   if (! mxIsNumeric(IN(I)) ||
00043       ! vlmxIsReal(IN(I)) ||
00044       ! vlmxIsMatrix(IN(I), -1, -1)) {
00045     vlmxError(vlmxErrInvalidArgument,
00046               "I is not a numeric matrix.") ;
00047   }
00048 
00049   if (mxGetClassID(IN(I)) != mxSINGLE_CLASS) {
00050     vlmxError(vlmxErrInvalidArgument,
00051               "I is not of class SINGLE.") ;
00052   }
00053 
00054   if (! vlmxIsPlainScalar(IN(CELLSIZE))) {
00055     vlmxError(vlmxErrInvalidArgument,
00056               "CELLSIZE is not a plain scalar.") ;
00057   }
00058 
00059   if (mxGetScalar(IN(CELLSIZE)) < 1.0) {
00060     vlmxError(vlmxErrInvalidArgument,
00061               "CELLSIZE is less than 1.") ;
00062   }
00063 
00064   cellSize = (vl_size) mxGetScalar(IN(CELLSIZE)) ;
00065   image = mxGetData(IN(I)) ;
00066   width = mxGetN(IN(I)) ;
00067   height = mxGetM(IN(I)) ;
00068 
00069   /* do job */
00070   {
00071     /* recall that MATLAB images are transposed */
00072     mwSize dimensions [3] ;
00073 
00074     /* get LBP object */
00075     VlLbp * lbp = vl_lbp_new (VlLbpUniform, VL_TRUE) ;
00076     if (lbp == NULL) {
00077       vlmxError(vlmxErrAlloc, NULL) ;
00078     }
00079 
00080     /* get output buffer */
00081     dimensions[0] = height / cellSize ;
00082     dimensions[1] = width / cellSize ;
00083     dimensions[2] = vl_lbp_get_dimension(lbp) ;
00084 
00085     OUT(FEATURES) = mxCreateNumericArray(3, dimensions, mxSINGLE_CLASS, mxREAL) ;
00086 
00087     vl_lbp_process(lbp, mxGetData(OUT(FEATURES)), image, height, width, cellSize) ;
00088     vl_lbp_delete(lbp) ;
00089   }
00090 }


libvlfeat
Author(s): Andrea Vedaldi
autogenerated on Thu Jun 6 2019 20:25:51