ring_borders

This module’s scope is the detection and mapping of borders in a wrapped phase map.

Example:

>>> import tuna
>>> raw = tuna.io.read ( "tuna/test/unit/unit_io/adhoc.ad3" )
>>> barycenter = tuna.plugins.run ( "Barycenter algorithm" ) ( data_can = raw )
>>> noise = tuna.plugins.run ( "Noise detector" ) ( data = raw,                                                         wrapped = barycenter,                                                         noise_mask_radius = 1,                                                         noise_threshold = 1 )
>>> rings = tuna.plugins.run ( "Ring center finder" ) ( data = raw.array,                                                             min_rings = 2 )
>>> borders = tuna.tools.phase_map.ring_border_detector ( barycenter, ( 219, 255 ), noise, rings ); borders.join ( )
>>> borders.distances.array [ 0 ] [ 170 : 190 ]
array([   0.        ,    0.        ,    0.        ,    0.        ,
          0.        ,    0.        ,    0.        ,    0.        ,
          0.        ,    0.        ,    0.        ,    0.        ,
        231.82699114,  231.82699114,  231.82699114,    0.        ,
          0.        ,    0.        ,    0.        ,    0.        ])
class tuna.tools.phase_map.ring_borders.ring_border_detector(data, center, noise, rings, log_level=20)[source]

This class is responsible for detecting the “borders” of the rings contained in a interferogram.

It inherits from the threading.Thread class, and it auto-starts its thread execution. Clients are expected to use its .join ( ) method before using its results.

Its constructor has the following signature:

Parameters:

  • data : numpy.ndarray

    Containing the wrapped phase map.

  • center : tuple of 2 integers

    Which correspond to the pixel center of the interferograph.

  • noise : can

    Containing the noise map for data.

  • rings : dictionary

    Such as the one produced by spectral_rings_fitter or equivalent.

  • log_level : valid logging level : logging.INFO

    Will set the log output to the specified level.

generate_borders_map_from_wrapped()[source]

The directional gradients from the wrapped phase map will have low values everywhere, except at the transition from 0 to max channel, indicative of an order change. This method will detect that and mark the border pixels with a one, and zero everywhere else.

map_distances_onto_borders()[source]

This method will map the pixels belonging to the border with the value of the radius of its nearest ring. Essentially, the objective is to have every pixel that belongs to a certain “border” to have the same non-zero value, and for different ring borders to have different values.

run()[source]

Method required by threading, which allows parallel exection in a separate thread.

First, this tool will aggregate all circles contained in the input rings dictionary. Then, it will map the distances from each pixel in the borders to the center of the rings structure. This is saved as the distances numpy.ndarray.