-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Warning in local binary pattern if image dtype is not integer #2563
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2563 +/- ##
==========================================
- Coverage 90.53% 90.53% -0.01%
==========================================
Files 304 304
Lines 21706 21709 +3
Branches 1872 1873 +1
==========================================
+ Hits 19652 19654 +2
Misses 1714 1714
- Partials 340 341 +1
Continue to review full report at Codecov.
|
skimage/feature/texture.py
Outdated
@@ -307,6 +309,12 @@ def local_binary_pattern(image, P, R, method='default'): | |||
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.214.6851, | |||
2004. | |||
""" | |||
match_datatype = re.search('int', str(image.dtype)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anshitag take a look at this awesome feature of numpy:
In [3]: z = np.array([3])
In [4]: z.dtype
Out[4]: dtype('int64')
In [5]: z.dtype.kind
Out[5]: 'i'
In [6]: z = np.array([3.1])
In [7]: z.dtype.kind
Out[7]: 'f'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@soupault thanks for the input! I just have some doubts regarding the change.
I tried running this code for an image from skimage data of dtype uint8, and got the following result:
In [30]: from skimage import data
image = data.load('brick.png')
In [31]: image.dtype
Out[31]: dtype('uint8')
In [32]: image.dtype.kind
Out[32]: 'u'
This image has been used in the example for LBP here.
Since there are only two outcomes for image.dtype.kind
for integer numpy arrays i.e. i
if signed integer and u
if unsigned integer, should I directly check these characters (not use re)?
|
||
if image.dtype.kind not in ('i', 'u'): | ||
warn('Image data type incorrect. Convert the image to integer type for' | ||
' local_binary_pattern') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
' local_binary_pattern') | |
' local_binary_pattern', stacklevel=2) |
@@ -307,6 +308,11 @@ def local_binary_pattern(image, P, R, method='default'): | |||
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.214.6851, | |||
2004. | |||
""" | |||
|
|||
if image.dtype.kind not in ('i', 'u'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's only 'u'
since positive integers are required.
I was browsing through old PRs, this one seems easy enough to merge soon. |
Hey everyone, |
Description
Added warning to the user if they do not use integer type image with Local Binary Pattern function.
Changes made to function
local_binary_pattern
in scikit-image/skimage/feature/texture.pyFile code checked with flake8, follows PEP08.
References
Closes #2522