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

Fix bug when creating symmetrical GLCM #261

Merged
merged 2 commits into from Jun 1, 2017

Conversation

JoostJM
Copy link
Collaborator

@JoostJM JoostJM commented May 30, 2017

To make GLCM symmetrical, the python code performed an inplace addition: P_glcm += numpy.transpose(P_glcm, (1, 0, 2)). However, when the matrix exceeds a certain size, this produces buggy behaviour, where for some elements, the calculated value equals P_glcm += P_glcm + numpy.transpose(P_glcm, (1, 0, 2)). This is caused by the fact that numpy.transpose returns a view, and not a copy of the array. Then, if the additions have to be processed in multiple chunks, the addition will become erroneous.

Use numpy.copy to get a transposed copy of the GLCM and not just a view of the GLCM.

To make GLCM symmetrical, the python code performed an inplace addition: `P_glcm += numpy.transpose(P_glcm, (1, 0, 2))`. However, when the matrix exceeds a certain size, this produces buggy behaviour, where for some elements, the calculated value equals `P_glcm += P_glcm + numpy.transpose(P_glcm, (1, 0, 2))`. This is caused by the fact that numpy.transpose returns a *view*, and not a copy of the array. Then, if the additions have to be processed in multiple chunks, the addition will become erroneous.

Use `numpy.copy` to get a transposed copy of the GLCM and not just a view of the GLCM.
@JoostJM
Copy link
Collaborator Author

JoostJM commented May 30, 2017

Note: baseline is not affected, as this bug occurred when creating a symmetrical GLCM, whereas the baseline is made using the assymetrical GLCM.

@JoostJM JoostJM added the bug label May 31, 2017
@JoostJM JoostJM merged commit 1d8e74e into AIM-Harvard:master Jun 1, 2017
@JoostJM JoostJM deleted the symmetrical-glcm-bug branch August 16, 2017 10:13
@JoostJM JoostJM added this to Bugfixes in Feature definitions Feb 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Feature definitions
  
Bugfixes
Development

Successfully merging this pull request may close these issues.

None yet

1 participant