<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - lbp_abstract.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2014  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#undef</font> DLIB_LBP_ABSTRACT_Hh_
<font color='#0000FF'>#ifdef</font> DLIB_LBP_ABSTRACT_Hh_

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../image_processing/generic_image.h.html'>../image_processing/generic_image.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../pixel.h.html'>../pixel.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type,
        <font color='#0000FF'>typename</font> image_type2
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='make_uniform_lbp_image'></a>make_uniform_lbp_image</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> img,
        image_type2<font color='#5555FF'>&amp;</font> lbp
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        requires
            - image_type == an image object that implements the interface defined in
              dlib/image_processing/generic_image.h 
            - image_type2 == an image object that implements the interface defined in
              dlib/image_processing/generic_image.h 
            - image_type2 should contain a grayscale pixel type such as unsigned char.
        ensures
            - #lbp.nr() == img.nr()
            - #lbp.nc() == img.nc()
            - This function extracts the uniform local-binary-pattern feature at every pixel
              and stores it into #lbp.  In particular, we have the following for all valid 
              r and c:
                - #lbp[r][c] == the uniform LBP for the 3x3 pixel window centered on img[r][c].  
                  In particular, this is a value in the range 0 to 58 inclusive. 
            - We use the idea of uniform LBPs from the paper: 
                Face Description with Local Binary Patterns: Application to Face Recognition
                by Ahonen, Hadid, and Pietikainen.
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type,
        <font color='#0000FF'>typename</font> T
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='extract_histogram_descriptors'></a>extract_histogram_descriptors</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> img,
        <font color='#0000FF'>const</font> point<font color='#5555FF'>&amp;</font> loc,
        std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> histograms,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> cell_size <font color='#5555FF'>=</font> <font color='#979000'>10</font>,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> block_size <font color='#5555FF'>=</font> <font color='#979000'>4</font>,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> max_val <font color='#5555FF'>=</font> <font color='#979000'>58</font>
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        requires
            - image_type == an image object that implements the interface defined in
              dlib/image_processing/generic_image.h 
            - image_type contains unsigned char valued pixels.
            - T is some scalar type like int or double
            - All pixel values in img are &lt;= max_val
            - cell_size &gt;= 1
            - block_size &gt;= 1
            - max_val &lt; 256
        ensures
            - This function extracts histograms of pixel values from block_size*block_size
              windows in the area in img immediately around img[loc.y()][loc.x()].  The
              histograms are appended onto the end of #histograms.  Each window is
              cell_size pixels wide and tall.  Moreover, the windows do not overlap.
            - #histograms.size() == histograms.size() + block_size*block_size*(max_val+1)
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type,
        <font color='#0000FF'>typename</font> T
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='extract_uniform_lbp_descriptors'></a>extract_uniform_lbp_descriptors</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> img,
        std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> feats,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> cell_size <font color='#5555FF'>=</font> <font color='#979000'>10</font>
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        requires
            - cell_size &gt;= 1
            - T is some scalar type like int or double
        ensures
            - Extracts histograms of uniform local-binary-patterns from img.  The
              histograms are from densely tiled windows that are cell_size pixels wide and
              tall.  The windows do not overlap and cover all of img.
            - #feats.size() == 59*(number of windows that fit into img)
              (i.e. #feats contains the LBP histograms)
            - We will have taken the square root of all the histogram elements.  That is,
              #feats[i] is the square root of the number of LBPs that appeared in its
              corresponding window.
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type,
        <font color='#0000FF'>typename</font> T
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='extract_highdim_face_lbp_descriptors'></a>extract_highdim_face_lbp_descriptors</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> img,
        <font color='#0000FF'>const</font> full_object_detection<font color='#5555FF'>&amp;</font> det,
        std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> feats
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        requires
            - T is some scalar type like int or double
            - det.num_parts() == 68
        ensures
            - This function extracts the high-dimensional LBP feature described in the
              paper:
                Blessing of Dimensionality: High-dimensional Feature and Its Efficient
                Compression for Face Verification by Dong Chen, Xudong Cao, Fang Wen, and
                Jian Sun
            - #feats == the high-dimensional LBP descriptor.  It is the concatenation of
              many LBP histograms, each extracted from different scales and from different
              windows around different face landmarks.  We also take the square root of
              each histogram element before storing it into #feats.
            - #feats.size() == 99120
            - This function assumes img has already been aligned and normalized to a
              standard size.
            - This function assumes det contains a human face detection with face parts
              annotated using the annotation scheme from the iBUG 300-W face landmark
              dataset.  This means that det.part(i) gives the locations of different face
              landmarks according to the iBUG 300-W annotation scheme.
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_LBP_ABSTRACT_Hh_
</font>

</pre></body></html>