title: Reducing processing time of images in python
body: <p>I have a python scripts that processes  black and white images.
  The first thing that I do is the usual process that takes not more than 170 ms which is</p>
  <pre><code>  img = img[200:900, 250:1100]
    imag = image_resize(img, height=960, width=1280)
    ImgBlur = cv2.GaussianBlur(imag, (11, 11), 0)
    ret, thresh1 = cv2.threshold(ImgBlur, 100, 255, cv2.THRESH_BINARY)
    imgCanny = cv2.Canny(thresh1, 100, 100)
  </code></pre>
  <p>Immediately after I need to find the white part in the image and I execute this function</p>
  <pre><code>  A = np.array(imgCanny)
    xpos = []
    ypos = []
    for i in range(len(A)):
        for j in range(len(A[i])):
            if A[i][j] == 255:
                ypos.append(i)
                xpos.append(j)
  </code></pre>
  <p>My problem is that this function is taking 2.3 seconds, mostly 98% of the processing time.
  Does anyone have an idea of how can I decrease that by another alternative?</p>
  <p>The imageCanny result that I get is this kind of image <a href="https://i.stack.imgur.com/AlHOE.png" rel="nofollow noreferrer">imgCanny</a></p>