Added (UDef-ARP.py) binary map checker functions #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added a binary map checker to automatically check whether the input data is a binary map or not. After the function returns False, an error message will show up.
A binary map (boolean map) is characterized by a data type of either byte or integer, with minimum and maximum values set to 0 and 1. The only exception is when the data type is real, with minimum and maximum values precisely at 0.0000000 and 1.0000000 and would need to check pixel values.
The validation logic is as follows:
If data type is byte or integer and min is 0 and max is 1, it returns True.
If data type is real and min is 0 and max is 1, it executes a function to check the number of unique values. Because the function only run under this condition and break when the unique value larger than 2, it executed fast in my testing.
(1) If the unique number is 2 [0,1], return True.
(2) If the number is larger than 2, break and return False.
For any other scenario, it returns False.