Boundary Extraction#
Extract the Fourier terms from a Granule
.
Boundary Extraction#
Draw the boundary around the granule
Fourier transform the boundary to get the perturbation
Group the same granule across frames
Outline#
Given a Granule
object we use a directional gradient to calculate the boundary of
the granule. From this boundary we perform a Fourier transform to extract amplitude of
each of these modes.
This analysis is performed on a granule by granule basis, we provide two functions to group the granules and aggregate the results, into a singe frame then across the frames.
When the granules are grouped across the frames we group the granules by their position in the frame, tracking the granule as it moves.
See workflow.process_image.py
for examples of how to use this module.
Provides#
- BoundaryExtractionGradient(granule:Granule):
A class for measuring the boundary of the granules.
- class flickerprint.common.boundary_extraction.BoundaryExtraction(granule: Granule, boundary_method)#
Base for the boundary extraction.
- angle_sweep(n_angles, samples_per_pixel=5, order=3)#
Measure the border of the image.
This works by sampling the image at
n_angles
evenly spaced and calculating the radius that best corresponds to the boundary. This evenly spaced nature allows us to Fourier transform the results.- Parameters:
n_angles (int) – We sample N angles evenly spaced in the range [0, 2π)
samples_per_pixel (float) – How many points are sampled per pixel during interpolation. Typically > 1.
- n_angles#
The sampling angles for the boundary
- Type:
np.ndarray
- radii#
The best estimate for the boundary values.
- Type:
np.ndarray
- static get_fourier_terms(radii)#
Perform the Fourier analysis.
- Returns:
components (np.ndarray) – The (complex) magnitudes of the boundary in Fourier space
fft_freq – The mode number of each of the Fourier terms
centre (The first fourier mode, which is required for recreating the droplet outline)
- property mean_radius_pixels#
Return the mean radius of the granule in pixel units.
This is then meant to be scaled by the physical size of the pixels in the microscope image. This is left to the user however to avoid a large pass through of variables.
- plot(ax=None, save_name: Path | None = None, im=None, dpi=None)#
Plot the detected edge of the granule.
- validate_boundary()#
Look for discontinuities in the boundary
- flickerprint.common.boundary_extraction.collect_fourier_terms(fourier_terms: Iterable[BoundaryExtraction], frame: MicroscopeFrame, granule_tracker, plot: bool = False, output_dir: Path | None = None) DataFrame #
Gather a list of Fourier terms into a single form and add metadata.
This gathers all the information from a given into a
pd.DataFrame
.