Coder Social home page Coder Social logo

spe-image-handler's Introduction

SPE File Handler

Description

This file is to analyze the .SPE image. Horizontal and vertical RMS beam spot sizes will be calculated separately.

Usage

For the beam RMS size calculation, there are two methods included. Following is a brief description of how each method works. Both methods suggest a similar result.

  • Method#1

    • Crop all images. All beam images will be cropped according to the user provided parameters.
    from spe_image_rms_rms_error import *
    
    SPE_image = DenoiseSPEImage(settings.FILE_START_STRING, settings.FOLDER_PATH, settings.FILE_LIST)
    SPE_image.set_cropped_range(100, 480, 200, 500)    # x_start, x_end, y_start, y_end 
    • Generate beam contours. To outline the beam spot (or to find the ROI) of every frame, contours will be generated based on the user provided contour levels. The contour with the longest path is the beam spot contour. Beam images and the corresponding contours can be displayed using the function of draw_beam_contour().
    SPE_image.draw_beam_contour(100, 50)

    img

    • Denoise the beam image. All pixel datapoints outside the beam contour will be set to zero, an example is shown below, img
    • Calculate the background within the contour. Background will be calculated from the lowest 100 pixel values within the contour. And subtract the calculated background from the copped image file.
    • Denoise the beam image (w/o background) the second time. Use scipy.ndimage.median_filter() function.
    • Calculate the beam RMS sizes. Beam RMS sizes are calculated from the Gaussian fitting.
    x_rms, y_rms, x_std, y_std = SPE_image.get_rms_and_rms_error(contour_method=True)
  • Method#2 (a bit faster)

    • Crop all images.
    SPE_image.set_cropped_range(100, 480, 200, 500)     # x_start, x_end, y_start, y_end 
    • Calculate the background. Background will be calculated from the upper corner of the image profile. The calculated background will be subtracted from the image file.
    • Denoise the beam image (w/o background). Use scipy.ndimage.median_filter() function, an example is shown below,
    • Calculate the beam RMS sizes.
    x_rms, y_rms, x_std, y_std = SPE_image.get_rms_and_rms_error(regular_method=True)

Beam profiles can be saved to one or multiple pdf files using the function of plot_single_frame(). Note: the two Boolean arguments need to be consistent to the used method.

SPE_image.plot_single_frame(contour_method=True, regular_method=False)    # for method#1
SPE_image.plot_single_frame(contour_method=False, regular_method=True)    # for method#2

Run test.py for a simple test.

TODOs

  • Auto detect the cropping region.
  • Fix the frame labeling bug.

Credit

The enclosed winspec.py was developed by Anton Loukianov (@antonl). Please visit https://github.com/antonl/pyWinSpec for more details.

spe-image-handler's People

Contributors

gbc1858 avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.