quantizable_modality.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2010-2011, Willow Garage, Inc.
00006  *
00007  *  All rights reserved. 
00008  *
00009  *  Redistribution and use in source and binary forms, with or without
00010  *  modification, are permitted provided that the following conditions
00011  *  are met:
00012  *
00013  *   * Redistributions of source code must retain the above copyright
00014  *     notice, this list of conditions and the following disclaimer.
00015  *   * Redistributions in binary form must reproduce the above
00016  *     copyright notice, this list of conditions and the following
00017  *     disclaimer in the documentation and/or other materials provided
00018  *     with the distribution.
00019  *   * Neither the name of Willow Garage, Inc. nor the names of its
00020  *     contributors may be used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  */
00037 
00038 #include <pcl/recognition/quantizable_modality.h>
00039 #include <cstddef>
00040 #include <string.h>
00041 
00043 pcl::QuantizableModality::QuantizableModality ()
00044 {
00045 }
00046 
00048 pcl::QuantizableModality::~QuantizableModality ()
00049 {
00050 }
00051 
00053 pcl::QuantizedMap::QuantizedMap ()
00054   : data_ (0), width_ (0), height_ (0)
00055 {
00056 }
00057 
00059 pcl::QuantizedMap::QuantizedMap (const QuantizedMap & copy_me)
00060   : data_ (0), width_ (copy_me.width_), height_ (copy_me.height_)
00061 {
00062   data_.insert (data_.begin (), copy_me.data_.begin (), copy_me.data_.end ());
00063 }
00064 
00066 pcl::QuantizedMap::QuantizedMap (const size_t width, const size_t height)
00067   : data_ (width*height), width_ (width), height_ (height)
00068 {
00069 }
00070 
00072 pcl::QuantizedMap::~QuantizedMap ()
00073 {
00074 }
00075 
00077 void
00078 pcl::QuantizedMap::
00079 resize (const size_t width, const size_t height)
00080 {
00081   data_.resize (width*height);
00082   width_ = width;
00083   height_ = height;
00084 }
00085 
00087 void
00088 pcl::QuantizedMap::
00089 spreadQuantizedMap (const QuantizedMap & input_map, QuantizedMap & output_map, const size_t spreading_size)
00090 {
00091   // TODO: implement differently (as in opencv)
00092   const size_t width = input_map.getWidth ();
00093   const size_t height = input_map.getHeight ();
00094   const size_t half_spreading_size = spreading_size / 2;
00095 
00096   QuantizedMap tmp_map (width, height);
00097   output_map.resize (width, height);
00098 
00099   for (size_t row_index = 0; row_index < height-spreading_size-1; ++row_index)
00100   {
00101     for (size_t col_index = 0; col_index < width-spreading_size-1; ++col_index)
00102     {
00103       unsigned char value = 0;
00104       const unsigned char * data_ptr = &(input_map (col_index, row_index));
00105       for (size_t spreading_index = 0; spreading_index < spreading_size; ++spreading_index, ++data_ptr)
00106       {
00107         value |= *data_ptr;
00108       }
00109 
00110       tmp_map (col_index + half_spreading_size, row_index) = value;
00111     }
00112   }
00113 
00114   for (size_t row_index = 0; row_index < height-spreading_size-1; ++row_index)
00115   {
00116     for (size_t col_index = 0; col_index < width-spreading_size-1; ++col_index)
00117     {
00118       unsigned char value = 0;
00119       const unsigned char * data_ptr = &(tmp_map (col_index, row_index));
00120       for (size_t spreading_index = 0; spreading_index < spreading_size; ++spreading_index, data_ptr += width)
00121       {
00122         value |= *data_ptr;
00123       }
00124 
00125       output_map (col_index, row_index + half_spreading_size) = value;
00126     }
00127   }
00128 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:31:41