libeblearntools
/home/rex/ebltrunk/tools/libeblearntools/include/similar_patches.h
00001 /***************************************************************************
00002  *   Copyright (C) 2009 by Pierre Sermanet   *
00003  *   pierre.sermanet@gmail.com   *
00004  *   All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions are met:
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Redistribution under a license not approved by the Open Source
00014  *       Initiative (http://www.opensource.org) must display the
00015  *       following acknowledgement in all advertising material:
00016  *        This product includes software developed at the Courant
00017  *        Institute of Mathematical Sciences (http://cims.nyu.edu).
00018  *     * The names of the authors may not be used to endorse or promote products
00019  *       derived from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
00022  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00023  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00024  * DISCLAIMED. IN NO EVENT SHALL ThE AUTHORS BE LIABLE FOR ANY
00025  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00026  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00028  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00029  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031  ***************************************************************************/
00032 
00033 #ifndef SIMILAR_PATCHES_H_
00034 #define SIMILAR_PATCHES_H_
00035 
00036 #include "libidx.h"
00037 #ifdef __GUI__
00038 #include "libidxgui.h"
00039 #endif
00040 
00041 #include <vector>
00042 
00043 using namespace std;
00044 
00045 namespace ebl {
00046 
00048   // similar_patches
00049 
00050   class similar_patches {
00051   private:
00052     unsigned int                        max_similar_patches;
00053     unsigned int                        pheight;
00054     unsigned int                        pwidth;
00055     unsigned int                        iheight;
00056     unsigned int                        iwidth;
00057     unsigned int                        wdisplay;
00058     unsigned int                        display_index;
00059     vector< vector< idx<ubyte>* > *>    dataset;
00060     vector< vector< idx<ubyte>* > *>    current_patches;
00061   public:
00062     unsigned int                        max_current_patches;
00063     vector< pair<int, int> >            current_patches_xy;
00064 
00065     similar_patches(unsigned int maxcurrent, unsigned int maxsimilar,
00066                     unsigned int ph, unsigned int pw,
00067                     unsigned int ih, unsigned int iw);
00068     virtual ~similar_patches();
00069     bool add_similar_patch(idx<ubyte> &im, int h, 
00070                            int w, unsigned int index);
00071     bool current_patch_empty(unsigned int index);
00072     void display_dataset(unsigned int maxh, unsigned int maxw);
00073     bool save_dataset(const char *directory);
00074   };
00075 
00076 } // namespace ebl {
00077 
00078 #endif /* SIMILAR_PATCHES_H_ */