code: def tenengrad(img, ksize=3):
      ''''TENG' algorithm (Krotkov86)'''
      Gx = cv2.Sobel(img, ddepth=cv2.CV_64F, dx=1, dy=0, ksize=ksize)
      Gy = cv2.Sobel(img, ddepth=cv2.CV_64F, dx=0, dy=1, ksize=ksize)
      FM = Gx*Gx + Gy*Gy
      mn = cv2.mean(FM)[0]
      if np.isnan(mn):
          return np.nanmean(FM)
      return mf tenengrad(img, ksize=3):
      ''''TENG' algorithm (Krotkov86)'''
      Gx = cv2.Sobel(img, ddepth=cv2.CV_64F, dx=1, dy=0, ksize=ksize)
      Gy = cv2.Sobel(img, ddepth=cv2.CV_64F, dx=0, dy=1, ksize=ksize)
      FM = Gx*Gx + Gy*Gy
      mn = cv2.mean(FM)[0]
      if np.isnan(mn):
          return np.nanmean(FM)
      return mn
docs: TENG' algorithm (Krotkov86)