CoolFace
Apppublic

sofia-canta/lbp-texture-explorer

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
App README

LBP Texture Explorer

Interactive Streamlit application for exploring texture analysis using Local Binary Patterns (LBP).


Project Summary

This project demonstrates how Local Binary Patterns (LBP) can be used to analyze local texture structures in images.

The application allows users to:

  • upload their own images
  • explore built-in sample textures
  • adjust LBP parameters interactively
  • compare original and LBP-transformed images
  • analyze LBP histograms
  • visualize flat, edge-like and corner-like texture regions

The app was designed as an educational tool for understanding texture analysis concepts in image processing.


Features

Input and Controls

  • Upload custom images
  • Built-in sample textures:
  • brick
  • concrete
  • gravel
  • Adjustable radius parameter
  • Adjustable number of sampled points parameter

Visualization

  • Side-by-side comparison of:
  • original image
  • LBP image
  • LBP histogram
  • Highlighted:
  • flat regions
  • edge-like regions
  • corner-like regions

Educational Content

  • Explanation of Local Binary Patterns
  • Step-by-step LBP workflow
  • Circular LBP explanation
  • Uniform vs non-uniform patterns
  • Histogram interpretation

How Local Binary Patterns Work

LBP compares the intensity of a central pixel with the intensity of its neighboring pixels and encodes the local texture pattern into a binary number.

Each neighboring pixel is assigned:

  • 1 if its intensity is greater than or equal to the center pixel
  • 0 if its intensity is lower than the center pixel

The binary values are combined into a binary code, which is converted into a decimal value representing the local texture pattern.

Repeating this process for every pixel produces the complete LBP representation of the image.


Circular LBP and Uniform Patterns

The app uses a circular LBP implementation instead of the original fixed 3×3 neighborhood.

This allows:

  • different neighborhood radii
  • different numbers of sampled points
  • texture analysis at different spatial scales

The app also uses uniform LBP patterns.

Uniform patterns contain only a small number of binary transitions and often correspond to meaningful structures such as:

  • flat regions
  • edges
  • corners

Non-uniform patterns are grouped into a single histogram bin to reduce noise and simplify interpretation.


Repository Structure

text
texture-explorer/
│
├── app.py
├── processing.py
├── metrics.py
├── utils.py
├── requirements.txt
├── README.md
│
├── sample_images/
│
├── screenshots/
│
└── docs/
    └── design_choices.md

Local Run Instructions

Clone the repository:

bash
git clone <your_repo_url>
cd texture-explorer

Install dependencies:

bash
pip install -r requirements.txt

Run the application:

bash
streamlit run app.py

Requirements

Main libraries used:

  • streamlit
  • numpy
  • matplotlib
  • pillow
  • scikit-image

Hugging Face Space URL

Add your public Hugging Face Space URL here:

https://huggingface.co/spaces/sofia-canta/lbp-texture-explorer

Screenshots / GIF

Original vs LBP Image

[image]

Original grayscale texture and corresponding LBP representation.


Histogram Visualization

LBP histogram showing the distribution of uniform and non-uniform patterns.

Brick Texture Histogram

[image]

The brick texture produces a histogram concentrated around a limited number of dominant bins, indicating the presence of repetitive and regular local texture structures such as edges and corners.

The contribution of non-uniform patterns remains relatively low because the texture contains regular and repeated spatial structures.

Gravel Texture Histogram

[image]

The gravel texture produces a more homogeneous and distributed histogram without strongly dominant patterns.

The larger junk bin indicates a higher proportion of non-uniform patterns caused by the irregular and highly variable local texture structure.

Effect of Increasing the Number of Sampling Points

[image]

Increasing the number of sampling points increases the probability of generating non-uniform patterns.

Larger neighborhoods are more likely to produce multiple transitions between 0 and 1 in the binary sequence due to the increased amount of captured local intensity variations.

Effect of Increasing Radius and Sampling Points

[image]

Increasing the radius allows the algorithm to analyze larger neighborhoods and broader texture variations.

This further increases the contribution of non-uniform patterns and enlarges the junk bin.


Flat, Edge-like, and Corner-like Pattern Detection

[image]

The highlighted histogram bins correspond to uniform LBP patterns associated with flat regions, edge-like structures, and corner-like structures.

In the brick texture, these characteristic patterns are clearly distinguishable due to the regular geometric structure of the texture.


Known Limitations

  • The current app mainly provides qualitative texture analysis based on visual inspection of the LBP image and histogram distributions.

Future improvements could include additional quantitative metrics, such as entropy-based measures describing how concentrated or distributed the histogram is, or texture complexity measures based on the proportion of non-uniform patterns.

  • The flat, edge-like, and corner-like regions are estimated using simplified groups of selected LBP values and therefore do not represent an exact texture classification.

Future improvements could include more advanced texture analysis methods or additional quantitative rules to identify local texture structures more accurately. ---

Design Notes

The application focuses on educational visualization rather than texture classification performance.

The app uses:

  • uniform Local Binary Patterns
  • circular neighborhood sampling
  • histogram-based texture interpretation

Special emphasis was placed on helping users visually understand:

  • local texture encoding
  • texture distributions
  • texture micro-patterns
  • uniform vs non-uniform texture structures