Skip to main content

Phase shifting algorithms for encoding and decoding sinusoidal fringe patterns.

Project description

Fringes

coding-cheme

PyPI Ruff tests Read the Docs PyPI - License Static Badge

Easily configure, encode and decode sinusoidal fringe patterns using phase shifting algorithms.

Features

Installation

You can install fringes directly from PyPi via pip:

pip install fringes

Usage

You instantiate, parameterize and deploy the Fringes class:

from fringes import Fringes  # import the Fringes class

f = Fringes()                # instantiate Fringes object

All parameters are accessible as class properties (managed attributes) of the Fringes instance.

f.X = 1920                   # set width of the fringe patterns
f.Y = 1080                   # set height of the fringe patterns
f.N = 4                      # set number of shifts
f.v = [9, 10]                # set spatial frequencies

print(f.T)                   # get number of frames

To encode the fringe pattern sequence I, use the method encode(). It returns a NumPy array in video-shape (frames, height, width, color channels).

I = f.encode()               # encode fringe patterns

Now display each frame of the fringe pattern sequence on a screen and capture the scene with a camera according to the following pseudocode (a minimal working example is depicted here):

# allocate image stack
Irec = []

for t in range(f.T):
    # display frame of pattern sequence on screen
    frame = I[t]
    ...

    # capture scene with camera
    image = ...
    
    # append to image stack
    Irec.append(image)

To decode (recorded) fringe patterns, use the method decode(). It returns the Numpy arrays brightness a, modulation b and (screen) coordinate x.

a, b, x = f.decode(Irec)     # decode fringe patterns

Note:
For the computationally expensive decode()-function we make use of the just-in-time compiler Numba. During the first execution, an initial compilation is executed. This can take several tens of seconds up to single digit minutes, depending on your CPU and energy settings. However, for any subsequent execution, the compiled code is cached and the code of the function runs much faster, approaching the speeds of code written in C.

More complete code examples can be found in the examples directory.

Support

I was looking for a user-friendly tool for phase shifting. Since I couldn't find any, I started developing one myself. It is intended for non-commercial, academic and educational use.

However, I do this entirely in my free time. If you like this package and can make use of it, I would be happy about a donation. It will help me keep it up-to-date and add more features in the future.

paypal

Thank you!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fringes-2.1.0.tar.gz (67.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fringes-2.1.0-py3-none-any.whl (63.2 kB view details)

Uploaded Python 3

File details

Details for the file fringes-2.1.0.tar.gz.

File metadata

  • Download URL: fringes-2.1.0.tar.gz
  • Upload date:
  • Size: 67.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fringes-2.1.0.tar.gz
Algorithm Hash digest
SHA256 6adb304f8ac6d2a4f7fac02c85c8bf26283ea7a97402e9289777a57657e614d8
MD5 3f3aab1ea0e51cf83a8593365a5ace83
BLAKE2b-256 f72b037b07c772c4f93eabc4e3b01bb7a89b282056963e3b301c98775beed2f7

See more details on using hashes here.

File details

Details for the file fringes-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: fringes-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 63.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fringes-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e0cb1ecd21afa920275a167fab6d4e9458d8ff79c1172bc27868c5a953c3f6d
MD5 ec96e0343ac0debf341bcb134a590281
BLAKE2b-256 9f7d17e0139c8b5a71b8d4a9e50939114606d3d5e1ea6698432c0b6e77aa619c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page