Skip to main content

Phase shifting algorithms for encoding and decoding sinusoidal fringe patterns.

Project description

Fringes

coding-cheme

PyPI Code style: black 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
T = 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 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.0.0.tar.gz (66.8 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.0.0-py3-none-any.whl (62.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fringes-2.0.0.tar.gz
  • Upload date:
  • Size: 66.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for fringes-2.0.0.tar.gz
Algorithm Hash digest
SHA256 97da905606c3079b78fb3b5453b0bc7787082be1770f6b3372756c0dae59a932
MD5 f0c203d15f111a9a94e4bf784a6c2698
BLAKE2b-256 b0939fde193a61bae04a88de9e54f280684fc3a7047e36ade7589304035fce26

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fringes-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 62.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for fringes-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4c585fdf84a731b3c588ee9450be943b170743085e5feb174a96a1fb08f6c0e
MD5 5514ac0d0c87d677a8348223762cdc33
BLAKE2b-256 3dbe2167ebf161de6942fc6c8f92153d220d9c10a47a9fa687306e8064a527aa

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