[scikit-image] GLCM for non-rectangular image

NASAHARA Kenlo 24dakenlo at gmail.com
Thu Sep 7 00:42:55 EDT 2017


Thanks, Juan

What a clever idea! 

You mean, we put a dummy number (which is 
larger than the actual maximum) and create the 
GLCM, and then we remove the pairs with the
valid number and the dummy number. (Perhaps the 
normalization should be done after that manually).

I will try it!

Kenlo Nasahara

On Thu, 7 Sep 2017 14:29:16 +1000
Juan Nunez-Iglesias <jni.soma at gmail.com> wrote:

> Hi Kenlo,
> 
> Thanks for your email.
> 
> `np.nan` is only defined for floating point images, but GLCM only works for non-negative integer images, since the intensity values need to serve as indices to a matrix.
> 
> Therefore, in order to ignore NULL values, you just need to create an array with an arbitrary value as NULL. This is actually not too hard. If you start with a uint8 image, make a uint16 image with a mask where values to be ignored are set to 256.
> 
> Then, use greycomatrix with levels=257.
> 
> Finally, from the documentation:
> 
> >        The grey-level co-occurrence histogram. The value
> >        `P[i,j,d,theta]` is the number of times that grey-level `j`
> >        occurs at a distance `d` and at an angle `theta` from
> >        grey-level `i`.
> 
> Thus you can get your odd-shaped GLCM, ignoring values outside your mask, with:
> 
> out = greycomatrix(image, […], levels=257)
> result = out[:256, :256]
> 
> I hope this helps!
> 
> If you have suggestions for making this process easier, please let us know!
> 
> Juan.
> 
> On 7 Sep 2017, 11:23 AM +1000, NASAHARA Kenlo <24dakenlo at gmail.com>, wrote:
> > Dear scikit-image community:
> >
> > I am trying GLCM functions in scikit-image.
> > http://scikit-image.org/docs/dev/auto_examples/features_detection/plot_glcm.html
> >
> > I wonder whether they can treat images with irregular
> > shapes, such as a circle, an oval, or some more complex
> > forms (not only rectagle).
> >
> > In the "greycomatrix", function:
> >
> > def greycomatrix(image, distances, angles, levels=None, symmetric=False, normed=False):
> >
> > image : array_like
> > Integer typed input image. Only positive valued images are supported.
> > If type is other than uint8, the argument `levels` needs to be set.
> >
> > the "image" seems to be required to be a rectangle.
> >
> > If NAN or NULL values are allowed in the "image", and the function skips
> > treating those "no-data" pixels assigned with NAN or NULL, then we
> > may be able to treat any shapes of image, by filling the pixels outside the
> > boudary with NAN or NULL.
> >
> > However, in the source code of "_glcm_loop" function
> > (https://searchcode.com/codesearch/view/83509141/), all the pixels
> > within the rectangular image are scanned, without permitting "no-data".
> >
> > My questions:
> > 1. Do you know how to treat GLCM in non-rectangular image with
> > scikit-image?
> > 2. If not, do you know any other ways to do that instead of scikit-image?
> > 3. Do you think it is a reasonable idea to change GLCM functions in
> > scikit-image so that they can treat no-data (allowing NAN or NULL)?
> >
> > --
> > Kenlo Nishida Nasahara
> > Faculty of Life and Environmental Sciences
> > University of Tsukuba, Japan 305-8572
> > 24dakenlo at gmail.com
> > _______________________________________________
> > scikit-image mailing list
> > scikit-image at python.org
> > https://mail.python.org/mailman/listinfo/scikit-image


-- 
Kenlo Nishida Nasahara
Faculty of Life and Environmental Sciences
University of Tsukuba, Japan 305-8572
24dakenlo at gmail.com


More information about the scikit-image mailing list