title: Python: How to check if an array is contained in another array using `numpy.all`and `numpy.any`?
body: <p>I am working on detecting certain areas on an image using <code>scikit-image</code>. I was able to detect blobs using <code>blob_doh</code> function. Also I was able to find regions using <code>Canny edge detector</code> and labeling. </p>
  
  <p>Now I want to check if the blobs, which I found before, are inside of those regions, and sort out those blobs which are not in any of the regions. Then I want to draw only the blobs which are inside the regions.</p>
  
  <p>I was trying to implement this using <code>numpy.all</code> and <code>numpy.any</code> but I probably misunderstand the way these functions work. Here is what I have:</p>
  
  <pre><code>for region in regions:
      # list of pixels' coords in a region
      pixel_array = region.coords
  
      # check if a blob is inside the region
      for blob in blobs_doh:
          y, x, r = blob
  
          if np.any(pixel_array == [x, y]):
              c = plt.Circle((x, y), r, color='red', linewidth=1, fill=False)
              minr, minc, maxr, maxc = region.bbox
              rect = mpatches.Rectangle((minc, minr), maxc - minc, maxr - minr, fill=False, edgecolor='lime', linewidth=1)
              # draw blobs and regtangles
              ax.add_patch(c)
              ax.add_patch(rect)
              break
  </code></pre>
  
  <p>So, what I do. <code>region</code> is an array of the shape <code>[[a1, b1], [a2, b2], [a3, b3], ..., [an, bn]]</code>, and a <code>blob</code> is an array of the shape <code>[c, d]</code>. My idea was to check if there is any sub-array in <code>region</code> equal to <code>blob</code>. I could do it of course in trivial way searching in a loop, but I thought there is more efficient way of doing this, and tried to use <code>numpy.all</code> and <code>numpy.any</code>. Unfortunately, I cannot get it working correctly. The line <code>np.any(pixel_array == [x, y])</code> checks for only the first element of <code>blob</code> but not for the sub-array <code>[x, y]</code> as a whole. I also tried different combinations of <code>.any</code> and <code>.all</code> using <code>axis</code> argument:</p>
  
  <pre><code>np.any(pixel_array == [x, y], axis = 1).all(axis = 0)
  </code></pre>
  
  <p>but could not get any acceptable result.</p>
  
  <p>Please help me with this task. What is the better way of performing such a check?</p>
  
  <p>Thank you.</p>