title: Python: taking the GLCM of a non-rectangular region
body: <p>I have been using the SLIC implementation of skimage to segment images in superpixels. I would like to use GLCMs to extract additional features from these superpixels for a classification problem. These superpixels are not rectangular. In MATLAB you can set pixels to NaN and they will be ignored by the algorithm (<a href="https://stackoverflow.com/questions/8237000/the-method-of-calculate-the-glcm-of-a-specific-point-in-a-image">link</a>). I could use this to make bounding boxes around the superpixels and then just setting the unused pixels to NaN.</p>
  
  <p>The <a href="http://scikit-image.org/docs/dev/api/skimage.feature.html#skimage.feature.greycomatrix" rel="nofollow noreferrer">greycomatrix</a> function in skimage does not work entirely the same as the MATLAB implementation however. When setting pixels to NaN the function fails on an assert to check if all values are larger than 0.</p>
  
  <p>Is there a Python implementation available which is able to work with nonrectangular ROIs?</p>