filter.h
Go to the documentation of this file.
00001 /*
00002 Copyright 2012. All rights reserved.
00003 Institute of Measurement and Control Systems
00004 Karlsruhe Institute of Technology, Germany
00005 
00006 This file is part of libelas.
00007 Authors: Julius Ziegler, Andreas Geiger
00008 
00009 libelas is free software; you can redistribute it and/or modify it under the
00010 terms of the GNU General Public License as published by the Free Software
00011 Foundation; either version 3 of the License, or any later version.
00012 
00013 libelas is distributed in the hope that it will be useful, but WITHOUT ANY
00014 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
00015 PARTICULAR PURPOSE. See the GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License along with
00018 libelas; if not, write to the Free Software Foundation, Inc., 51 Franklin
00019 Street, Fifth Floor, Boston, MA 02110-1301, USA 
00020 */
00021 
00022 #ifndef __FILTER_H__
00023 #define __FILTER_H__
00024 
00025 #include <emmintrin.h>
00026 #include <pmmintrin.h>
00027 
00028 // define fixed-width datatypes for Visual Studio projects
00029 #ifndef _MSC_VER
00030   #include <stdint.h>
00031 #else
00032   typedef __int8            int8_t;
00033   typedef __int16           int16_t;
00034   typedef __int32           int32_t;
00035   typedef __int64           int64_t;
00036   typedef unsigned __int8   uint8_t;
00037   typedef unsigned __int16  uint16_t;
00038   typedef unsigned __int32  uint32_t;
00039   typedef unsigned __int64  uint64_t;
00040 #endif
00041 
00042 // fast filters: implements 3x3 and 5x5 sobel filters and 
00043 //               5x5 blob and corner filters based on SSE2/3 instructions
00044 namespace filter {
00045   
00046   // private namespace, public user functions at the bottom of this file
00047   namespace detail {
00048     void integral_image( const uint8_t* in, int32_t* out, int w, int h );
00049     void unpack_8bit_to_16bit( const __m128i a, __m128i& b0, __m128i& b1 );
00050     void pack_16bit_to_8bit_saturate( const __m128i a0, const __m128i a1, __m128i& b );
00051     
00052     // convolve image with a (1,4,6,4,1) row vector. Result is accumulated into output.
00053     // output is scaled by 1/128, then clamped to [-128,128], and finally shifted to [0,255].
00054     void convolve_14641_row_5x5_16bit( const int16_t* in, uint8_t* out, int w, int h );
00055     
00056     // convolve image with a (1,2,0,-2,-1) row vector. Result is accumulated into output.
00057     // This one works on 16bit input and 8bit output.
00058     // output is scaled by 1/128, then clamped to [-128,128], and finally shifted to [0,255].
00059     void convolve_12021_row_5x5_16bit( const int16_t* in, uint8_t* out, int w, int h );
00060 
00061     // convolve image with a (1,2,1) row vector. Result is accumulated into output.
00062     // This one works on 16bit input and 8bit output.
00063     // output is scaled by 1/4, then clamped to [-128,128], and finally shifted to [0,255].
00064     void convolve_121_row_3x3_16bit( const int16_t* in, uint8_t* out, int w, int h );
00065     
00066     // convolve image with a (1,0,-1) row vector. Result is accumulated into output.
00067     // This one works on 16bit input and 8bit output.
00068     // output is scaled by 1/4, then clamped to [-128,128], and finally shifted to [0,255].
00069     void convolve_101_row_3x3_16bit( const int16_t* in, uint8_t* out, int w, int h );
00070     
00071     void convolve_cols_5x5( const unsigned char* in, int16_t* out_v, int16_t* out_h, int w, int h );
00072     
00073     void convolve_col_p1p1p0m1m1_5x5( const unsigned char* in, int16_t* out, int w, int h );
00074     
00075     void convolve_row_p1p1p0m1m1_5x5( const int16_t* in, int16_t* out, int w, int h );
00076     
00077     void convolve_cols_3x3( const unsigned char* in, int16_t* out_v, int16_t* out_h, int w, int h );
00078   }
00079   
00080   void sobel3x3( const uint8_t* in, uint8_t* out_v, uint8_t* out_h, int w, int h );
00081   
00082   void sobel5x5( const uint8_t* in, uint8_t* out_v, uint8_t* out_h, int w, int h );
00083   
00084   // -1 -1  0  1  1
00085   // -1 -1  0  1  1
00086   //  0  0  0  0  0
00087   //  1  1  0 -1 -1
00088   //  1  1  0 -1 -1
00089   void checkerboard5x5( const uint8_t* in, int16_t* out, int w, int h );
00090   
00091   // -1 -1 -1 -1 -1
00092   // -1  1  1  1 -1
00093   // -1  1  8  1 -1
00094   // -1  1  1  1 -1
00095   // -1 -1 -1 -1 -1
00096   void blob5x5( const uint8_t* in, int16_t* out, int w, int h );
00097 };
00098 
00099 #endif


libviso2
Author(s): Andreas Geiger, Stephan Wirth
autogenerated on Thu Jun 6 2019 21:23:13