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

Unexpected behavior of skimage.feature.local_binary_pattern #2522

Closed
msbajammal opened this issue Feb 19, 2017 · 2 comments · Fixed by #6272
Closed

Unexpected behavior of skimage.feature.local_binary_pattern #2522

msbajammal opened this issue Feb 19, 2017 · 2 comments · Fixed by #6272

Comments

@msbajammal
Copy link

msbajammal commented Feb 19, 2017

Hi,
The local binary pattern method in skimage is producing unexpected results. For some flat regions, it correctly produces 255 (e.g. binary 11111111). But for some other flat regions in the same image, it produces noise (decimal 85, binary 01010101).

Here is a link with code example and images to reproduce the issue:
http://stackoverflow.com/questions/42322400/unexpected-behavior-in-local-binary-pattern-python-skimage

OS version: Mac OS X 10.9.5

python version: '3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:52:12) \n[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)]'

skimage.version: '0.12.3'

@stefanv
Copy link
Member

stefanv commented Feb 20, 2017

As mentioned on the S/O question: this is because of floating point differences. If you convert the image to ubyte first, it'll work fine. Still, I see this as a usability bug.

Do you want to file a patch that issues a warning to the user if they do not use integer types with LBPs?

@anshitag
Copy link
Contributor

anshitag commented Mar 7, 2017

@stefanv
Hi, I've tried to fix this issue. Please let me know if this is the correct approach.

Add these lines to the function local_binary_pattern in scikit-image/skimage/feature/texture.py

import re
from warnings import warn
match = re.search('int',str(image.dtype))
if not match:
      warn('Image data type incorrect. Use integer data types for local_binary_pattern')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
5 participants