Skip to content
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

ENH: Add check to prevent too many bins from being generated #391

Merged
merged 1 commit into from Jun 20, 2018

Commits on Jun 20, 2018

  1. ENH: Add check to prevent too many bins from being generated

    When the GLCM is calculated in C, an array is generated of size Ng x Ng x Na (Ng = number of bins, Na = number of angles). If the number of bins exceeds 12852 with 13 angles, the resulting array has more than 2,147,483,648 elements, which in turn causes the index variable (int32) to overflow, crashing the python interpreter.
    
    Seeing as generally ~100 bins are advised, limit the number of bins instead of using datatypes that can reach higher numbers. A maximum number of 7000 is chosen (allowing for a maximum of 43 angles in GLCM). If the number of bins exceeds this number, an error is raised.
    
    Additionally, add a size check prior to instantiating the output arrays in C. If the size > 2147483648, throw an error.
    
    Fix typo in error message when calculation of angles fails.
    JoostJM committed Jun 20, 2018
    Copy the full SHA
    844e03d View commit details
    Browse the repository at this point in the history