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

remove max_val param from threshold.texture() #1219

Merged
merged 2 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions docs/texture_threshold.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Creates a binary image from a grayscale image using [skimage](http://scikit-imag
texture calculation for thresholding.


**plantcv.threshold.texture**(*gray_img, ksize, threshold, offset=3, texture_method='dissimilarity', borders='nearest', max_value=255*)
**plantcv.threshold.texture**(*gray_img, ksize, threshold, offset=3, texture_method='dissimilarity', borders='nearest'*)

**returns** thresholded/binary image

Expand All @@ -17,7 +17,6 @@ texture calculation for thresholding.
‘contrast’, ‘dissimilarity’ (default), ‘homogeneity’, ‘ASM’, ‘energy’,
or ‘correlation’. For equations of different features see [this link](http://scikit-image.org/docs/dev/api/skimage.feature.html#greycoprops)
- borders - How the array borders are handled, either ‘reflect’, ‘constant’, ‘nearest’ (default), ‘mirror’, or ‘wrap’
- max_value - Value to apply above threshold (usually 255 = white)
- **Context:**
- Used to threshold based on texture
- **Note:**
Expand All @@ -40,8 +39,7 @@ pcv.params.debug = "plot"

# Create binary image from a gray image based on texture values.
texture_img = pcv.threshold.texture(gray_img, ksize=6, threshold=7, offset=3,
texture_method='dissimilarity', borders='nearest',
max_value=255)
texture_method='dissimilarity', borders='nearest')

```

Expand Down
7 changes: 4 additions & 3 deletions docs/updating.md
Original file line number Diff line number Diff line change
Expand Up @@ -1057,12 +1057,13 @@ pages for more details on the input and output variable types.
#### plantcv.threshold.saturation

* pre v3.8: NA
* post v3.8: bin_img = **plantcv.threshold.saturation**(*rgb_img, threshold=255, channel="any")
* post v3.8: bin_img = **plantcv.threshold.saturation**(*rgb_img, threshold=255, channel="any"*)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

noticed this missing *


#### plantcv.threshold.texture_filter
#### plantcv.threshold.texture
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the texture function name was mismatched here. I took a look at the git history and it looks like it's always been mismatched, so i changed it here. happy to adjust if needed


* pre v3.0: NA
* post v3.0: bin_img = **plantcv.threshold.texture_filter**(*gray_img, ksize, threshold, offset=3, texture_method='dissimilarity', borders='nearest', max_value=255*)
* post v3.0: bin_img = **plantcv.threshold.texture**(*gray_img, ksize, threshold, offset=3, texture_method='dissimilarity', borders='nearest', max_value=255*)
* post v4.0: bin_img = **plantcv.threshold.texture**(*gray_img, ksize, threshold, offset=3, texture_method='dissimilarity', borders='nearest'*)

#### plantcv.threshold.triangle

Expand Down
5 changes: 1 addition & 4 deletions plantcv/plantcv/threshold/threshold_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@ def triangle(gray_img, object_type="light", xstep=1):
return bin_img


def texture(gray_img, ksize, threshold, offset=3, texture_method='dissimilarity', borders='nearest',
max_value=255):
def texture(gray_img, ksize, threshold, offset=3, texture_method='dissimilarity', borders='nearest'):
"""Creates a binary image from a grayscale image using skimage texture calculation for thresholding.
This function is quite slow.

Expand All @@ -302,7 +301,6 @@ def texture(gray_img, ksize, threshold, offset=3, texture_method='dissimilarity'
scikit-image.
borders = How the array borders are handled, either 'reflect',
'constant', 'nearest', 'mirror', or 'wrap'
max_value = Value to apply above threshold (usually 255 = white)

Returns:
bin_img = Thresholded, binary image
Expand All @@ -313,7 +311,6 @@ def texture(gray_img, ksize, threshold, offset=3, texture_method='dissimilarity'
:param offset: int
:param texture_method: str
:param borders: str
:param max_value: int
:return bin_img: numpy.ndarray
"""
# Function that calculates the texture of a kernel
Expand Down
3 changes: 1 addition & 2 deletions tests/plantcv/threshold/test_threshold_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ def test_texture(threshold_test_data):
gray_img = cv2.imread(threshold_test_data.small_gray_img, -1)
# Subset input data
gray_img = gray_img[150:200, 200:250]
binary_img = texture(gray_img, ksize=6, threshold=7, offset=3, texture_method='dissimilarity', borders='nearest',
max_value=255)
binary_img = texture(gray_img, ksize=6, threshold=7, offset=3, texture_method='dissimilarity', borders='nearest')
# Assert that the output image has the dimensions of the input image and is binary
assert gray_img.shape == binary_img.shape and np.array_equal(np.unique(binary_img), np.array([0, 255]))

Expand Down