Texture analysis using Haralick Descriptors for Computer Vision tasks#8004
Texture analysis using Haralick Descriptors for Computer Vision tasks#8004tianyizheng02 merged 28 commits intoTheAlgorithms:masterfrom
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
|
|
||
|
|
||
| def normalize_image( | ||
| image: np.ndarray, cap: float = 255.0, data_type=np.uint8 |
There was a problem hiding this comment.
Please provide type hint for the parameter: data_type
| return np.where(image > threshold, 1, 0) | ||
|
|
||
|
|
||
| def transform(image: np.ndarray, kind: str, kernel=None) -> np.ndarray: |
There was a problem hiding this comment.
Please provide type hint for the parameter: kernel
| return true_mask, false_mask | ||
|
|
||
|
|
||
| def matrix_concurrency(image: np.ndarray, coordinate) -> np.ndarray: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file computer_vision/haralick_descriptors.py, please provide doctest for the function matrix_concurrency
Please provide type hint for the parameter: coordinate
| return matrix / np.sum(matrix) | ||
|
|
||
|
|
||
| def haralick_descriptors(matrix: np.ndarray) -> list: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file computer_vision/haralick_descriptors.py, please provide doctest for the function haralick_descriptors
| ] | ||
|
|
||
|
|
||
| def get_descriptors(masks: tuple[np.ndarray, np.ndarray], coordinate) -> np.ndarray: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file computer_vision/haralick_descriptors.py, please provide doctest for the function get_descriptors
Please provide type hint for the parameter: coordinate
| return np.sqrt(np.sum(np.square(point_1 - point_2))) | ||
|
|
||
|
|
||
| def get_distances(descriptors, base) -> list[Any]: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file computer_vision/haralick_descriptors.py, please provide doctest for the function get_distances
Please provide type hint for the parameter: descriptors
Please provide type hint for the parameter: base
| return sorted(enumerate(distances), key=lambda tup: tup[1]) | ||
|
|
||
|
|
||
| def main(): |
There was a problem hiding this comment.
Please provide return type hint for the function: main. If the function does not return a value, please provide the type hint as: def function() -> None:
As there is no test file in this pull request nor any test function or class in the file computer_vision/haralick_descriptors.py, please provide doctest for the function main
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| return sorted(enumerate(distances), key=lambda tup: tup[1]) | ||
|
|
||
|
|
||
| def main(): |
There was a problem hiding this comment.
Please provide return type hint for the function: main. If the function does not return a value, please provide the type hint as: def function() -> None:
As there is no test file in this pull request nor any test function or class in the file computer_vision/haralick_descriptors.py, please provide doctest for the function main
|
Does the main require a doctest as well? gezz... |
for more information, see https://pre-commit.ci
|
@cclauss Awaiting review 😁 |
|
@cclauss Any insights yet? |
| @@ -1,5 +1,6 @@ | |||
| beautifulsoup4 | |||
| fake_useragent | |||
| imageio | |||
There was a problem hiding this comment.
Depending on how you plan to use ImageIO, I'd recommend using imageio<3.0 or imageio<4.0 instead. We will release v3.0 around the end of January which will remove deprecations. Pinning up to the next version major avoids your code breaking once that happens and puts you in charge of when/how to upgrade.
There was a problem hiding this comment.
We are a bit different than most repos. In general, we do not pin dependencies because we are not shipping an executable (app or library) and our individual algorithms are almost always self-standing. We hope that tests catch incompatibilities so that they can be fixed as they break. If not then users can report failures so we fix-as-we-go.
No! What if the Kernel is empty?
Example:
>>> kernel = np.zeros((1))
>>> kernel or np.ones((3, 3))
array([[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]])
Co-authored-by: Christian Clauss <cclauss@me.com>
|
Please rebase on the current master |
|
Awaiting merge :) |
| array([[158, 97], | ||
| [ 56, 200]], dtype=uint8) | ||
| """ | ||
| return np.dot(image[:, :, 0:3], [0.299, 0.587, 0.114]).astype(np.uint8) |
There was a problem hiding this comment.
Can you include a source (e.g., Wikipedia) for those luminance weight values?
| def transform(image: np.ndarray, kind: str, kernel: np.ndarray = None) -> np.ndarray: | ||
| """ | ||
| Simple image transformation using one of two available filter functions: | ||
| Erosion and Dilation. |
There was a problem hiding this comment.
We already have digital_image_processing/morphological_operations/erosion_operation.py and digital_image_processing/morphological_operations/dilation_operation.py. Can we use those two files to replace this function in the future?
| index = int(input()) | ||
| q_value = [int(value) for value in input().split()] | ||
|
|
||
| # Format is the respective filter to apply, | ||
| # can be either 1 for the opening filter or else for the closing | ||
| parameters = {"format": int(input()), "threshold": int(input())} | ||
|
|
||
| # Number of images to perform methods on | ||
| b_number = int(input()) | ||
|
|
||
| files, descriptors = ([], []) | ||
|
|
||
| for _ in range(b_number): | ||
| file = input().rstrip() |
There was a problem hiding this comment.
Can we have prompt messages for each of the input calls
tianyizheng02
left a comment
There was a problem hiding this comment.
There are still some minor issues, but the major ones have been addressed.
Describe your change:
I've added a series of methods for calculating the Haralick descriptors, as well as some encapsulating methods for comparing textures between a baseline image and a sequence of comparison images.
Checklist:
Fixes: #{$ISSUE_NO}.