title: Comparing pixels in alpha-trimmed filter
body: <p>I have the following problem. I have written code for alpha-trimmed filter in opencv library. I think that it is properly constructed but I don't know how to compare two 3 channels pixels during sorting a 'window with pixels'. In my code it is done but comparing two  but it is impossible for vectors. I assume that i should compare it one channel and after second and so on. Have you any hints for me, or could you propose some modifications in my code. This is my code.</p>
  
  <pre><code>int alphatrimmed(Mat img, int alpha)
  {
  Mat img9 = img.clone();
  const int start = alpha;
  const int end = 9 - alpha;
  //going through whole image
  for (int i = 1; i &lt; img.rows - 1; i++)
      for (int j = 1; j &lt; img.cols-1; j++)
  {
          int k = 0;
          Vec3b element[9];
  //selecting elements
          for (int m = i - 1; m &lt; i + 2; m++)
          for (int n = j - 1; n &lt; j + 2; n++)
              element[k++] = img.at&lt;Vec3b&gt;(m*img.cols + n);
              for (int i = 0; i &lt; end; i++)
              {
                  int min = i;
                  for (int j = i + 1; j &lt; 9; j++)
                  if (element[j] &lt; element[min])
                      min = j;
                  Vec3b temp = element[i];
                  element[i] = element[min];
                  element[min] = temp;
              }
              const int result = (i - 1)*(img.cols - 2) + j - 1;
              img9.at&lt;Vec3b&gt;(result) = element[start];
              for (int j = start + 1; j &lt; end; j++)
                  img9.at&lt;Vec3b&gt;(result) += element[j];
              img9.at&lt;Vec3b&gt;(result) /= 9 - alpha;
  }
      namedWindow("AlphaTrimmed Filter", WINDOW_AUTOSIZE);
      imshow("AlphaTrimmed Filter", img9);
      return 0;
  }
  </code></pre>
  
  <p>Thank you for your time spent on solving my problem.</p>