stereo-vision
All Data Structures Namespaces Functions Modules Pages
filter.h
1 /*
2 Copyright 2011. All rights reserved.
3 Institute of Measurement and Control Systems
4 Karlsruhe Institute of Technology, Germany
5 
6 This file is part of libelas.
7 Authors: Julius Ziegler, Andreas Geiger
8 
9 libelas is free software; you can redistribute it and/or modify it under the
10 terms of the GNU General Public License as published by the Free Software
11 Foundation; either version 3 of the License, or any later version.
12 
13 libelas is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License along with
18 libelas; if not, write to the Free Software Foundation, Inc., 51 Franklin
19 Street, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21 
22 #ifndef __FILTER_H__
23 #define __FILTER_H__
24 
25 #include <emmintrin.h>
26 #include <pmmintrin.h>
27 #include <stdint.h>
28 
29 // fast filters: implements 3x3 and 5x5 sobel filters and
30 // 5x5 blob and corner filters based on SSE2/3 instructions
31 namespace filter {
32 
33  // private namespace, public user functions at the bottom of this file
34  namespace detail {
35  void integral_image( const uint8_t* in, int32_t* out, int w, int h );
36  void unpack_8bit_to_16bit( const __m128i a, __m128i& b0, __m128i& b1 );
37  void pack_16bit_to_8bit_saturate( const __m128i a0, const __m128i a1, __m128i& b );
38 
39  // convolve image with a (1,4,6,4,1) row vector. Result is accumulated into output.
40  // output is scaled by 1/128, then clamped to [-128,128], and finally shifted to [0,255].
41  void convolve_14641_row_5x5_16bit( const int16_t* in, uint8_t* out, int w, int h );
42 
43  // convolve image with a (1,2,0,-2,-1) row vector. Result is accumulated into output.
44  // This one works on 16bit input and 8bit output.
45  // output is scaled by 1/128, then clamped to [-128,128], and finally shifted to [0,255].
46  void convolve_12021_row_5x5_16bit( const int16_t* in, uint8_t* out, int w, int h );
47 
48  // convolve image with a (1,2,1) row vector. Result is accumulated into output.
49  // This one works on 16bit input and 8bit output.
50  // output is scaled by 1/4, then clamped to [-128,128], and finally shifted to [0,255].
51  void convolve_121_row_3x3_16bit( const int16_t* in, uint8_t* out, int w, int h );
52 
53  // convolve image with a (1,0,-1) row vector. Result is accumulated into output.
54  // This one works on 16bit input and 8bit output.
55  // output is scaled by 1/4, then clamped to [-128,128], and finally shifted to [0,255].
56  void convolve_101_row_3x3_16bit( const int16_t* in, uint8_t* out, int w, int h );
57 
58  void convolve_cols_5x5( const unsigned char* in, int16_t* out_v, int16_t* out_h, int w, int h );
59 
60  void convolve_col_p1p1p0m1m1_5x5( const unsigned char* in, int16_t* out, int w, int h );
61 
62  void convolve_row_p1p1p0m1m1_5x5( const int16_t* in, int16_t* out, int w, int h );
63 
64  void convolve_cols_3x3( const unsigned char* in, int16_t* out_v, int16_t* out_h, int w, int h );
65  }
66 
67  void sobel3x3( const uint8_t* in, uint8_t* out_v, uint8_t* out_h, int w, int h );
68 
69  void sobel5x5( const uint8_t* in, uint8_t* out_v, uint8_t* out_h, int w, int h );
70 
71  // -1 -1 0 1 1
72  // -1 -1 0 1 1
73  // 0 0 0 0 0
74  // 1 1 0 -1 -1
75  // 1 1 0 -1 -1
76  void checkerboard5x5( const uint8_t* in, int16_t* out, int w, int h );
77 
78  // -1 -1 -1 -1 -1
79  // -1 1 1 1 -1
80  // -1 1 8 1 -1
81  // -1 1 1 1 -1
82  // -1 -1 -1 -1 -1
83  void blob5x5( const uint8_t* in, int16_t* out, int w, int h );
84 };
85 
86 #endif