34 #ifndef __INCLUDE_MIST_CORNER__
35 #define __INCLUDE_MIST_CORNER__
38 #ifndef __INCLUDE_MIST_H__
42 #ifndef __INCLUDE_MIST_VECTOR__
43 #include "../vector.h"
46 #ifndef __INCLUDE_MIST_LIMITS__
47 #include "../limits.h"
50 #ifndef __INCLUDE_MIST_VECTOR__
51 #include "../vector.h"
54 #ifndef __INCLUDE_CONVERTER__
55 #include "../converter.h"
58 #ifndef __INCLUDE_MIST_THREAD__
59 #include "../thread.h"
62 #ifndef __INCLUDE_FILTER_LINEAR_FILTER_H__
75 namespace __corner_utility__
77 struct corner_position
87 corner_position(
int xx,
int yy,
double k ) : x( xx ), y( yy ), key( k ){ }
90 bool operator <(
const corner_position &f )
const
92 return( key < f.key );
96 static bool greater(
const corner_position &f1,
const corner_position &f2 )
126 template <
class T,
class Allocator,
template <
typename,
typename >
class LIST,
class TT,
class AAllocator >
144 image_type tmp, k1( 3, 3 ), k2( 3, 3 ), gx, gy;
148 k1( 0, 0 ) = -1; k1( 1, 0 ) = 0; k1( 2, 0 ) = 1;
149 k1( 0, 1 ) = -2; k1( 1, 1 ) = 0; k1( 2, 1 ) = 2;
150 k1( 0, 2 ) = -1; k1( 1, 2 ) = 0; k1( 2, 2 ) = 1;
152 k2( 0, 0 ) = -1; k2( 1, 0 ) = -2; k2( 2, 0 ) = -1;
153 k2( 0, 1 ) = 0; k2( 1, 1 ) = 0; k2( 2, 1 ) = 0;
154 k2( 0, 2 ) = +1; k2( 1, 2 ) = +2; k2( 2, 2 ) = +1;
156 linear_filter( tmp, gx, k1 );
157 linear_filter( tmp, gy, k2 );
159 vector_image_type work( in.
width( ), in.
height( ) ), wwork;
162 #pragma omp parallel for schedule( guided )
164 for(
int j = 0 ; j < static_cast< int >( tmp.height( ) ) ; j++ )
166 for( size_type i = 0 ; i < tmp.width( ) ; i++ )
168 double dx = gx( i, j );
169 double dy = gy( i, j );
171 work( i, j ) = vector_type( dx * dx, dy * dy, dx * dy );
179 average_filter( work, wwork, window_size, window_size );
184 typedef __corner_utility__::corner_position point_type;
185 typedef std::vector< point_type > point_list_type;
186 point_list_type point_list, out_list;
188 for( size_type j = 1 ; j < wwork.height( ) - 1 ; j++ )
190 for( size_type i = 1 ; i < wwork.width( ) - 1 ; i++ )
192 const vector_type &v = wwork( i, j );
193 double Mc = v.r * v.g - v.b * v.b - kappa * ( v.r + v.g ) * ( v.r + v.g );
197 point_list.push_back( point_type( i, j, Mc ) );
202 std::sort( point_list.begin( ), point_list.end( ), __corner_utility__::corner_position::greater );
204 min_distance = min_distance * min_distance;
205 for( size_type i = 0 ; i < point_list.size( ) && out_list.size( ) < max_corners ; i++ )
207 const point_type &v = point_list[ i ];
210 for( size_type l = 0 ; l < out_list.size( ) ; l++ )
212 const point_type &u = out_list[ l ];
213 if( ( v.x - u.x ) * ( v.x - u.x ) + ( v.y - u.y ) * ( v.y - u.y ) < min_distance )
222 out_list.push_back( v );
228 for( size_type i = 0 ; i < out_list.size( ) ; i++ )
230 out.push_back( ovector_type( out_list[ i ].x, out_list[ i ].y ) );
233 return( out.size( ) );
246 #endif // __INCLUDE_MIST_CORNER__