PCL
MorphologicalOperator.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.4.0
6 // ----------------------------------------------------------------------------
7 // pcl/MorphologicalOperator.h - Released 2020-07-31T19:33:04Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2020 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (http://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_MorphologicalOperator_h
53 #define __PCL_MorphologicalOperator_h
54 
56 
57 #include <pcl/Defs.h>
58 #include <pcl/Diagnostics.h>
59 
60 #include <pcl/Exception.h>
61 #include <pcl/Math.h>
62 #include <pcl/PixelTraits.h>
63 #include <pcl/Selection.h>
64 #include <pcl/Sort.h>
65 #include <pcl/String.h>
66 #include <pcl/Utility.h>
67 
68 namespace pcl
69 {
70 
71 // ----------------------------------------------------------------------------
72 
80 class PCL_CLASS MorphologicalOperator
81 {
82 public:
83 
87  MorphologicalOperator() = default;
88 
92  MorphologicalOperator( const MorphologicalOperator& ) = default;
93 
98  {
99  }
100 
105  virtual MorphologicalOperator* Clone() const = 0;
106 
110  virtual String Description() const
111  {
112  return String();
113  }
114 
121  virtual bool IsDilation() const
122  {
123  return false;
124  }
125 
131  {
132  throw NotImplemented( *this, "Apply to 32-bit floating-point images" );
133  }
134 
140  {
141  throw NotImplemented( *this, "Apply to 64-bit floating-point images" );
142  }
143 
149  {
150  throw NotImplemented( *this, "Apply to 32-bit complex images" );
151  }
152 
158  {
159  throw NotImplemented( *this, "Apply to 64-bit complex images" );
160  }
161 
167  {
168  throw NotImplemented( *this, "Apply to 8-bit integer images" );
169  }
170 
176  {
177  throw NotImplemented( *this, "Apply to 16-bit integer images" );
178  }
179 
185  {
186  throw NotImplemented( *this, "Apply to 32-bit integer images" );
187  }
188 };
189 
190 // ----------------------------------------------------------------------------
191 
199 class PCL_CLASS ErosionFilter : public MorphologicalOperator
200 {
201 public:
202 
205  MorphologicalOperator* Clone() const override
206  {
207  return new ErosionFilter( *this );
208  }
209 
212  String Description() const override
213  {
214  return "Erosion";
215  }
216 
221  FloatPixelTraits::sample operator ()( FloatPixelTraits::sample* f, size_type n ) const override
222  {
223  return Operate( f, n );
224  }
225 
231  {
232  return Operate( f, n );
233  }
234 
239  UInt8PixelTraits::sample operator ()( UInt8PixelTraits::sample* f, size_type n ) const override
240  {
241  return Operate( f, n );
242  }
243 
249  {
250  return Operate( f, n );
251  }
252 
258  {
259  return Operate( f, n );
260  }
261 
262 private:
263 
264  template <typename T>
265  static T Operate( T* f, size_type n )
266  {
267  return *pcl::MinItem( f, f+n );
268  }
269 };
270 
271 // ----------------------------------------------------------------------------
272 
280 class PCL_CLASS DilationFilter : public MorphologicalOperator
281 {
282 public:
283 
286  MorphologicalOperator* Clone() const override
287  {
288  return new DilationFilter( *this );
289  }
290 
293  String Description() const override
294  {
295  return "Dilation";
296  }
297 
300  bool IsDilation() const override
301  {
302  return true;
303  }
304 
309  FloatPixelTraits::sample operator ()( FloatPixelTraits::sample* f, size_type n ) const override
310  {
311  return Operate( f, n );
312  }
313 
319  {
320  return Operate( f, n );
321  }
322 
327  UInt8PixelTraits::sample operator ()( UInt8PixelTraits::sample* f, size_type n ) const override
328  {
329  return Operate( f, n );
330  }
331 
337  {
338  return Operate( f, n );
339  }
340 
346  {
347  return Operate( f, n );
348  }
349 
350 private:
351 
352  template <typename T>
353  static T Operate( T* f, size_type n )
354  {
355  return *pcl::MaxItem( f, f+n );
356  }
357 };
358 
359 // ----------------------------------------------------------------------------
360 
368 class PCL_CLASS MedianFilter : public MorphologicalOperator
369 {
370 public:
371 
374  MorphologicalOperator* Clone() const override
375  {
376  return new MedianFilter( *this );
377  }
378 
381  String Description() const override
382  {
383  return "Median";
384  }
385 
390  FloatPixelTraits::sample operator ()( FloatPixelTraits::sample* f, size_type n ) const override
391  {
392  return Operate( f, n, (FloatPixelTraits*)0 );
393  }
394 
400  {
401  return Operate( f, n, (DoublePixelTraits*)0 );
402  }
403 
408  UInt8PixelTraits::sample operator ()( UInt8PixelTraits::sample* f, size_type n ) const override
409  {
410  return Operate( f, n, (UInt8PixelTraits*)0 );
411  }
412 
418  {
419  return Operate( f, n, (UInt16PixelTraits*)0 );
420  }
421 
427  {
428  return Operate( f, n, (UInt32PixelTraits*)0 );
429  }
430 
431 private:
432 
433 #define CMPXCHG( a, b ) \
434  if ( f[b] < f[a] ) pcl::Swap( f[a], f[b] )
435 
436 #define MEAN( a, b ) \
437  P::FloatToSample( (double( a ) + double( b ))/2 )
438 
439  template <typename T, class P>
440  static T Operate( T* f, size_type n, P* )
441  {
442  /*
443  * Use fast, hard-coded selection networks for n <= 32:
444  *
445  * Knuth, D. E., The Art of Computer Programming, volume 3: Sorting and
446  * Searching, Addison Wesley, 1973.
447  *
448  * Hillis, W. D., Co-evolving parasites improve simulated evolution as an
449  * optimization procedure.</em> Langton, C. et al. (Eds.), Artificial
450  * Life II. Addison Wesley, 1992.
451  *
452  * Hugues Juille, Evolution of Non-Deterministic Incremental Algorithms
453  * as a New Approach for Search in State Spaces, 1995.
454  *
455  * Use a quick selection algorithm for n > 32:
456  *
457  * William H. Press et al., Numerical Recipes 3rd Edition: The Art of
458  * Scientific Computing, Cambridge University Press, 2007, Section 8.5.
459  *
460  * Robert Sedgewick, Kevin Wayne, Algorithms, 4th Edition, Addison-Wesley
461  * Professional, 2011, pp 345-347.
462  */
463  switch ( n )
464  {
465  case 0: // ?!
466  return 0;
467  case 1: // !?
468  return f[0];
469  case 2:
470  return MEAN( f[0], f[1] );
471  case 3:
472  CMPXCHG( 0, 1 ); CMPXCHG( 1, 2 );
473  return pcl::Max( f[0], f[1] );
474  case 4:
475  CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 0, 2 );
476  CMPXCHG( 1, 3 );
477  return MEAN( f[1], f[2] );
478  case 5:
479  CMPXCHG( 0, 1 ); CMPXCHG( 3, 4 ); CMPXCHG( 0, 3 );
480  CMPXCHG( 1, 4 ); CMPXCHG( 1, 2 ); CMPXCHG( 2, 3 );
481  return pcl::Max( f[1], f[2] );
482  case 6:
483  CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 0, 2 );
484  CMPXCHG( 1, 3 ); CMPXCHG( 1, 2 ); CMPXCHG( 4, 5 );
485  CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 ); CMPXCHG( 1, 4 );
486  CMPXCHG( 2, 4 ); CMPXCHG( 3, 5 ); CMPXCHG( 3, 4 );
487  return MEAN( f[2], f[3] );
488  case 7:
489  CMPXCHG( 0, 5 ); CMPXCHG( 0, 3 ); CMPXCHG( 1, 6 );
490  CMPXCHG( 2, 4 ); CMPXCHG( 0, 1 ); CMPXCHG( 3, 5 );
491  CMPXCHG( 2, 6 ); CMPXCHG( 2, 3 ); CMPXCHG( 3, 6 );
492  CMPXCHG( 4, 5 ); CMPXCHG( 1, 4 ); CMPXCHG( 1, 3 );
493  return pcl::Min( f[3], f[4] );
494  case 8:
495  CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 ); CMPXCHG( 2, 6 );
496  CMPXCHG( 3, 7 ); CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 );
497  CMPXCHG( 4, 6 ); CMPXCHG( 5, 7 ); CMPXCHG( 2, 4 );
498  CMPXCHG( 3, 5 ); CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 );
499  CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 ); CMPXCHG( 1, 4 );
500  CMPXCHG( 3, 6 );
501  return MEAN( f[3], f[4] );
502  case 9:
503  CMPXCHG( 1, 2 ); CMPXCHG( 4, 5 ); CMPXCHG( 7, 8 );
504  CMPXCHG( 0, 1 ); CMPXCHG( 3, 4 ); CMPXCHG( 6, 7 );
505  CMPXCHG( 1, 2 ); CMPXCHG( 4, 5 ); CMPXCHG( 7, 8 );
506  CMPXCHG( 0, 3 ); CMPXCHG( 5, 8 ); CMPXCHG( 4, 7 );
507  CMPXCHG( 3, 6 ); CMPXCHG( 1, 4 ); CMPXCHG( 2, 5 );
508  CMPXCHG( 4, 7 ); CMPXCHG( 4, 2 ); CMPXCHG( 6, 4 );
509  return pcl::Min( f[2], f[4] );
510  case 10:
511  CMPXCHG( 4, 9 ); CMPXCHG( 3, 8 ); CMPXCHG( 2, 7 );
512  CMPXCHG( 1, 6 ); CMPXCHG( 0, 5 ); CMPXCHG( 1, 4 );
513  CMPXCHG( 6, 9 ); CMPXCHG( 0, 3 ); CMPXCHG( 5, 8 );
514  CMPXCHG( 0, 2 ); CMPXCHG( 3, 6 ); CMPXCHG( 7, 9 );
515  CMPXCHG( 0, 1 ); CMPXCHG( 2, 4 ); CMPXCHG( 5, 7 );
516  CMPXCHG( 8, 9 ); CMPXCHG( 1, 2 ); CMPXCHG( 4, 6 );
517  CMPXCHG( 7, 8 ); CMPXCHG( 3, 5 ); CMPXCHG( 2, 5 );
518  CMPXCHG( 6, 8 ); CMPXCHG( 1, 3 ); CMPXCHG( 4, 7 );
519  CMPXCHG( 2, 3 ); CMPXCHG( 6, 7 ); CMPXCHG( 3, 4 );
520  CMPXCHG( 5, 6 );
521  return MEAN( f[4], f[5] );
522  case 11:
523  CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 );
524  CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 ); CMPXCHG( 1, 3 );
525  CMPXCHG( 5, 7 ); CMPXCHG( 0, 2 ); CMPXCHG( 4, 6 );
526  CMPXCHG( 8, 10 ); CMPXCHG( 1, 2 ); CMPXCHG( 5, 6 );
527  CMPXCHG( 9, 10 ); CMPXCHG( 1, 5 ); CMPXCHG( 6, 10 );
528  CMPXCHG( 5, 9 ); CMPXCHG( 2, 6 ); CMPXCHG( 1, 5 );
529  CMPXCHG( 6, 10 ); CMPXCHG( 0, 4 ); CMPXCHG( 3, 7 );
530  CMPXCHG( 4, 8 ); CMPXCHG( 0, 4 ); CMPXCHG( 1, 4 );
531  CMPXCHG( 7, 10 ); CMPXCHG( 3, 8 ); CMPXCHG( 2, 3 );
532  CMPXCHG( 8, 9 ); CMPXCHG( 3, 5 ); CMPXCHG( 6, 8 );
533  return pcl::Min( f[5], f[6] );
534  case 12:
535  CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 );
536  CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 );
537  CMPXCHG( 1, 3 ); CMPXCHG( 5, 7 ); CMPXCHG( 9, 11 );
538  CMPXCHG( 0, 2 ); CMPXCHG( 4, 6 ); CMPXCHG( 8, 10 );
539  CMPXCHG( 1, 2 ); CMPXCHG( 5, 6 ); CMPXCHG( 9, 10 );
540  CMPXCHG( 1, 5 ); CMPXCHG( 6, 10 ); CMPXCHG( 5, 9 );
541  CMPXCHG( 2, 6 ); CMPXCHG( 1, 5 ); CMPXCHG( 6, 10 );
542  CMPXCHG( 0, 4 ); CMPXCHG( 7, 11 ); CMPXCHG( 3, 7 );
543  CMPXCHG( 4, 8 ); CMPXCHG( 0, 4 ); CMPXCHG( 7, 11 );
544  CMPXCHG( 1, 4 ); CMPXCHG( 7, 10 ); CMPXCHG( 3, 8 );
545  CMPXCHG( 2, 3 ); CMPXCHG( 8, 9 ); CMPXCHG( 3, 5 );
546  CMPXCHG( 6, 8 );
547  return MEAN( f[5], f[6] );
548  case 13:
549  CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 ); CMPXCHG( 2, 10 );
550  CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 ); CMPXCHG( 0, 4 );
551  CMPXCHG( 1, 5 ); CMPXCHG( 2, 6 ); CMPXCHG( 3, 7 );
552  CMPXCHG( 8, 12 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
553  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 0, 2 );
554  CMPXCHG( 1, 3 ); CMPXCHG( 4, 6 ); CMPXCHG( 5, 7 );
555  CMPXCHG( 8, 10 ); CMPXCHG( 9, 11 ); CMPXCHG( 2, 8 );
556  CMPXCHG( 3, 9 ); CMPXCHG( 6, 12 ); CMPXCHG( 2, 4 );
557  CMPXCHG( 3, 5 ); CMPXCHG( 6, 8 ); CMPXCHG( 7, 9 );
558  CMPXCHG( 10, 12 ); CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 );
559  CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 );
560  CMPXCHG( 10, 11 ); CMPXCHG( 1, 8 ); CMPXCHG( 3, 10 );
561  CMPXCHG( 5, 12 ); CMPXCHG( 3, 6 ); CMPXCHG( 5, 8 );
562  return pcl::Max( f[5], f[6] );
563  case 14:
564  CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 );
565  CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 );
566  CMPXCHG( 12, 13 ); CMPXCHG( 0, 2 ); CMPXCHG( 4, 6 );
567  CMPXCHG( 8, 10 ); CMPXCHG( 1, 3 ); CMPXCHG( 5, 7 );
568  CMPXCHG( 9, 11 ); CMPXCHG( 0, 4 ); CMPXCHG( 8, 12 );
569  CMPXCHG( 1, 5 ); CMPXCHG( 9, 13 ); CMPXCHG( 2, 6 );
570  CMPXCHG( 3, 7 ); CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 );
571  CMPXCHG( 2, 10 ); CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 );
572  CMPXCHG( 5, 13 ); CMPXCHG( 5, 10 ); CMPXCHG( 6, 9 );
573  CMPXCHG( 3, 12 ); CMPXCHG( 7, 11 ); CMPXCHG( 1, 2 );
574  CMPXCHG( 4, 8 ); CMPXCHG( 7, 13 ); CMPXCHG( 2, 8 );
575  CMPXCHG( 5, 6 ); CMPXCHG( 9, 10 ); CMPXCHG( 3, 8 );
576  CMPXCHG( 7, 12 ); CMPXCHG( 6, 8 ); CMPXCHG( 3, 5 );
577  CMPXCHG( 7, 9 ); CMPXCHG( 5, 6 ); CMPXCHG( 7, 8 );
578  return MEAN( f[6], f[7] );
579  case 15:
580  CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 );
581  CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 );
582  CMPXCHG( 12, 13 ); CMPXCHG( 0, 2 ); CMPXCHG( 4, 6 );
583  CMPXCHG( 8, 10 ); CMPXCHG( 12, 14 ); CMPXCHG( 1, 3 );
584  CMPXCHG( 5, 7 ); CMPXCHG( 9, 11 ); CMPXCHG( 0, 4 );
585  CMPXCHG( 8, 12 ); CMPXCHG( 1, 5 ); CMPXCHG( 9, 13 );
586  CMPXCHG( 2, 6 ); CMPXCHG( 10, 14 ); CMPXCHG( 3, 7 );
587  CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 ); CMPXCHG( 2, 10 );
588  CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 ); CMPXCHG( 5, 13 );
589  CMPXCHG( 6, 14 ); CMPXCHG( 5, 10 ); CMPXCHG( 6, 9 );
590  CMPXCHG( 3, 12 ); CMPXCHG( 13, 14 ); CMPXCHG( 7, 11 );
591  CMPXCHG( 1, 2 ); CMPXCHG( 4, 8 ); CMPXCHG( 7, 13 );
592  CMPXCHG( 2, 8 ); CMPXCHG( 5, 6 ); CMPXCHG( 9, 10 );
593  CMPXCHG( 3, 8 ); CMPXCHG( 7, 12 ); CMPXCHG( 6, 8 );
594  CMPXCHG( 3, 5 ); CMPXCHG( 7, 9 ); CMPXCHG( 5, 6 );
595  CMPXCHG( 7, 8 );
596  return pcl::Max( f[6], f[7] );
597  case 16:
598  CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 );
599  CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 );
600  CMPXCHG( 12, 13 ); CMPXCHG( 14, 15 ); CMPXCHG( 0, 2 );
601  CMPXCHG( 4, 6 ); CMPXCHG( 8, 10 ); CMPXCHG( 12, 14 );
602  CMPXCHG( 1, 3 ); CMPXCHG( 5, 7 ); CMPXCHG( 9, 11 );
603  CMPXCHG( 13, 15 ); CMPXCHG( 0, 4 ); CMPXCHG( 8, 12 );
604  CMPXCHG( 1, 5 ); CMPXCHG( 9, 13 ); CMPXCHG( 2, 6 );
605  CMPXCHG( 10, 14 ); CMPXCHG( 3, 7 ); CMPXCHG( 11, 15 );
606  CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 ); CMPXCHG( 2, 10 );
607  CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 ); CMPXCHG( 5, 13 );
608  CMPXCHG( 6, 14 ); CMPXCHG( 7, 15 ); CMPXCHG( 5, 10 );
609  CMPXCHG( 6, 9 ); CMPXCHG( 3, 12 ); CMPXCHG( 13, 14 );
610  CMPXCHG( 7, 11 ); CMPXCHG( 1, 2 ); CMPXCHG( 4, 8 );
611  CMPXCHG( 7, 13 ); CMPXCHG( 2, 8 ); CMPXCHG( 5, 6 );
612  CMPXCHG( 9, 10 ); CMPXCHG( 3, 8 ); CMPXCHG( 7, 12 );
613  CMPXCHG( 6, 8 ); CMPXCHG( 10, 12 ); CMPXCHG( 3, 5 );
614  CMPXCHG( 7, 9 ); CMPXCHG( 5, 6 ); CMPXCHG( 7, 8 );
615  CMPXCHG( 9, 10 ); CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 );
616  return MEAN( f[7], f[8] );
617  case 17:
618  CMPXCHG( 0, 16 ); CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 );
619  CMPXCHG( 2, 10 ); CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 );
620  CMPXCHG( 5, 13 ); CMPXCHG( 6, 14 ); CMPXCHG( 7, 15 );
621  CMPXCHG( 8, 16 ); CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 );
622  CMPXCHG( 2, 6 ); CMPXCHG( 3, 7 ); CMPXCHG( 8, 12 );
623  CMPXCHG( 9, 13 ); CMPXCHG( 10, 14 ); CMPXCHG( 11, 15 );
624  CMPXCHG( 4, 16 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
625  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
626  CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 ); CMPXCHG( 4, 6 );
627  CMPXCHG( 5, 7 ); CMPXCHG( 8, 10 ); CMPXCHG( 9, 11 );
628  CMPXCHG( 12, 14 ); CMPXCHG( 13, 15 ); CMPXCHG( 2, 16 );
629  CMPXCHG( 2, 8 ); CMPXCHG( 3, 9 ); CMPXCHG( 6, 12 );
630  CMPXCHG( 7, 13 ); CMPXCHG( 10, 16 ); CMPXCHG( 2, 4 );
631  CMPXCHG( 3, 5 ); CMPXCHG( 6, 8 ); CMPXCHG( 7, 9 );
632  CMPXCHG( 10, 12 ); CMPXCHG( 11, 13 ); CMPXCHG( 14, 16 );
633  CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 );
634  CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 );
635  CMPXCHG( 12, 13 ); CMPXCHG( 14, 15 ); CMPXCHG( 1, 16 );
636  CMPXCHG( 1, 8 ); CMPXCHG( 3, 10 ); CMPXCHG( 5, 12 );
637  CMPXCHG( 7, 14 ); CMPXCHG( 5, 8 ); CMPXCHG( 7, 10 );
638  return pcl::Max( f[7], f[8] );
639  case 18:
640  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 0, 8 );
641  CMPXCHG( 1, 9 ); CMPXCHG( 2, 10 ); CMPXCHG( 3, 11 );
642  CMPXCHG( 4, 12 ); CMPXCHG( 5, 13 ); CMPXCHG( 6, 14 );
643  CMPXCHG( 7, 15 ); CMPXCHG( 8, 16 ); CMPXCHG( 9, 17 );
644  CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 ); CMPXCHG( 2, 6 );
645  CMPXCHG( 3, 7 ); CMPXCHG( 8, 12 ); CMPXCHG( 9, 13 );
646  CMPXCHG( 10, 14 ); CMPXCHG( 11, 15 ); CMPXCHG( 4, 16 );
647  CMPXCHG( 5, 17 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
648  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
649  CMPXCHG( 13, 17 ); CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 );
650  CMPXCHG( 4, 6 ); CMPXCHG( 5, 7 ); CMPXCHG( 8, 10 );
651  CMPXCHG( 9, 11 ); CMPXCHG( 12, 14 ); CMPXCHG( 13, 15 );
652  CMPXCHG( 2, 16 ); CMPXCHG( 3, 17 ); CMPXCHG( 2, 8 );
653  CMPXCHG( 3, 9 ); CMPXCHG( 6, 12 ); CMPXCHG( 7, 13 );
654  CMPXCHG( 10, 16 ); CMPXCHG( 11, 17 ); CMPXCHG( 2, 4 );
655  CMPXCHG( 3, 5 ); CMPXCHG( 6, 8 ); CMPXCHG( 7, 9 );
656  CMPXCHG( 10, 12 ); CMPXCHG( 11, 13 ); CMPXCHG( 14, 16 );
657  CMPXCHG( 15, 17 ); CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 );
658  CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 );
659  CMPXCHG( 10, 11 ); CMPXCHG( 12, 13 ); CMPXCHG( 14, 15 );
660  CMPXCHG( 16, 17 ); CMPXCHG( 1, 16 ); CMPXCHG( 1, 8 );
661  CMPXCHG( 3, 10 ); CMPXCHG( 5, 12 ); CMPXCHG( 7, 14 );
662  CMPXCHG( 9, 16 ); CMPXCHG( 5, 8 ); CMPXCHG( 7, 10 );
663  CMPXCHG( 9, 12 ); CMPXCHG( 7, 8 ); CMPXCHG( 9, 10 );
664  return MEAN( f[8], f[9] );
665  case 19:
666  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 2, 18 );
667  CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 ); CMPXCHG( 2, 10 );
668  CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 ); CMPXCHG( 5, 13 );
669  CMPXCHG( 6, 14 ); CMPXCHG( 7, 15 ); CMPXCHG( 8, 16 );
670  CMPXCHG( 9, 17 ); CMPXCHG( 10, 18 ); CMPXCHG( 0, 4 );
671  CMPXCHG( 1, 5 ); CMPXCHG( 2, 6 ); CMPXCHG( 3, 7 );
672  CMPXCHG( 8, 12 ); CMPXCHG( 9, 13 ); CMPXCHG( 10, 14 );
673  CMPXCHG( 11, 15 ); CMPXCHG( 4, 16 ); CMPXCHG( 5, 17 );
674  CMPXCHG( 6, 18 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
675  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
676  CMPXCHG( 13, 17 ); CMPXCHG( 14, 18 ); CMPXCHG( 0, 2 );
677  CMPXCHG( 1, 3 ); CMPXCHG( 4, 6 ); CMPXCHG( 5, 7 );
678  CMPXCHG( 8, 10 ); CMPXCHG( 9, 11 ); CMPXCHG( 12, 14 );
679  CMPXCHG( 13, 15 ); CMPXCHG( 16, 18 ); CMPXCHG( 2, 16 );
680  CMPXCHG( 3, 17 ); CMPXCHG( 2, 8 ); CMPXCHG( 3, 9 );
681  CMPXCHG( 6, 12 ); CMPXCHG( 7, 13 ); CMPXCHG( 10, 16 );
682  CMPXCHG( 11, 17 ); CMPXCHG( 2, 4 ); CMPXCHG( 3, 5 );
683  CMPXCHG( 6, 8 ); CMPXCHG( 7, 9 ); CMPXCHG( 10, 12 );
684  CMPXCHG( 11, 13 ); CMPXCHG( 14, 16 ); CMPXCHG( 15, 17 );
685  CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 );
686  CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 );
687  CMPXCHG( 12, 13 ); CMPXCHG( 14, 15 ); CMPXCHG( 16, 17 );
688  CMPXCHG( 1, 16 ); CMPXCHG( 3, 18 ); CMPXCHG( 3, 10 );
689  CMPXCHG( 5, 12 ); CMPXCHG( 7, 14 ); CMPXCHG( 9, 16 );
690  CMPXCHG( 7, 10 ); CMPXCHG( 9, 12 );
691  return pcl::Min( f[9], f[10] );
692  case 20:
693  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 2, 18 );
694  CMPXCHG( 3, 19 ); CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 );
695  CMPXCHG( 2, 10 ); CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 );
696  CMPXCHG( 5, 13 ); CMPXCHG( 6, 14 ); CMPXCHG( 7, 15 );
697  CMPXCHG( 8, 16 ); CMPXCHG( 9, 17 ); CMPXCHG( 10, 18 );
698  CMPXCHG( 11, 19 ); CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 );
699  CMPXCHG( 2, 6 ); CMPXCHG( 3, 7 ); CMPXCHG( 8, 12 );
700  CMPXCHG( 9, 13 ); CMPXCHG( 10, 14 ); CMPXCHG( 11, 15 );
701  CMPXCHG( 4, 16 ); CMPXCHG( 5, 17 ); CMPXCHG( 6, 18 );
702  CMPXCHG( 7, 19 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
703  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
704  CMPXCHG( 13, 17 ); CMPXCHG( 14, 18 ); CMPXCHG( 15, 19 );
705  CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 ); CMPXCHG( 4, 6 );
706  CMPXCHG( 5, 7 ); CMPXCHG( 8, 10 ); CMPXCHG( 9, 11 );
707  CMPXCHG( 12, 14 ); CMPXCHG( 13, 15 ); CMPXCHG( 16, 18 );
708  CMPXCHG( 17, 19 ); CMPXCHG( 2, 16 ); CMPXCHG( 3, 17 );
709  CMPXCHG( 2, 8 ); CMPXCHG( 3, 9 ); CMPXCHG( 6, 12 );
710  CMPXCHG( 7, 13 ); CMPXCHG( 10, 16 ); CMPXCHG( 11, 17 );
711  CMPXCHG( 2, 4 ); CMPXCHG( 3, 5 ); CMPXCHG( 6, 8 );
712  CMPXCHG( 7, 9 ); CMPXCHG( 10, 12 ); CMPXCHG( 11, 13 );
713  CMPXCHG( 14, 16 ); CMPXCHG( 15, 17 ); CMPXCHG( 0, 1 );
714  CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 );
715  CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 ); CMPXCHG( 12, 13 );
716  CMPXCHG( 14, 15 ); CMPXCHG( 16, 17 ); CMPXCHG( 18, 19 );
717  CMPXCHG( 1, 16 ); CMPXCHG( 3, 18 ); CMPXCHG( 3, 10 );
718  CMPXCHG( 5, 12 ); CMPXCHG( 7, 14 ); CMPXCHG( 9, 16 );
719  CMPXCHG( 7, 10 ); CMPXCHG( 9, 12 );
720  return MEAN( f[9], f[10] );
721  case 21:
722  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 2, 18 );
723  CMPXCHG( 3, 19 ); CMPXCHG( 4, 20 ); CMPXCHG( 0, 8 );
724  CMPXCHG( 1, 9 ); CMPXCHG( 2, 10 ); CMPXCHG( 3, 11 );
725  CMPXCHG( 4, 12 ); CMPXCHG( 5, 13 ); CMPXCHG( 6, 14 );
726  CMPXCHG( 7, 15 ); CMPXCHG( 8, 16 ); CMPXCHG( 9, 17 );
727  CMPXCHG( 10, 18 ); CMPXCHG( 11, 19 ); CMPXCHG( 12, 20 );
728  CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 ); CMPXCHG( 2, 6 );
729  CMPXCHG( 3, 7 ); CMPXCHG( 8, 12 ); CMPXCHG( 9, 13 );
730  CMPXCHG( 10, 14 ); CMPXCHG( 11, 15 ); CMPXCHG( 16, 20 );
731  CMPXCHG( 4, 16 ); CMPXCHG( 5, 17 ); CMPXCHG( 6, 18 );
732  CMPXCHG( 7, 19 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
733  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
734  CMPXCHG( 13, 17 ); CMPXCHG( 14, 18 ); CMPXCHG( 15, 19 );
735  CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 ); CMPXCHG( 4, 6 );
736  CMPXCHG( 5, 7 ); CMPXCHG( 8, 10 ); CMPXCHG( 9, 11 );
737  CMPXCHG( 12, 14 ); CMPXCHG( 13, 15 ); CMPXCHG( 16, 18 );
738  CMPXCHG( 17, 19 ); CMPXCHG( 2, 16 ); CMPXCHG( 3, 17 );
739  CMPXCHG( 6, 20 ); CMPXCHG( 2, 8 ); CMPXCHG( 3, 9 );
740  CMPXCHG( 6, 12 ); CMPXCHG( 7, 13 ); CMPXCHG( 10, 16 );
741  CMPXCHG( 11, 17 ); CMPXCHG( 14, 20 ); CMPXCHG( 2, 4 );
742  CMPXCHG( 3, 5 ); CMPXCHG( 6, 8 ); CMPXCHG( 7, 9 );
743  CMPXCHG( 10, 12 ); CMPXCHG( 11, 13 ); CMPXCHG( 14, 16 );
744  CMPXCHG( 15, 17 ); CMPXCHG( 18, 20 ); CMPXCHG( 0, 1 );
745  CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 );
746  CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 ); CMPXCHG( 12, 13 );
747  CMPXCHG( 14, 15 ); CMPXCHG( 16, 17 ); CMPXCHG( 18, 19 );
748  CMPXCHG( 1, 16 ); CMPXCHG( 3, 18 ); CMPXCHG( 5, 20 );
749  CMPXCHG( 3, 10 ); CMPXCHG( 5, 12 ); CMPXCHG( 7, 14 );
750  CMPXCHG( 9, 16 ); CMPXCHG( 7, 10 ); CMPXCHG( 9, 12 );
751  return pcl::Max( f[9], f[10] );
752  case 22:
753  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 2, 18 );
754  CMPXCHG( 3, 19 ); CMPXCHG( 4, 20 ); CMPXCHG( 5, 21 );
755  CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 ); CMPXCHG( 2, 10 );
756  CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 ); CMPXCHG( 5, 13 );
757  CMPXCHG( 6, 14 ); CMPXCHG( 7, 15 ); CMPXCHG( 8, 16 );
758  CMPXCHG( 9, 17 ); CMPXCHG( 10, 18 ); CMPXCHG( 11, 19 );
759  CMPXCHG( 12, 20 ); CMPXCHG( 13, 21 ); CMPXCHG( 0, 4 );
760  CMPXCHG( 1, 5 ); CMPXCHG( 2, 6 ); CMPXCHG( 3, 7 );
761  CMPXCHG( 8, 12 ); CMPXCHG( 9, 13 ); CMPXCHG( 10, 14 );
762  CMPXCHG( 11, 15 ); CMPXCHG( 16, 20 ); CMPXCHG( 17, 21 );
763  CMPXCHG( 4, 16 ); CMPXCHG( 5, 17 ); CMPXCHG( 6, 18 );
764  CMPXCHG( 7, 19 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
765  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
766  CMPXCHG( 13, 17 ); CMPXCHG( 14, 18 ); CMPXCHG( 15, 19 );
767  CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 ); CMPXCHG( 4, 6 );
768  CMPXCHG( 5, 7 ); CMPXCHG( 8, 10 ); CMPXCHG( 9, 11 );
769  CMPXCHG( 12, 14 ); CMPXCHG( 13, 15 ); CMPXCHG( 16, 18 );
770  CMPXCHG( 17, 19 ); CMPXCHG( 2, 16 ); CMPXCHG( 3, 17 );
771  CMPXCHG( 6, 20 ); CMPXCHG( 7, 21 ); CMPXCHG( 2, 8 );
772  CMPXCHG( 3, 9 ); CMPXCHG( 6, 12 ); CMPXCHG( 7, 13 );
773  CMPXCHG( 10, 16 ); CMPXCHG( 11, 17 ); CMPXCHG( 14, 20 );
774  CMPXCHG( 15, 21 ); CMPXCHG( 2, 4 ); CMPXCHG( 3, 5 );
775  CMPXCHG( 6, 8 ); CMPXCHG( 7, 9 ); CMPXCHG( 10, 12 );
776  CMPXCHG( 11, 13 ); CMPXCHG( 14, 16 ); CMPXCHG( 15, 17 );
777  CMPXCHG( 18, 20 ); CMPXCHG( 19, 21 ); CMPXCHG( 0, 1 );
778  CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 );
779  CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 ); CMPXCHG( 12, 13 );
780  CMPXCHG( 14, 15 ); CMPXCHG( 16, 17 ); CMPXCHG( 18, 19 );
781  CMPXCHG( 20, 21 ); CMPXCHG( 1, 16 ); CMPXCHG( 3, 18 );
782  CMPXCHG( 5, 20 ); CMPXCHG( 3, 10 ); CMPXCHG( 5, 12 );
783  CMPXCHG( 7, 14 ); CMPXCHG( 9, 16 ); CMPXCHG( 11, 18 );
784  CMPXCHG( 7, 10 ); CMPXCHG( 9, 12 ); CMPXCHG( 11, 14 );
785  CMPXCHG( 9, 10 ); CMPXCHG( 11, 12 );
786  return MEAN( f[10], f[11] );
787  case 23:
788  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 2, 18 );
789  CMPXCHG( 3, 19 ); CMPXCHG( 4, 20 ); CMPXCHG( 5, 21 );
790  CMPXCHG( 6, 22 ); CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 );
791  CMPXCHG( 2, 10 ); CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 );
792  CMPXCHG( 5, 13 ); CMPXCHG( 6, 14 ); CMPXCHG( 7, 15 );
793  CMPXCHG( 8, 16 ); CMPXCHG( 9, 17 ); CMPXCHG( 10, 18 );
794  CMPXCHG( 11, 19 ); CMPXCHG( 12, 20 ); CMPXCHG( 13, 21 );
795  CMPXCHG( 14, 22 ); CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 );
796  CMPXCHG( 2, 6 ); CMPXCHG( 3, 7 ); CMPXCHG( 8, 12 );
797  CMPXCHG( 9, 13 ); CMPXCHG( 10, 14 ); CMPXCHG( 11, 15 );
798  CMPXCHG( 16, 20 ); CMPXCHG( 17, 21 ); CMPXCHG( 18, 22 );
799  CMPXCHG( 4, 16 ); CMPXCHG( 5, 17 ); CMPXCHG( 6, 18 );
800  CMPXCHG( 7, 19 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
801  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
802  CMPXCHG( 13, 17 ); CMPXCHG( 14, 18 ); CMPXCHG( 15, 19 );
803  CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 ); CMPXCHG( 4, 6 );
804  CMPXCHG( 5, 7 ); CMPXCHG( 8, 10 ); CMPXCHG( 9, 11 );
805  CMPXCHG( 12, 14 ); CMPXCHG( 13, 15 ); CMPXCHG( 16, 18 );
806  CMPXCHG( 17, 19 ); CMPXCHG( 20, 22 ); CMPXCHG( 2, 16 );
807  CMPXCHG( 3, 17 ); CMPXCHG( 6, 20 ); CMPXCHG( 7, 21 );
808  CMPXCHG( 2, 8 ); CMPXCHG( 3, 9 ); CMPXCHG( 6, 12 );
809  CMPXCHG( 7, 13 ); CMPXCHG( 10, 16 ); CMPXCHG( 11, 17 );
810  CMPXCHG( 14, 20 ); CMPXCHG( 15, 21 ); CMPXCHG( 2, 4 );
811  CMPXCHG( 3, 5 ); CMPXCHG( 6, 8 ); CMPXCHG( 7, 9 );
812  CMPXCHG( 10, 12 ); CMPXCHG( 11, 13 ); CMPXCHG( 14, 16 );
813  CMPXCHG( 15, 17 ); CMPXCHG( 18, 20 ); CMPXCHG( 19, 21 );
814  CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 );
815  CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 );
816  CMPXCHG( 12, 13 ); CMPXCHG( 14, 15 ); CMPXCHG( 16, 17 );
817  CMPXCHG( 18, 19 ); CMPXCHG( 20, 21 ); CMPXCHG( 1, 16 );
818  CMPXCHG( 3, 18 ); CMPXCHG( 5, 20 ); CMPXCHG( 7, 22 );
819  CMPXCHG( 5, 12 ); CMPXCHG( 7, 14 ); CMPXCHG( 9, 16 );
820  CMPXCHG( 11, 18 ); CMPXCHG( 9, 12 ); CMPXCHG( 11, 14 );
821  return pcl::Min( f[11], f[12] );
822  case 24:
823  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 2, 18 );
824  CMPXCHG( 3, 19 ); CMPXCHG( 4, 20 ); CMPXCHG( 5, 21 );
825  CMPXCHG( 6, 22 ); CMPXCHG( 7, 23 ); CMPXCHG( 0, 8 );
826  CMPXCHG( 1, 9 ); CMPXCHG( 2, 10 ); CMPXCHG( 3, 11 );
827  CMPXCHG( 4, 12 ); CMPXCHG( 5, 13 ); CMPXCHG( 6, 14 );
828  CMPXCHG( 7, 15 ); CMPXCHG( 8, 16 ); CMPXCHG( 9, 17 );
829  CMPXCHG( 10, 18 ); CMPXCHG( 11, 19 ); CMPXCHG( 12, 20 );
830  CMPXCHG( 13, 21 ); CMPXCHG( 14, 22 ); CMPXCHG( 15, 23 );
831  CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 ); CMPXCHG( 2, 6 );
832  CMPXCHG( 3, 7 ); CMPXCHG( 8, 12 ); CMPXCHG( 9, 13 );
833  CMPXCHG( 10, 14 ); CMPXCHG( 11, 15 ); CMPXCHG( 16, 20 );
834  CMPXCHG( 17, 21 ); CMPXCHG( 18, 22 ); CMPXCHG( 19, 23 );
835  CMPXCHG( 4, 16 ); CMPXCHG( 5, 17 ); CMPXCHG( 6, 18 );
836  CMPXCHG( 7, 19 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
837  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
838  CMPXCHG( 13, 17 ); CMPXCHG( 14, 18 ); CMPXCHG( 15, 19 );
839  CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 ); CMPXCHG( 4, 6 );
840  CMPXCHG( 5, 7 ); CMPXCHG( 8, 10 ); CMPXCHG( 9, 11 );
841  CMPXCHG( 12, 14 ); CMPXCHG( 13, 15 ); CMPXCHG( 16, 18 );
842  CMPXCHG( 17, 19 ); CMPXCHG( 20, 22 ); CMPXCHG( 21, 23 );
843  CMPXCHG( 2, 16 ); CMPXCHG( 3, 17 ); CMPXCHG( 6, 20 );
844  CMPXCHG( 7, 21 ); CMPXCHG( 2, 8 ); CMPXCHG( 3, 9 );
845  CMPXCHG( 6, 12 ); CMPXCHG( 7, 13 ); CMPXCHG( 10, 16 );
846  CMPXCHG( 11, 17 ); CMPXCHG( 14, 20 ); CMPXCHG( 15, 21 );
847  CMPXCHG( 2, 4 ); CMPXCHG( 3, 5 ); CMPXCHG( 6, 8 );
848  CMPXCHG( 7, 9 ); CMPXCHG( 10, 12 ); CMPXCHG( 11, 13 );
849  CMPXCHG( 14, 16 ); CMPXCHG( 15, 17 ); CMPXCHG( 18, 20 );
850  CMPXCHG( 19, 21 ); CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 );
851  CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 );
852  CMPXCHG( 10, 11 ); CMPXCHG( 12, 13 ); CMPXCHG( 14, 15 );
853  CMPXCHG( 16, 17 ); CMPXCHG( 18, 19 ); CMPXCHG( 20, 21 );
854  CMPXCHG( 22, 23 ); CMPXCHG( 1, 16 ); CMPXCHG( 3, 18 );
855  CMPXCHG( 5, 20 ); CMPXCHG( 7, 22 ); CMPXCHG( 5, 12 );
856  CMPXCHG( 7, 14 ); CMPXCHG( 9, 16 ); CMPXCHG( 11, 18 );
857  CMPXCHG( 9, 12 ); CMPXCHG( 11, 14 );
858  return MEAN( f[11], f[12] );
859  case 25:
860  CMPXCHG( 0, 1 ); CMPXCHG( 3, 4 ); CMPXCHG( 2, 4 );
861  CMPXCHG( 2, 3 ); CMPXCHG( 6, 7 ); CMPXCHG( 5, 7 );
862  CMPXCHG( 5, 6 ); CMPXCHG( 9, 10 ); CMPXCHG( 8, 10 );
863  CMPXCHG( 8, 9 ); CMPXCHG( 12, 13 ); CMPXCHG( 11, 13 );
864  CMPXCHG( 11, 12 ); CMPXCHG( 15, 16 ); CMPXCHG( 14, 16 );
865  CMPXCHG( 14, 15 ); CMPXCHG( 18, 19 ); CMPXCHG( 17, 19 );
866  CMPXCHG( 17, 18 ); CMPXCHG( 21, 22 ); CMPXCHG( 20, 22 );
867  CMPXCHG( 20, 21 ); CMPXCHG( 23, 24 ); CMPXCHG( 2, 5 );
868  CMPXCHG( 3, 6 ); CMPXCHG( 0, 6 ); CMPXCHG( 0, 3 );
869  CMPXCHG( 4, 7 ); CMPXCHG( 1, 7 ); CMPXCHG( 1, 4 );
870  CMPXCHG( 11, 14 ); CMPXCHG( 8, 14 ); CMPXCHG( 8, 11 );
871  CMPXCHG( 12, 15 ); CMPXCHG( 9, 15 ); CMPXCHG( 9, 12 );
872  CMPXCHG( 13, 16 ); CMPXCHG( 10, 16 ); CMPXCHG( 10, 13 );
873  CMPXCHG( 20, 23 ); CMPXCHG( 17, 23 ); CMPXCHG( 17, 20 );
874  CMPXCHG( 21, 24 ); CMPXCHG( 18, 24 ); CMPXCHG( 18, 21 );
875  CMPXCHG( 19, 22 ); CMPXCHG( 8, 17 ); CMPXCHG( 9, 18 );
876  CMPXCHG( 0, 18 ); CMPXCHG( 0, 9 ); CMPXCHG( 10, 19 );
877  CMPXCHG( 1, 19 ); CMPXCHG( 1, 10 ); CMPXCHG( 11, 20 );
878  CMPXCHG( 2, 20 ); CMPXCHG( 2, 11 ); CMPXCHG( 12, 21 );
879  CMPXCHG( 3, 21 ); CMPXCHG( 3, 12 ); CMPXCHG( 13, 22 );
880  CMPXCHG( 4, 22 ); CMPXCHG( 4, 13 ); CMPXCHG( 14, 23 );
881  CMPXCHG( 5, 23 ); CMPXCHG( 5, 14 ); CMPXCHG( 15, 24 );
882  CMPXCHG( 6, 24 ); CMPXCHG( 6, 15 ); CMPXCHG( 7, 16 );
883  CMPXCHG( 7, 19 ); CMPXCHG( 13, 21 ); CMPXCHG( 15, 23 );
884  CMPXCHG( 7, 13 ); CMPXCHG( 7, 15 ); CMPXCHG( 1, 9 );
885  CMPXCHG( 3, 11 ); CMPXCHG( 5, 17 ); CMPXCHG( 11, 17 );
886  CMPXCHG( 9, 17 ); CMPXCHG( 4, 10 ); CMPXCHG( 6, 12 );
887  CMPXCHG( 7, 14 ); CMPXCHG( 4, 6 ); CMPXCHG( 4, 7 );
888  CMPXCHG( 12, 14 ); CMPXCHG( 10, 14 ); CMPXCHG( 6, 7 );
889  CMPXCHG( 10, 12 ); CMPXCHG( 6, 10 ); CMPXCHG( 6, 17 );
890  CMPXCHG( 12, 17 ); CMPXCHG( 7, 17 ); CMPXCHG( 7, 10 );
891  CMPXCHG( 12, 18 ); CMPXCHG( 7, 12 ); CMPXCHG( 10, 18 );
892  CMPXCHG( 12, 20 ); CMPXCHG( 10, 20 );
893  return pcl::Max( f[10], f[12] );
894  case 26:
895  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 2, 18 );
896  CMPXCHG( 3, 19 ); CMPXCHG( 4, 20 ); CMPXCHG( 5, 21 );
897  CMPXCHG( 6, 22 ); CMPXCHG( 7, 23 ); CMPXCHG( 8, 24 );
898  CMPXCHG( 9, 25 ); CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 );
899  CMPXCHG( 2, 10 ); CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 );
900  CMPXCHG( 5, 13 ); CMPXCHG( 6, 14 ); CMPXCHG( 7, 15 );
901  CMPXCHG( 16, 24 ); CMPXCHG( 17, 25 ); CMPXCHG( 8, 16 );
902  CMPXCHG( 9, 17 ); CMPXCHG( 10, 18 ); CMPXCHG( 11, 19 );
903  CMPXCHG( 12, 20 ); CMPXCHG( 13, 21 ); CMPXCHG( 14, 22 );
904  CMPXCHG( 15, 23 ); CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 );
905  CMPXCHG( 2, 6 ); CMPXCHG( 3, 7 ); CMPXCHG( 8, 12 );
906  CMPXCHG( 9, 13 ); CMPXCHG( 10, 14 ); CMPXCHG( 11, 15 );
907  CMPXCHG( 16, 20 ); CMPXCHG( 17, 21 ); CMPXCHG( 18, 22 );
908  CMPXCHG( 19, 23 ); CMPXCHG( 4, 16 ); CMPXCHG( 5, 17 );
909  CMPXCHG( 6, 18 ); CMPXCHG( 7, 19 ); CMPXCHG( 12, 24 );
910  CMPXCHG( 13, 25 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
911  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
912  CMPXCHG( 13, 17 ); CMPXCHG( 14, 18 ); CMPXCHG( 15, 19 );
913  CMPXCHG( 20, 24 ); CMPXCHG( 21, 25 ); CMPXCHG( 0, 2 );
914  CMPXCHG( 1, 3 ); CMPXCHG( 4, 6 ); CMPXCHG( 5, 7 );
915  CMPXCHG( 8, 10 ); CMPXCHG( 9, 11 ); CMPXCHG( 12, 14 );
916  CMPXCHG( 13, 15 ); CMPXCHG( 16, 18 ); CMPXCHG( 17, 19 );
917  CMPXCHG( 20, 22 ); CMPXCHG( 21, 23 ); CMPXCHG( 2, 16 );
918  CMPXCHG( 3, 17 ); CMPXCHG( 6, 20 ); CMPXCHG( 7, 21 );
919  CMPXCHG( 10, 24 ); CMPXCHG( 11, 25 ); CMPXCHG( 2, 8 );
920  CMPXCHG( 3, 9 ); CMPXCHG( 6, 12 ); CMPXCHG( 7, 13 );
921  CMPXCHG( 10, 16 ); CMPXCHG( 11, 17 ); CMPXCHG( 14, 20 );
922  CMPXCHG( 15, 21 ); CMPXCHG( 18, 24 ); CMPXCHG( 19, 25 );
923  CMPXCHG( 2, 4 ); CMPXCHG( 3, 5 ); CMPXCHG( 6, 8 );
924  CMPXCHG( 7, 9 ); CMPXCHG( 10, 12 ); CMPXCHG( 11, 13 );
925  CMPXCHG( 14, 16 ); CMPXCHG( 15, 17 ); CMPXCHG( 18, 20 );
926  CMPXCHG( 19, 21 ); CMPXCHG( 22, 24 ); CMPXCHG( 23, 25 );
927  CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 );
928  CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 );
929  CMPXCHG( 12, 13 ); CMPXCHG( 14, 15 ); CMPXCHG( 16, 17 );
930  CMPXCHG( 18, 19 ); CMPXCHG( 20, 21 ); CMPXCHG( 22, 23 );
931  CMPXCHG( 24, 25 ); CMPXCHG( 1, 16 ); CMPXCHG( 3, 18 );
932  CMPXCHG( 5, 20 ); CMPXCHG( 7, 22 ); CMPXCHG( 9, 24 );
933  CMPXCHG( 5, 12 ); CMPXCHG( 7, 14 ); CMPXCHG( 9, 16 );
934  CMPXCHG( 11, 18 ); CMPXCHG( 13, 20 ); CMPXCHG( 9, 12 );
935  CMPXCHG( 11, 14 ); CMPXCHG( 13, 16 ); CMPXCHG( 11, 12 );
936  CMPXCHG( 13, 14 );
937  return MEAN( f[12], f[13] );
938  case 27:
939  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 2, 18 );
940  CMPXCHG( 3, 19 ); CMPXCHG( 4, 20 ); CMPXCHG( 5, 21 );
941  CMPXCHG( 6, 22 ); CMPXCHG( 7, 23 ); CMPXCHG( 8, 24 );
942  CMPXCHG( 9, 25 ); CMPXCHG( 10, 26 ); CMPXCHG( 0, 8 );
943  CMPXCHG( 1, 9 ); CMPXCHG( 2, 10 ); CMPXCHG( 3, 11 );
944  CMPXCHG( 4, 12 ); CMPXCHG( 5, 13 ); CMPXCHG( 6, 14 );
945  CMPXCHG( 7, 15 ); CMPXCHG( 16, 24 ); CMPXCHG( 17, 25 );
946  CMPXCHG( 18, 26 ); CMPXCHG( 8, 16 ); CMPXCHG( 9, 17 );
947  CMPXCHG( 10, 18 ); CMPXCHG( 11, 19 ); CMPXCHG( 12, 20 );
948  CMPXCHG( 13, 21 ); CMPXCHG( 14, 22 ); CMPXCHG( 15, 23 );
949  CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 ); CMPXCHG( 2, 6 );
950  CMPXCHG( 3, 7 ); CMPXCHG( 8, 12 ); CMPXCHG( 9, 13 );
951  CMPXCHG( 10, 14 ); CMPXCHG( 11, 15 ); CMPXCHG( 16, 20 );
952  CMPXCHG( 17, 21 ); CMPXCHG( 18, 22 ); CMPXCHG( 19, 23 );
953  CMPXCHG( 4, 16 ); CMPXCHG( 5, 17 ); CMPXCHG( 6, 18 );
954  CMPXCHG( 7, 19 ); CMPXCHG( 12, 24 ); CMPXCHG( 13, 25 );
955  CMPXCHG( 14, 26 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
956  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
957  CMPXCHG( 13, 17 ); CMPXCHG( 14, 18 ); CMPXCHG( 15, 19 );
958  CMPXCHG( 20, 24 ); CMPXCHG( 21, 25 ); CMPXCHG( 22, 26 );
959  CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 ); CMPXCHG( 4, 6 );
960  CMPXCHG( 5, 7 ); CMPXCHG( 8, 10 ); CMPXCHG( 9, 11 );
961  CMPXCHG( 12, 14 ); CMPXCHG( 13, 15 ); CMPXCHG( 16, 18 );
962  CMPXCHG( 17, 19 ); CMPXCHG( 20, 22 ); CMPXCHG( 21, 23 );
963  CMPXCHG( 24, 26 ); CMPXCHG( 2, 16 ); CMPXCHG( 3, 17 );
964  CMPXCHG( 6, 20 ); CMPXCHG( 7, 21 ); CMPXCHG( 10, 24 );
965  CMPXCHG( 11, 25 ); CMPXCHG( 2, 8 ); CMPXCHG( 3, 9 );
966  CMPXCHG( 6, 12 ); CMPXCHG( 7, 13 ); CMPXCHG( 10, 16 );
967  CMPXCHG( 11, 17 ); CMPXCHG( 14, 20 ); CMPXCHG( 15, 21 );
968  CMPXCHG( 18, 24 ); CMPXCHG( 19, 25 ); CMPXCHG( 2, 4 );
969  CMPXCHG( 3, 5 ); CMPXCHG( 6, 8 ); CMPXCHG( 7, 9 );
970  CMPXCHG( 10, 12 ); CMPXCHG( 11, 13 ); CMPXCHG( 14, 16 );
971  CMPXCHG( 15, 17 ); CMPXCHG( 18, 20 ); CMPXCHG( 19, 21 );
972  CMPXCHG( 22, 24 ); CMPXCHG( 23, 25 ); CMPXCHG( 0, 1 );
973  CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 );
974  CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 ); CMPXCHG( 12, 13 );
975  CMPXCHG( 14, 15 ); CMPXCHG( 16, 17 ); CMPXCHG( 18, 19 );
976  CMPXCHG( 20, 21 ); CMPXCHG( 22, 23 ); CMPXCHG( 24, 25 );
977  CMPXCHG( 1, 16 ); CMPXCHG( 3, 18 ); CMPXCHG( 5, 20 );
978  CMPXCHG( 7, 22 ); CMPXCHG( 9, 24 ); CMPXCHG( 11, 26 );
979  CMPXCHG( 7, 14 ); CMPXCHG( 9, 16 ); CMPXCHG( 11, 18 );
980  CMPXCHG( 13, 20 ); CMPXCHG( 11, 14 ); CMPXCHG( 13, 16 );
981  return pcl::Min( f[13], f[14] );
982  case 28:
983  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 2, 18 );
984  CMPXCHG( 3, 19 ); CMPXCHG( 4, 20 ); CMPXCHG( 5, 21 );
985  CMPXCHG( 6, 22 ); CMPXCHG( 7, 23 ); CMPXCHG( 8, 24 );
986  CMPXCHG( 9, 25 ); CMPXCHG( 10, 26 ); CMPXCHG( 11, 27 );
987  CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 ); CMPXCHG( 2, 10 );
988  CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 ); CMPXCHG( 5, 13 );
989  CMPXCHG( 6, 14 ); CMPXCHG( 7, 15 ); CMPXCHG( 16, 24 );
990  CMPXCHG( 17, 25 ); CMPXCHG( 18, 26 ); CMPXCHG( 19, 27 );
991  CMPXCHG( 8, 16 ); CMPXCHG( 9, 17 ); CMPXCHG( 10, 18 );
992  CMPXCHG( 11, 19 ); CMPXCHG( 12, 20 ); CMPXCHG( 13, 21 );
993  CMPXCHG( 14, 22 ); CMPXCHG( 15, 23 ); CMPXCHG( 0, 4 );
994  CMPXCHG( 1, 5 ); CMPXCHG( 2, 6 ); CMPXCHG( 3, 7 );
995  CMPXCHG( 8, 12 ); CMPXCHG( 9, 13 ); CMPXCHG( 10, 14 );
996  CMPXCHG( 11, 15 ); CMPXCHG( 16, 20 ); CMPXCHG( 17, 21 );
997  CMPXCHG( 18, 22 ); CMPXCHG( 19, 23 ); CMPXCHG( 4, 16 );
998  CMPXCHG( 5, 17 ); CMPXCHG( 6, 18 ); CMPXCHG( 7, 19 );
999  CMPXCHG( 12, 24 ); CMPXCHG( 13, 25 ); CMPXCHG( 14, 26 );
1000  CMPXCHG( 15, 27 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
1001  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
1002  CMPXCHG( 13, 17 ); CMPXCHG( 14, 18 ); CMPXCHG( 15, 19 );
1003  CMPXCHG( 20, 24 ); CMPXCHG( 21, 25 ); CMPXCHG( 22, 26 );
1004  CMPXCHG( 23, 27 ); CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 );
1005  CMPXCHG( 4, 6 ); CMPXCHG( 5, 7 ); CMPXCHG( 8, 10 );
1006  CMPXCHG( 9, 11 ); CMPXCHG( 12, 14 ); CMPXCHG( 13, 15 );
1007  CMPXCHG( 16, 18 ); CMPXCHG( 17, 19 ); CMPXCHG( 20, 22 );
1008  CMPXCHG( 21, 23 ); CMPXCHG( 24, 26 ); CMPXCHG( 25, 27 );
1009  CMPXCHG( 2, 16 ); CMPXCHG( 3, 17 ); CMPXCHG( 6, 20 );
1010  CMPXCHG( 7, 21 ); CMPXCHG( 10, 24 ); CMPXCHG( 11, 25 );
1011  CMPXCHG( 2, 8 ); CMPXCHG( 3, 9 ); CMPXCHG( 6, 12 );
1012  CMPXCHG( 7, 13 ); CMPXCHG( 10, 16 ); CMPXCHG( 11, 17 );
1013  CMPXCHG( 14, 20 ); CMPXCHG( 15, 21 ); CMPXCHG( 18, 24 );
1014  CMPXCHG( 19, 25 ); CMPXCHG( 2, 4 ); CMPXCHG( 3, 5 );
1015  CMPXCHG( 6, 8 ); CMPXCHG( 7, 9 ); CMPXCHG( 10, 12 );
1016  CMPXCHG( 11, 13 ); CMPXCHG( 14, 16 ); CMPXCHG( 15, 17 );
1017  CMPXCHG( 18, 20 ); CMPXCHG( 19, 21 ); CMPXCHG( 22, 24 );
1018  CMPXCHG( 23, 25 ); CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 );
1019  CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 );
1020  CMPXCHG( 10, 11 ); CMPXCHG( 12, 13 ); CMPXCHG( 14, 15 );
1021  CMPXCHG( 16, 17 ); CMPXCHG( 18, 19 ); CMPXCHG( 20, 21 );
1022  CMPXCHG( 22, 23 ); CMPXCHG( 24, 25 ); CMPXCHG( 26, 27 );
1023  CMPXCHG( 1, 16 ); CMPXCHG( 3, 18 ); CMPXCHG( 5, 20 );
1024  CMPXCHG( 7, 22 ); CMPXCHG( 9, 24 ); CMPXCHG( 11, 26 );
1025  CMPXCHG( 7, 14 ); CMPXCHG( 9, 16 ); CMPXCHG( 11, 18 );
1026  CMPXCHG( 13, 20 ); CMPXCHG( 11, 14 ); CMPXCHG( 13, 16 );
1027  return MEAN( f[13], f[14] );
1028  case 29:
1029  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 2, 18 );
1030  CMPXCHG( 3, 19 ); CMPXCHG( 4, 20 ); CMPXCHG( 5, 21 );
1031  CMPXCHG( 6, 22 ); CMPXCHG( 7, 23 ); CMPXCHG( 8, 24 );
1032  CMPXCHG( 9, 25 ); CMPXCHG( 10, 26 ); CMPXCHG( 11, 27 );
1033  CMPXCHG( 12, 28 ); CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 );
1034  CMPXCHG( 2, 10 ); CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 );
1035  CMPXCHG( 5, 13 ); CMPXCHG( 6, 14 ); CMPXCHG( 7, 15 );
1036  CMPXCHG( 16, 24 ); CMPXCHG( 17, 25 ); CMPXCHG( 18, 26 );
1037  CMPXCHG( 19, 27 ); CMPXCHG( 20, 28 ); CMPXCHG( 8, 16 );
1038  CMPXCHG( 9, 17 ); CMPXCHG( 10, 18 ); CMPXCHG( 11, 19 );
1039  CMPXCHG( 12, 20 ); CMPXCHG( 13, 21 ); CMPXCHG( 14, 22 );
1040  CMPXCHG( 15, 23 ); CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 );
1041  CMPXCHG( 2, 6 ); CMPXCHG( 3, 7 ); CMPXCHG( 8, 12 );
1042  CMPXCHG( 9, 13 ); CMPXCHG( 10, 14 ); CMPXCHG( 11, 15 );
1043  CMPXCHG( 16, 20 ); CMPXCHG( 17, 21 ); CMPXCHG( 18, 22 );
1044  CMPXCHG( 19, 23 ); CMPXCHG( 24, 28 ); CMPXCHG( 4, 16 );
1045  CMPXCHG( 5, 17 ); CMPXCHG( 6, 18 ); CMPXCHG( 7, 19 );
1046  CMPXCHG( 12, 24 ); CMPXCHG( 13, 25 ); CMPXCHG( 14, 26 );
1047  CMPXCHG( 15, 27 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
1048  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
1049  CMPXCHG( 13, 17 ); CMPXCHG( 14, 18 ); CMPXCHG( 15, 19 );
1050  CMPXCHG( 20, 24 ); CMPXCHG( 21, 25 ); CMPXCHG( 22, 26 );
1051  CMPXCHG( 23, 27 ); CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 );
1052  CMPXCHG( 4, 6 ); CMPXCHG( 5, 7 ); CMPXCHG( 8, 10 );
1053  CMPXCHG( 9, 11 ); CMPXCHG( 12, 14 ); CMPXCHG( 13, 15 );
1054  CMPXCHG( 16, 18 ); CMPXCHG( 17, 19 ); CMPXCHG( 20, 22 );
1055  CMPXCHG( 21, 23 ); CMPXCHG( 24, 26 ); CMPXCHG( 25, 27 );
1056  CMPXCHG( 2, 16 ); CMPXCHG( 3, 17 ); CMPXCHG( 6, 20 );
1057  CMPXCHG( 7, 21 ); CMPXCHG( 10, 24 ); CMPXCHG( 11, 25 );
1058  CMPXCHG( 14, 28 ); CMPXCHG( 2, 8 ); CMPXCHG( 3, 9 );
1059  CMPXCHG( 6, 12 ); CMPXCHG( 7, 13 ); CMPXCHG( 10, 16 );
1060  CMPXCHG( 11, 17 ); CMPXCHG( 14, 20 ); CMPXCHG( 15, 21 );
1061  CMPXCHG( 18, 24 ); CMPXCHG( 19, 25 ); CMPXCHG( 22, 28 );
1062  CMPXCHG( 2, 4 ); CMPXCHG( 3, 5 ); CMPXCHG( 6, 8 );
1063  CMPXCHG( 7, 9 ); CMPXCHG( 10, 12 ); CMPXCHG( 11, 13 );
1064  CMPXCHG( 14, 16 ); CMPXCHG( 15, 17 ); CMPXCHG( 18, 20 );
1065  CMPXCHG( 19, 21 ); CMPXCHG( 22, 24 ); CMPXCHG( 23, 25 );
1066  CMPXCHG( 26, 28 ); CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 );
1067  CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 );
1068  CMPXCHG( 10, 11 ); CMPXCHG( 12, 13 ); CMPXCHG( 14, 15 );
1069  CMPXCHG( 16, 17 ); CMPXCHG( 18, 19 ); CMPXCHG( 20, 21 );
1070  CMPXCHG( 22, 23 ); CMPXCHG( 24, 25 ); CMPXCHG( 26, 27 );
1071  CMPXCHG( 1, 16 ); CMPXCHG( 3, 18 ); CMPXCHG( 5, 20 );
1072  CMPXCHG( 7, 22 ); CMPXCHG( 9, 24 ); CMPXCHG( 11, 26 );
1073  CMPXCHG( 13, 28 ); CMPXCHG( 7, 14 ); CMPXCHG( 9, 16 );
1074  CMPXCHG( 11, 18 ); CMPXCHG( 13, 20 ); CMPXCHG( 11, 14 );
1075  CMPXCHG( 13, 16 );
1076  return pcl::Max( f[13], f[14] );
1077  case 30:
1078  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 2, 18 );
1079  CMPXCHG( 3, 19 ); CMPXCHG( 4, 20 ); CMPXCHG( 5, 21 );
1080  CMPXCHG( 6, 22 ); CMPXCHG( 7, 23 ); CMPXCHG( 8, 24 );
1081  CMPXCHG( 9, 25 ); CMPXCHG( 10, 26 ); CMPXCHG( 11, 27 );
1082  CMPXCHG( 12, 28 ); CMPXCHG( 13, 29 ); CMPXCHG( 0, 8 );
1083  CMPXCHG( 1, 9 ); CMPXCHG( 2, 10 ); CMPXCHG( 3, 11 );
1084  CMPXCHG( 4, 12 ); CMPXCHG( 5, 13 ); CMPXCHG( 6, 14 );
1085  CMPXCHG( 7, 15 ); CMPXCHG( 16, 24 ); CMPXCHG( 17, 25 );
1086  CMPXCHG( 18, 26 ); CMPXCHG( 19, 27 ); CMPXCHG( 20, 28 );
1087  CMPXCHG( 21, 29 ); CMPXCHG( 8, 16 ); CMPXCHG( 9, 17 );
1088  CMPXCHG( 10, 18 ); CMPXCHG( 11, 19 ); CMPXCHG( 12, 20 );
1089  CMPXCHG( 13, 21 ); CMPXCHG( 14, 22 ); CMPXCHG( 15, 23 );
1090  CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 ); CMPXCHG( 2, 6 );
1091  CMPXCHG( 3, 7 ); CMPXCHG( 8, 12 ); CMPXCHG( 9, 13 );
1092  CMPXCHG( 10, 14 ); CMPXCHG( 11, 15 ); CMPXCHG( 16, 20 );
1093  CMPXCHG( 17, 21 ); CMPXCHG( 18, 22 ); CMPXCHG( 19, 23 );
1094  CMPXCHG( 24, 28 ); CMPXCHG( 25, 29 ); CMPXCHG( 4, 16 );
1095  CMPXCHG( 5, 17 ); CMPXCHG( 6, 18 ); CMPXCHG( 7, 19 );
1096  CMPXCHG( 12, 24 ); CMPXCHG( 13, 25 ); CMPXCHG( 14, 26 );
1097  CMPXCHG( 15, 27 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
1098  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
1099  CMPXCHG( 13, 17 ); CMPXCHG( 14, 18 ); CMPXCHG( 15, 19 );
1100  CMPXCHG( 20, 24 ); CMPXCHG( 21, 25 ); CMPXCHG( 22, 26 );
1101  CMPXCHG( 23, 27 ); CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 );
1102  CMPXCHG( 4, 6 ); CMPXCHG( 5, 7 ); CMPXCHG( 8, 10 );
1103  CMPXCHG( 9, 11 ); CMPXCHG( 12, 14 ); CMPXCHG( 13, 15 );
1104  CMPXCHG( 16, 18 ); CMPXCHG( 17, 19 ); CMPXCHG( 20, 22 );
1105  CMPXCHG( 21, 23 ); CMPXCHG( 24, 26 ); CMPXCHG( 25, 27 );
1106  CMPXCHG( 2, 16 ); CMPXCHG( 3, 17 ); CMPXCHG( 6, 20 );
1107  CMPXCHG( 7, 21 ); CMPXCHG( 10, 24 ); CMPXCHG( 11, 25 );
1108  CMPXCHG( 14, 28 ); CMPXCHG( 15, 29 ); CMPXCHG( 2, 8 );
1109  CMPXCHG( 3, 9 ); CMPXCHG( 6, 12 ); CMPXCHG( 7, 13 );
1110  CMPXCHG( 10, 16 ); CMPXCHG( 11, 17 ); CMPXCHG( 14, 20 );
1111  CMPXCHG( 15, 21 ); CMPXCHG( 18, 24 ); CMPXCHG( 19, 25 );
1112  CMPXCHG( 22, 28 ); CMPXCHG( 23, 29 ); CMPXCHG( 2, 4 );
1113  CMPXCHG( 3, 5 ); CMPXCHG( 6, 8 ); CMPXCHG( 7, 9 );
1114  CMPXCHG( 10, 12 ); CMPXCHG( 11, 13 ); CMPXCHG( 14, 16 );
1115  CMPXCHG( 15, 17 ); CMPXCHG( 18, 20 ); CMPXCHG( 19, 21 );
1116  CMPXCHG( 22, 24 ); CMPXCHG( 23, 25 ); CMPXCHG( 26, 28 );
1117  CMPXCHG( 27, 29 ); CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 );
1118  CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 );
1119  CMPXCHG( 10, 11 ); CMPXCHG( 12, 13 ); CMPXCHG( 14, 15 );
1120  CMPXCHG( 16, 17 ); CMPXCHG( 18, 19 ); CMPXCHG( 20, 21 );
1121  CMPXCHG( 22, 23 ); CMPXCHG( 24, 25 ); CMPXCHG( 26, 27 );
1122  CMPXCHG( 28, 29 ); CMPXCHG( 1, 16 ); CMPXCHG( 3, 18 );
1123  CMPXCHG( 5, 20 ); CMPXCHG( 7, 22 ); CMPXCHG( 9, 24 );
1124  CMPXCHG( 11, 26 ); CMPXCHG( 13, 28 ); CMPXCHG( 7, 14 );
1125  CMPXCHG( 9, 16 ); CMPXCHG( 11, 18 ); CMPXCHG( 13, 20 );
1126  CMPXCHG( 15, 22 ); CMPXCHG( 11, 14 ); CMPXCHG( 13, 16 );
1127  CMPXCHG( 15, 18 ); CMPXCHG( 13, 14 ); CMPXCHG( 15, 16 );
1128  return MEAN( f[14], f[15] );
1129  case 31:
1130  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 2, 18 );
1131  CMPXCHG( 3, 19 ); CMPXCHG( 4, 20 ); CMPXCHG( 5, 21 );
1132  CMPXCHG( 6, 22 ); CMPXCHG( 7, 23 ); CMPXCHG( 8, 24 );
1133  CMPXCHG( 9, 25 ); CMPXCHG( 10, 26 ); CMPXCHG( 11, 27 );
1134  CMPXCHG( 12, 28 ); CMPXCHG( 13, 29 ); CMPXCHG( 14, 30 );
1135  CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 ); CMPXCHG( 2, 10 );
1136  CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 ); CMPXCHG( 5, 13 );
1137  CMPXCHG( 6, 14 ); CMPXCHG( 7, 15 ); CMPXCHG( 16, 24 );
1138  CMPXCHG( 17, 25 ); CMPXCHG( 18, 26 ); CMPXCHG( 19, 27 );
1139  CMPXCHG( 20, 28 ); CMPXCHG( 21, 29 ); CMPXCHG( 22, 30 );
1140  CMPXCHG( 8, 16 ); CMPXCHG( 9, 17 ); CMPXCHG( 10, 18 );
1141  CMPXCHG( 11, 19 ); CMPXCHG( 12, 20 ); CMPXCHG( 13, 21 );
1142  CMPXCHG( 14, 22 ); CMPXCHG( 15, 23 ); CMPXCHG( 0, 4 );
1143  CMPXCHG( 1, 5 ); CMPXCHG( 2, 6 ); CMPXCHG( 3, 7 );
1144  CMPXCHG( 8, 12 ); CMPXCHG( 9, 13 ); CMPXCHG( 10, 14 );
1145  CMPXCHG( 11, 15 ); CMPXCHG( 16, 20 ); CMPXCHG( 17, 21 );
1146  CMPXCHG( 18, 22 ); CMPXCHG( 19, 23 ); CMPXCHG( 24, 28 );
1147  CMPXCHG( 25, 29 ); CMPXCHG( 26, 30 ); CMPXCHG( 4, 16 );
1148  CMPXCHG( 5, 17 ); CMPXCHG( 6, 18 ); CMPXCHG( 7, 19 );
1149  CMPXCHG( 12, 24 ); CMPXCHG( 13, 25 ); CMPXCHG( 14, 26 );
1150  CMPXCHG( 15, 27 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
1151  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
1152  CMPXCHG( 13, 17 ); CMPXCHG( 14, 18 ); CMPXCHG( 15, 19 );
1153  CMPXCHG( 20, 24 ); CMPXCHG( 21, 25 ); CMPXCHG( 22, 26 );
1154  CMPXCHG( 23, 27 ); CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 );
1155  CMPXCHG( 4, 6 ); CMPXCHG( 5, 7 ); CMPXCHG( 8, 10 );
1156  CMPXCHG( 9, 11 ); CMPXCHG( 12, 14 ); CMPXCHG( 13, 15 );
1157  CMPXCHG( 16, 18 ); CMPXCHG( 17, 19 ); CMPXCHG( 20, 22 );
1158  CMPXCHG( 21, 23 ); CMPXCHG( 24, 26 ); CMPXCHG( 25, 27 );
1159  CMPXCHG( 28, 30 ); CMPXCHG( 2, 16 ); CMPXCHG( 3, 17 );
1160  CMPXCHG( 6, 20 ); CMPXCHG( 7, 21 ); CMPXCHG( 10, 24 );
1161  CMPXCHG( 11, 25 ); CMPXCHG( 14, 28 ); CMPXCHG( 15, 29 );
1162  CMPXCHG( 2, 8 ); CMPXCHG( 3, 9 ); CMPXCHG( 6, 12 );
1163  CMPXCHG( 7, 13 ); CMPXCHG( 10, 16 ); CMPXCHG( 11, 17 );
1164  CMPXCHG( 14, 20 ); CMPXCHG( 15, 21 ); CMPXCHG( 18, 24 );
1165  CMPXCHG( 19, 25 ); CMPXCHG( 22, 28 ); CMPXCHG( 23, 29 );
1166  CMPXCHG( 2, 4 ); CMPXCHG( 3, 5 ); CMPXCHG( 6, 8 );
1167  CMPXCHG( 7, 9 ); CMPXCHG( 10, 12 ); CMPXCHG( 11, 13 );
1168  CMPXCHG( 14, 16 ); CMPXCHG( 15, 17 ); CMPXCHG( 18, 20 );
1169  CMPXCHG( 19, 21 ); CMPXCHG( 22, 24 ); CMPXCHG( 23, 25 );
1170  CMPXCHG( 26, 28 ); CMPXCHG( 27, 29 ); CMPXCHG( 0, 1 );
1171  CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 );
1172  CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 ); CMPXCHG( 12, 13 );
1173  CMPXCHG( 14, 15 ); CMPXCHG( 16, 17 ); CMPXCHG( 18, 19 );
1174  CMPXCHG( 20, 21 ); CMPXCHG( 22, 23 ); CMPXCHG( 24, 25 );
1175  CMPXCHG( 26, 27 ); CMPXCHG( 28, 29 ); CMPXCHG( 1, 16 );
1176  CMPXCHG( 3, 18 ); CMPXCHG( 5, 20 ); CMPXCHG( 7, 22 );
1177  CMPXCHG( 9, 24 ); CMPXCHG( 11, 26 ); CMPXCHG( 13, 28 );
1178  CMPXCHG( 15, 30 ); CMPXCHG( 9, 16 ); CMPXCHG( 11, 18 );
1179  CMPXCHG( 13, 20 ); CMPXCHG( 15, 22 ); CMPXCHG( 13, 16 );
1180  CMPXCHG( 15, 18 ); CMPXCHG( 15, 16 );
1181  return pcl::Min( f[15], f[16] );
1182  case 32:
1183  CMPXCHG( 0, 16 ); CMPXCHG( 1, 17 ); CMPXCHG( 2, 18 );
1184  CMPXCHG( 3, 19 ); CMPXCHG( 4, 20 ); CMPXCHG( 5, 21 );
1185  CMPXCHG( 6, 22 ); CMPXCHG( 7, 23 ); CMPXCHG( 8, 24 );
1186  CMPXCHG( 9, 25 ); CMPXCHG( 10, 26 ); CMPXCHG( 11, 27 );
1187  CMPXCHG( 12, 28 ); CMPXCHG( 13, 29 ); CMPXCHG( 14, 30 );
1188  CMPXCHG( 15, 31 ); CMPXCHG( 0, 8 ); CMPXCHG( 1, 9 );
1189  CMPXCHG( 2, 10 ); CMPXCHG( 3, 11 ); CMPXCHG( 4, 12 );
1190  CMPXCHG( 5, 13 ); CMPXCHG( 6, 14 ); CMPXCHG( 7, 15 );
1191  CMPXCHG( 16, 24 ); CMPXCHG( 17, 25 ); CMPXCHG( 18, 26 );
1192  CMPXCHG( 19, 27 ); CMPXCHG( 20, 28 ); CMPXCHG( 21, 29 );
1193  CMPXCHG( 22, 30 ); CMPXCHG( 23, 31 ); CMPXCHG( 8, 16 );
1194  CMPXCHG( 9, 17 ); CMPXCHG( 10, 18 ); CMPXCHG( 11, 19 );
1195  CMPXCHG( 12, 20 ); CMPXCHG( 13, 21 ); CMPXCHG( 14, 22 );
1196  CMPXCHG( 15, 23 ); CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 );
1197  CMPXCHG( 2, 6 ); CMPXCHG( 3, 7 ); CMPXCHG( 8, 12 );
1198  CMPXCHG( 9, 13 ); CMPXCHG( 10, 14 ); CMPXCHG( 11, 15 );
1199  CMPXCHG( 16, 20 ); CMPXCHG( 17, 21 ); CMPXCHG( 18, 22 );
1200  CMPXCHG( 19, 23 ); CMPXCHG( 24, 28 ); CMPXCHG( 25, 29 );
1201  CMPXCHG( 26, 30 ); CMPXCHG( 27, 31 ); CMPXCHG( 4, 16 );
1202  CMPXCHG( 5, 17 ); CMPXCHG( 6, 18 ); CMPXCHG( 7, 19 );
1203  CMPXCHG( 12, 24 ); CMPXCHG( 13, 25 ); CMPXCHG( 14, 26 );
1204  CMPXCHG( 15, 27 ); CMPXCHG( 4, 8 ); CMPXCHG( 5, 9 );
1205  CMPXCHG( 6, 10 ); CMPXCHG( 7, 11 ); CMPXCHG( 12, 16 );
1206  CMPXCHG( 13, 17 ); CMPXCHG( 14, 18 ); CMPXCHG( 15, 19 );
1207  CMPXCHG( 20, 24 ); CMPXCHG( 21, 25 ); CMPXCHG( 22, 26 );
1208  CMPXCHG( 23, 27 ); CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 );
1209  CMPXCHG( 4, 6 ); CMPXCHG( 5, 7 ); CMPXCHG( 8, 10 );
1210  CMPXCHG( 9, 11 ); CMPXCHG( 12, 14 ); CMPXCHG( 13, 15 );
1211  CMPXCHG( 16, 18 ); CMPXCHG( 17, 19 ); CMPXCHG( 20, 22 );
1212  CMPXCHG( 21, 23 ); CMPXCHG( 24, 26 ); CMPXCHG( 25, 27 );
1213  CMPXCHG( 28, 30 ); CMPXCHG( 29, 31 ); CMPXCHG( 2, 16 );
1214  CMPXCHG( 3, 17 ); CMPXCHG( 6, 20 ); CMPXCHG( 7, 21 );
1215  CMPXCHG( 10, 24 ); CMPXCHG( 11, 25 ); CMPXCHG( 14, 28 );
1216  CMPXCHG( 15, 29 ); CMPXCHG( 2, 8 ); CMPXCHG( 3, 9 );
1217  CMPXCHG( 6, 12 ); CMPXCHG( 7, 13 ); CMPXCHG( 10, 16 );
1218  CMPXCHG( 11, 17 ); CMPXCHG( 14, 20 ); CMPXCHG( 15, 21 );
1219  CMPXCHG( 18, 24 ); CMPXCHG( 19, 25 ); CMPXCHG( 22, 28 );
1220  CMPXCHG( 23, 29 ); CMPXCHG( 2, 4 ); CMPXCHG( 3, 5 );
1221  CMPXCHG( 6, 8 ); CMPXCHG( 7, 9 ); CMPXCHG( 10, 12 );
1222  CMPXCHG( 11, 13 ); CMPXCHG( 14, 16 ); CMPXCHG( 15, 17 );
1223  CMPXCHG( 18, 20 ); CMPXCHG( 19, 21 ); CMPXCHG( 22, 24 );
1224  CMPXCHG( 23, 25 ); CMPXCHG( 26, 28 ); CMPXCHG( 27, 29 );
1225  CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 4, 5 );
1226  CMPXCHG( 6, 7 ); CMPXCHG( 8, 9 ); CMPXCHG( 10, 11 );
1227  CMPXCHG( 12, 13 ); CMPXCHG( 14, 15 ); CMPXCHG( 16, 17 );
1228  CMPXCHG( 18, 19 ); CMPXCHG( 20, 21 ); CMPXCHG( 22, 23 );
1229  CMPXCHG( 24, 25 ); CMPXCHG( 26, 27 ); CMPXCHG( 28, 29 );
1230  CMPXCHG( 30, 31 ); CMPXCHG( 1, 16 ); CMPXCHG( 3, 18 );
1231  CMPXCHG( 5, 20 ); CMPXCHG( 7, 22 ); CMPXCHG( 9, 24 );
1232  CMPXCHG( 11, 26 ); CMPXCHG( 13, 28 ); CMPXCHG( 15, 30 );
1233  CMPXCHG( 9, 16 ); CMPXCHG( 11, 18 ); CMPXCHG( 13, 20 );
1234  CMPXCHG( 15, 22 ); CMPXCHG( 13, 16 ); CMPXCHG( 15, 18 );
1235  return MEAN( f[15], f[16] );
1236  default:
1237  {
1238  distance_type n2 = distance_type( n >> 1 );
1239  if ( n & 1 )
1240  return *pcl::Select( f, f+n, n2 );
1241  return P::FloatToSample( (double( *pcl::Select( f, f+n, n2 ) )
1242  + double( *pcl::Select( f, f+n, n2-1 ) ))/2 );
1243  }
1244  }
1245  }
1246 
1247 #undef CMPXCHG
1248 #undef MEAN
1249 };
1250 
1251 // ----------------------------------------------------------------------------
1252 
1266 class PCL_CLASS SelectionFilter : public MorphologicalOperator
1267 {
1268 public:
1269 
1274  SelectionFilter() = default;
1275 
1279  SelectionFilter( float p )
1280  : k( pcl::Range( p, float( 0 ), float( 1 ) ) )
1281  {
1282  PCL_PRECONDITION( 0 <= p && p <= 1 )
1283  PCL_CHECK( 0 <= k && k <= 1 )
1284  }
1285 
1289  SelectionFilter( const SelectionFilter& ) = default;
1290 
1293  MorphologicalOperator* Clone() const override
1294  {
1295  return new SelectionFilter( *this );
1296  }
1297 
1301  float SelectionPoint() const
1302  {
1303  return k;
1304  }
1305 
1309  void SetSelectionPoint( float _k )
1310  {
1311  PCL_PRECONDITION( 0 <= _k && _k <= 1 )
1312  k = pcl::Range( _k, float( 0 ), float( 1 ) );
1313  }
1314 
1317  String Description() const override
1318  {
1319  return String().Format( "Selection, k=%.5f", k );
1320  }
1321 
1327  {
1328  return Operate( f, n );
1329  }
1330 
1336  {
1337  return Operate( f, n );
1338  }
1339 
1345  {
1346  return Operate( f, n );
1347  }
1348 
1354  {
1355  return Operate( f, n );
1356  }
1357 
1363  {
1364  return Operate( f, n );
1365  }
1366 
1367 private:
1368 
1369  float k = 0.5F;
1370 
1371  template <typename T>
1372  T Operate( T* f, size_type n ) const
1373  {
1374  return *pcl::Select( f, f+n, distance_type( pcl::RoundInt( k*(n-1) ) ) );
1375  }
1376 };
1377 
1378 // ----------------------------------------------------------------------------
1379 
1387 class PCL_CLASS MidpointFilter : public MorphologicalOperator
1388 {
1389 public:
1390 
1393  MorphologicalOperator* Clone() const override
1394  {
1395  return new MidpointFilter( *this );
1396  }
1397 
1400  String Description() const override
1401  {
1402  return "Midpoint";
1403  }
1404 
1410  {
1411  return Operate( f, n, (FloatPixelTraits*)0 );
1412  }
1413 
1419  {
1420  return Operate( f, n, (DoublePixelTraits*)0 );
1421  }
1422 
1428  {
1429  return Operate( f, n, (UInt8PixelTraits*)0 );
1430  }
1431 
1437  {
1438  return Operate( f, n, (UInt16PixelTraits*)0 );
1439  }
1440 
1446  {
1447  return Operate( f, n, (UInt32PixelTraits*)0 );
1448  }
1449 
1450 private:
1451 
1452  template <typename T, class P>
1453  static T Operate( T* f, size_type n, P* )
1454  {
1455  T* min, * max;
1456  pcl::FindExtremeItems( min, max, f, f+n );
1457  return P::FloatToSample( (double( *min ) + double( *max ))/2 );
1458  }
1459 };
1460 
1461 // ----------------------------------------------------------------------------
1462 
1479 {
1480 public:
1481 
1488  AlphaTrimmedMeanFilter() = default;
1489 
1495  : d( pcl::Range( t, float( 0 ), float( 1 ) ) )
1496  {
1497  PCL_PRECONDITION( 0 <= t && t <= 1 )
1498  PCL_CHECK( 0 <= d && d <= 1 )
1499  }
1500 
1504  AlphaTrimmedMeanFilter( const AlphaTrimmedMeanFilter& ) = default;
1505 
1508  MorphologicalOperator* Clone() const override
1509  {
1510  return new AlphaTrimmedMeanFilter( *this );
1511  }
1512 
1516  float TrimmingFactor() const
1517  {
1518  return d;
1519  }
1520 
1524  void SetTrimmingFactor( float t )
1525  {
1526  PCL_PRECONDITION( 0 <= t && t <= 1 )
1527  d = pcl::Range( t, float( 0 ), float( 1 ) );
1528  }
1529 
1532  String Description() const override
1533  {
1534  return String().Format( "Alpha-trimmed mean, d=%.5f", d );
1535  }
1536 
1542  {
1543  return Operate( f, n, (FloatPixelTraits*)0 );
1544  }
1545 
1551  {
1552  return Operate( f, n, (DoublePixelTraits*)0 );
1553  }
1554 
1560  {
1561  return Operate( f, n, (UInt8PixelTraits*)0 );
1562  }
1563 
1569  {
1570  return Operate( f, n, (UInt16PixelTraits*)0 );
1571  }
1572 
1578  {
1579  return Operate( f, n, (UInt32PixelTraits*)0 );
1580  }
1581 
1582 private:
1583 
1584  float d = 0.2F;
1585 
1586  template <typename T, class P>
1587  T Operate( T* f, size_type n, P* ) const
1588  {
1589  pcl::Sort( f, f+n );
1590  double s = 0;
1591  size_type i1 = RoundInt( d*((n - 1) >> 1) );
1592  size_type i2 = n-i1;
1593  for ( size_type i = i1; i < i2; ++i )
1594  s += f[i];
1595  return P::FloatToSample( s/(i2 - i1) );
1596  }
1597 };
1598 
1599 // ----------------------------------------------------------------------------
1600 
1601 } // pcl
1602 
1603 #endif // __PCL_MorphologicalOperator_h
1604 
1605 // ----------------------------------------------------------------------------
1606 // EOF pcl/MorphologicalOperator.h - Released 2020-07-31T19:33:04Z
traits_type::sample sample
Definition: PixelTraits.h:4665
void FindExtremeItems(FI &kmin, FI &kmax, FI i, FI j)
Definition: Utility.h:517
64-bit IEEE 754 normalized floating point real pixel traits.
Definition: PixelTraits.h:924
32-bit unsigned integer pixel traits.
Definition: PixelTraits.h:4653
Alpha-trimmed mean operator.
int RoundInt(T x)
Definition: Math.h:1478
Erosion morphological operator.
PCL root namespace.
Definition: AbstractImage.h:76
MorphologicalOperator * Clone() const override
FI MaxItem(FI i, FI j)
Definition: Utility.h:479
Morphological selection operator.
An exception that indicates an unsupported feature.
Definition: Exception.h:343
void Sort(BI i, BI j)
Definition: Sort.h:534
traits_type::sample sample
Definition: PixelTraits.h:364
String Description() const override
Dilation morphological operator.
8-bit unsigned integer pixel traits.
Definition: PixelTraits.h:2965
MorphologicalOperator * Clone() const override
constexpr const T & Range(const T &x, const T &a, const T &b)
Definition: Utility.h:190
Abstract base class of all PCL morphological operators.
size_t size_type
Definition: Defs.h:543
Morphological median operator.
String & Format(const_c_string8 fmt,...)
Definition: String.h:10877
RI Select(RI i, RI j, distance_type k)
Definition: Selection.h:165
Unicode (UTF-16) string.
Definition: String.h:7916
String Description() const override
constexpr const T & Max(const T &a, const T &b)
Definition: Utility.h:119
32-bit IEEE 754 normalized floating point real pixel traits.
Definition: PixelTraits.h:352
Generic complex number.
Definition: Complex.h:83
constexpr const T & Min(const T &a, const T &b)
Definition: Utility.h:90
virtual String Description() const
MorphologicalOperator * Clone() const override
MorphologicalOperator * Clone() const override
String Description() const override
FI MinItem(FI i, FI j)
Definition: Utility.h:441
traits_type::sample sample
Definition: PixelTraits.h:3821
String Description() const override
ptrdiff_t distance_type
Definition: Defs.h:549
String Description() const override
MorphologicalOperator * Clone() const override
MorphologicalOperator * Clone() const override
traits_type::sample sample
Definition: PixelTraits.h:2977
traits_type::sample sample
Definition: PixelTraits.h:936
16-bit unsigned integer pixel traits.
Definition: PixelTraits.h:3809
String Description() const override