Skip to main content

ISO 11146 Calculation of Laser Beam Center and Diameter

Project description

Simple and fast calculation of beam sizes from a single monochrome image based on the ISO 11146 method of variances. Some effort has been made to make the algorithm less sensitive to background offset and noise.

Installation

Just use pip:

pip install laserbeamsize

Usage

Finding the center and dimensions of a good beam image:

import imageio
import numpy as np
import laserbeamsize as lbs

beam = imageio.imread("t-hene.pgm")
x, y, dx, dy, phi = lbs.beam_size(beam)

print("The center of the beam ellipse is at (%.0f, %.0f)" % (x,y))
print("The ellipse diameter (closest to horizontal) is %.0f pixels" % dx)
print("The ellipse diameter (closest to   vertical) is %.0f pixels" % dy)
print("The ellipse is rotated %.0f° ccw from the horizontal" % (phi*180/3.1416))

ellipticity = dy/dx
if ellipticity>0.87:
    print()
    print("The beam is circular because the ellipticity=%.2f > 0.87")
    print("The circular beam diameter is %.0f pixels" % np.sqrt((dx**2+dy**2)/2))

Alternatively, one can get a quick visual report:

lbs.visual_report(beam)
plt.show()

Which will show something like

hene-report.png

Documentation about backgrounds, integrations, and other issues are explained at <https://laserbeamsize.readthedocs.io>

License

laserbeamsize is licensed under the terms of the MIT license.

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

laserbeamsize-1.2.0.tar.gz (225.8 kB view details)

Uploaded Source

File details

Details for the file laserbeamsize-1.2.0.tar.gz.

File metadata

  • Download URL: laserbeamsize-1.2.0.tar.gz
  • Upload date:
  • Size: 225.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1.post20200515 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

File hashes

Hashes for laserbeamsize-1.2.0.tar.gz
Algorithm Hash digest
SHA256 9682f2b071ca0d0940d8e2fc6566af49f26a0a40b91d7377ab192e1795c878a4
MD5 f4bd152be3b5690977c23f2bfb927080
BLAKE2b-256 9ecb155c6c932ea2f241a333ff9d935337d17cf2ee43660bb27435341f888b90

See more details on using hashes here.

Supported by

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