title: Improve these opencv nested loop
body: <p>I want to check each pixcel in 11 imgs,get rid of the extremum,and use the center value to calculate mean value.</p>
  
  <pre class="lang-py prettyprint-override"><code>    import cv2  
      import numpy as np
  
      img1 = cv2.imread("J:/1.jpg", cv2.IMREAD_COLOR)
      img2 = cv2.imread("J:/2.jpg", cv2.IMREAD_COLOR)
      img3 = cv2.imread("J:/3.jpg", cv2.IMREAD_COLOR)
      img4 = cv2.imread("J:/4.jpg", cv2.IMREAD_COLOR)
      img5 = cv2.imread("J:/5.jpg", cv2.IMREAD_COLOR)
      img6 = cv2.imread("J:/6.jpg", cv2.IMREAD_COLOR)
      img7 = cv2.imread("J:/7.jpg", cv2.IMREAD_COLOR)
      img8 = cv2.imread("J:/8.jpg", cv2.IMREAD_COLOR)
      img9 = cv2.imread("J:/9.jpg", cv2.IMREAD_COLOR)
      img10 = cv2.imread("J:/10.jpg", cv2.IMREAD_COLOR)
      img11 = cv2.imread("J:/11.jpg", cv2.IMREAD_COLOR)
      imgList = [img1, img2, img3, img4, img5, img6, img7, img8, img9, img10, img11]  
  
      height = img1.shape[0]
      width = img1.shape[1]
      imgall = np.array(imgList)
  
      png = np.zeros((height, width, 4), dtype=np.uint8)
  
      start1 = cv2.getTickCount()
      for yh in range(height):
          for xw in range(width):
              pstd = np.std(imgall[:, yh, xw, :], axis=0)
              pstdmean = np.mean(pstd)
              if pstdmean &lt; 50:
                  if pstdmean &lt; 10:
                      png[yh, xw] = list(np.mean(imgall[:, yh, xw, :], axis=0)) + [255]
                  else:
                      pmedian = np.median(imgall[:, yh, xw, :], axis=0)
                      png[yh, xw] = list(pmedian) + [255]
      end1 = cv2.getTickCount()
      during1 = (end1 - start1) / cv2.getTickFrequency()
      print(during1)
  </code></pre>
  
  <p>I'm trying to find how to get "gather number"/"mode number",like:histogram,Euclidean Distance,bgr2grey,Normal distribution...</p>
  
  <p>I would like to replace this poor median method.</p>