-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correlation metric outside bounds of -1 to +1 #6
Comments
@ailich I have had the same problem. Do you have any news? I am trying to apply textural features as input variables of a machine learning model. I have doubts about whether to keep the values obtained (although I do not understand them) or assign 1 to values> 1 and -1 to values <-1. |
@sermomon I have not found a solution to this, but there have been github commits so it's possible that it might be fixed in a newer version (e.g. have you tried with the development branch on github ( Also just some general good resources for GLCM include: |
@ailich Thanks for your quick response. I'm going to try with the developing version. I also have access to a Matlab, so I am going to also test from Matlab and report the results. Which tool do you suggest from QGis? I agree with the comments I have read about the inf and -inf values, but I also don't understand the > 1 and <-1 values. It might be interesting to apply the glcm() function to a raster with the same value for all pixels. If the correlation values = 1, the probability is that it is an error, if, on the contrary, very high values are obtained, the correlation may be on another scale of values. Maybe my contribution is a little inexperienced, but I'm going to do these tests. |
QGIS's processing toolbox has access to functions from many other open source GIS's. r.texture from GRASS GIS should do what you want. It's important to note that "r.texture assumes grey levels ranging from 0 to 255 as input. The input is automatically rescaled to 0 to 255 if the input map range is outside of this range," so you may need to use r.recode and r.quantile as well to do the quantization step. QGIS can also access the Orfeo Toolbox which has a tool to calculate GLCM textures. If you need to code it in R, the RQGIS3 package or RQGIS package lets you call QGIS from R. RQGIS3 is continually developed and works with QGIS3, wile RQGIS is no longer being developed and works with QGIS2. RQGIS3 will give you access to QGIS and GRASS Functions, but cannot link to the Orfeo Toolbox, while RQGIS can also link to the Orfeo Toolbox but its development is no longer being supported. If you do end up using RQGIS/RQGIS3, because you have to do this for many surfaces, I recommend learning how the tool works in QGIS first because having the GUI makes it easier to figure out how to set things up properly. |
I've created a small reproducible example to demonstrate the issue, which could maybe help understand it.
|
@sermomon did you have any luck with the MATLAB comparisons? |
@sermomon, I coded up an alternative implementation here (https://github.com/ailich/GLCMTextures) if you want to test it out. |
I'm getting values outside the bounds that should be possible for correlation. Correlation should be constrained to -1 to +1 (when scale_factor=1), but about 1% of the resulting non NA values seem to fall outside this range when using the glcm function on my raster data. The resulting correlation glcm raster has max and min values of +Inf and -Inf and also contains real numbers outside the -1 to +1 bounds ranging from about 2 to 47.
(Running R version 3.4.1 on Windows 10)
The text was updated successfully, but these errors were encountered: