, OpenCV 16- ( 5), .
Huang [2]. , . 8- OpenCV. 65536 .
... O (log r), 16- . [3]
algorithm ++, , Weiss.
1) . , ( ).
memcpy( &v[0], &window[0], window.size() * sizeof(_Type) );
std::vector< _Type >::iterator it = v.begin() + v.size()/2;
std::nth_element( v.begin(), it, v.end() );
return *it;
2) . 65536 , , ? , , , (, float).
typedef std::map< _Type, int > Map;
for ( )
{
Map::iterator it = map.find( px );
if ( it->second > 1 )
it->second -= 1;
else
map.erase( it );
}
for ( )
{
Map::iterator lower = map.lower_bound( px );
if ( lower != map.end() && lower->first == px )
lower->second += 1;
else
map.insert( lower, std::pair<_Type,int>( px, 1 ) );
}
3) . , , 65536 , -, :
[0...65535] <- px
[0...4095] <- px / 16
[0...255] <- px / 256
[0...15] <- px / 4096
( ), . 16 .

. (1) , (2) (3) 8bpp OpenCV (). , OpenCV, 16 . [0,255], [0, 8020] ( 16 , ).
, , . N- , OpenCV ( 8bpp ), .
Windows 7, 8 x 3,4 Visual Studio v. 10. Mine , OpenCV . 2136x3201 (http://i.imgur.com/gg9Z2aB.jpg, Vogue).
[2]: , : " II:
", 1981 .
[3]: , : " ", 2006