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

Fixed skimage.feature.graycomatrix example documentation. #7297

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions skimage/feature/texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def graycomatrix(image, distances, angles, levels=None, symmetric=False, normed=

Examples
--------
Compute 2 GLCMs: One for a 1-pixel offset to the right, and one
for a 1-pixel offset upwards.
Compute 4 GLCMs at 1-pixel offset for 4 different angles. For example, 0 radians
refers to the pixel to the right and pi/2 to the pixel above.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @FedericoWZhaw! I would be a little more explicit; maybe:

Compute 4 GLCMs: The first one for a 1-pixel offset to the right (distance 1 and angle 0 rad); the second one for a 1-pixel offset to the first bisector (distance 1 and angle pi/4); etc.

or include it as comments in the code, when each GLCM is printed. Is it correct that pi/4 and 3*pi/4 correspond to the upward diagonal directions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"1-pixel offset" and "distance 1" seem somewhat redundant, I find the later more precise? "bisector" seems like a very technical term that's not used anywhere else in the docstring..?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"1-pixel offset" and "distance 1" seem somewhat redundant, I find the later more precise?

The description of the distance parameter states:
distances : array_like
List of pixel pair distance offsets.

What about:
"Compute 4 GLCMs using 1-pixel distance and 4 different angles. For example, an angle of 0 radians refers to the neighboring pixel to the right; pi/4 to the top-right diagonal neighbor (row-1,column+1); pi/2 to the pixel above, etc."

Feel free to suggest something else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you both for iterating! 😃

"1-pixel offset" and "distance 1" seem somewhat redundant

Totally, but that was on purpose, to clarify the arguments, as done in the text of the gallery example: "a 1-pixel offset to the right (distance 1 and angle 0 rad)" parallels "a horizontal offset of 5 (distance=[5] and angles=[0])."

"bisector" seems like a very technical term

I must say I'm not sure how it sound to most ears... I would assume that someone using scikit-image would have some minimal computing background and, for instance, would have already heard something like "the equation of the first bisector line is y=x" (but I'm definitely not attached to this term).

I very much like @FedericoWZhaw's suggestion (minor: I would write "0 radian" instead of "0 radians"). It's just that -- and that was my original motivation for suggesting a change -- an angle refers to a direction so, e.g., an angle of 0 refers to all pixels to the right, not only to the pixel to the right; the fact that it's the pixel to the right comes from the pair (distance=1, angle=0); same with all other angles (angle pi/2 means one of the pixels straight above, and it's the pixel right above because it's at distance 1).


>>> image = np.array([[0, 0, 1, 1],
... [0, 0, 1, 1],
Expand Down