API reference
Backends and transfers
ParticleHolography.AbstractBackend — Type
Abstract execution backend used by ParticleHolography plans.
ParticleHolography.CPUBackend — Type
CPU execution through ordinary Julia arrays and FFTW.
ParticleHolography.backend — Function
backend()Return the process-wide default backend. A new Julia process starts with CPU. Call backend(:cpu), backend(:cuda), or backend(:metal) to change it. Explicit backend arguments remain available for side-by-side comparisons.
backend(kind; device=nothing)Select and return the process-wide default execution backend. kind is :cpu, :cuda, :metal, or :auto. Subsequent calls that omit a backend use this selection. :auto prefers CUDA, then Metal, and always falls back to CPU.
Changing the default while concurrent tasks are running is unsupported. Pass an explicit backend object to each call when CPU and GPU work must coexist.
ParticleHolography.available_backends — Function
Return the symbols of backends usable in the current process.
ParticleHolography.to_backend — Function
Copy x to b. An input already on b may be returned without copying.
Copy x to the currently selected backend().
ParticleHolography.to_host — Function
Copy an array or wrapped optical value to host memory.
ParticleHolography.synchronize_backend — Function
synchronize_backend(backend)Wait for queued work on an execution backend. Use this before timing GPU work. The longer name avoids collisions with functions exported by CUDA.jl/Metal.jl.
ParticleHolography.PropagationGrid — Type
Distance-independent spatial-frequency grid for angular-spectrum propagation.
ParticleHolography.PropagationKernel — Type
Distance-dependent angular-spectrum multiplier in FFT-native order.
ParticleHolography.Wavefront — Type
Complex optical wavefront on any supported execution backend.
ParticleHolography.LowPassFilter — Type
Frequency-domain low-pass filter stored in FFT-native order.
ParticleHolography.propagation_grid — Function
propagation_grid([backend], shape, wavelength, pixel_pitch)Construct the distance-independent spatial-frequency grid used by the angular-spectrum method. shape may be a square side length or (height, width). All length parameters must use the same unit.
ParticleHolography.propagation_kernel — Function
propagation_kernel([backend], distance, wavelength, grid)Construct the angular-spectrum propagation multiplier for distance. The kernel is stored in the order consumed directly by plan_fft.
ParticleHolography.gabor_wavefront — Function
Create a complex Gabor wavefront from a non-negative intensity image.
ParticleHolography.pad2d — Function
pad2d(input[, target_shape]; mode=:mean)Centre input in a larger 2-D array. The default target is twice each input dimension. mode=:mean fills the border with the input mean; mode=:zero uses zero. The result stays on the input backend.
Plans and reconstruction
ParticleHolography.PhaseRetrievalPlan — Type
Reusable Gerchberg-Saxton workspace for a pair of holograms.
ParticleHolography.phase_retrieval! — Function
phase_retrieval!(plan, hologram1, hologram2; iterations=10)Run Gerchberg-Saxton phase retrieval using buffers owned by plan. The returned Wavefront aliases the plan workspace and is overwritten by the next call. Use phase_retrieval when an owning copy is required.
ParticleHolography.phase_retrieval — Function
Run phase retrieval with plan and return an owning wavefront copy.
ParticleHolography.ReconstructionRequest — Type
ReconstructionRequest(slices; volume=Float32, min_projection=nothing)Describe the outputs to produce during one depth scan. Real-valued volume types store intensity, complex types store the propagated wavefront, and nothing avoids allocating that output. volume accepts N0f8, Float32, ComplexF32, ComplexF64, or nothing; min_projection accepts N0f8, Float32, or nothing.
ParticleHolography.ReconstructionResult — Type
Outputs generated together by one reconstruction depth scan.
ParticleHolography.MemoryDiagnostic — Type
Conservative memory estimate for a reconstruction plan and output request. required_bytes is the new allocation covered by scope; safe is missing when the backend cannot report available memory.
ParticleHolography.memory_diagnostic — Function
memory_diagnostic(backend, working_shape, request;
output_shape=working_shape, include_plan=true,
safety_factor=1.2)Estimate new plan, output, and conversion allocations before reconstruction. The estimate is conservative because FFT libraries do not expose every internal allocation. Metal reports unified host/device memory.
Return a conservative memory estimate for an existing phase-retrieval plan.
ParticleHolography.ReconstructionPlan — Type
Reusable FFT plans and buffers for a uniformly-spaced reconstruction volume.
ParticleHolography.reconstruct! — Function
Reconstruct intensity into a preallocated (height, width, slices) array.
ParticleHolography.reconstruct — Function
reconstruct(plan, wavefront, request)Generate the requested volume and MinIP in one propagation pass. Access the outputs as result.volume and result.min_projection; an unrequested output is nothing. Set check_memory=false only when the conservative preflight should not stop allocation.
Allocate and return a reconstructed intensity volume using a reusable plan.
ParticleHolography.reconstruct_padded — Function
reconstruct_padded(plan, wavefront[, request]; mode=:mean)Pad wavefront to the plan shape and reconstruct only the original central field of view. The propagation uses the padded plane, but no padded 3-D output volume is allocated.
ParticleHolography.reconstruct_complex! — Function
Reconstruct complex amplitude into a preallocated volume.
ParticleHolography.reconstruct_complex — Function
Allocate and return the complex-amplitude reconstruction volume.
ParticleHolography.xyprojection! — Function
Compute the minimum-intensity projection along reconstruction depth.
ParticleHolography.xyprojection — Function
Allocate and return the minimum-intensity projection over reconstruction depth.
ParticleHolography.reconstruct_and_projection! — Function
Fill preallocated intensity volume and minimum-intensity projection.
ParticleHolography.reconstruct_and_projection — Function
Allocate and return both an intensity volume and its depth projection.
ParticleHolography.asm_propagate! — Function
Propagate input into the preallocated output wavefront.
ParticleHolography.asm_propagate — Function
Allocate a wavefront and propagate input by one angular-spectrum step.
Deprecated migration aliases
TransferSqrtPart, Transfer, transfer_sqrt, and transfer are retained as deprecated aliases or wrappers for source migration. New code should use PropagationGrid, PropagationKernel, propagation_grid, and propagation_kernel.
Filters, detection, calibration, and tracking
ParticleHolography.Labonte — Method
v0.2 keyword-compatible spelling of labonte.
ParticleHolography.append_path! — Method
Append one correspondence graph to an existing set of paths, preserving branches.
ParticleHolography.apply_low_pass_filter! — Method
Apply an FFT-native low-pass filter in place to a wavefront.
ParticleHolography.asm_propagate! — Method
Propagate input into the preallocated output wavefront.
ParticleHolography.asm_propagate — Method
Allocate a wavefront and propagate input by one angular-spectrum step.
ParticleHolography.available_backends — Method
Return the symbols of backends usable in the current process.
ParticleHolography.backend — Method
backend(kind; device=nothing)Select and return the process-wide default execution backend. kind is :cpu, :cuda, :metal, or :auto. Subsequent calls that omit a backend use this selection. :auto prefers CUDA, then Metal, and always falls back to CPU.
Changing the default while concurrent tasks are running is unsupported. Pass an explicit backend object to each call when CPU and GPU work must coexist.
ParticleHolography.backend — Method
backend()Return the process-wide default backend. A new Julia process starts with CPU. Call backend(:cpu), backend(:cuda), or backend(:metal) to change it. Explicit backend arguments remain available for side-by-side comparisons.
ParticleHolography.connected_component_labeling — Method
connected_component_labeling(image)Label non-zero pixels using 8-way connectivity. The reference implementation runs on the host and returns consecutive UInt32 labels with zero reserved for the background. Device inputs are copied one image at a time.
ParticleHolography.count_labels — Method
Count non-background connected-component labels.
ParticleHolography.dictload — Method
dictload(filename)Load a particle dictionary from a file in JSON format. The dictionary should have UUID keys and values as Vector{Float32}, which includes the coordinates (and diameters) of the particles.
Arguments
filename::String: The path to the file.
Returns
Dict: The loaded dictionary.
ParticleHolography.dictsave — Method
dictsave(filename, dict)Save a particle dictionary to a file in JSON format. The dictionary should have UUID keys and values as Vector{Float32}, which includes the coordinates (and diameters) of the particles.
Arguments
filename::String: The path to the file.dict::Dict: The dictionary to save.
Returns
nothing
ParticleHolography.dilate — Method
dilate(volume)Dilate each XY slice with a 3×3 neighbourhood. The operation stays on the input array's backend and preserves the v0.2 convention that boundary pixels remain false.
ParticleHolography.finalize_particle_neighborhoods! — Method
Remove duplicate, one-slice, highly elongated, and area-smaller-than-10 boxes.
ParticleHolography.find_external_contours — Method
find_external_contours(image)Finds non-hole contours in binary images. This function is excuted on the CPU. Equivalent to CVRETREXTERNAL and CVCHAINAPPROX_NONE modes of the findContours() function provided in OpenCV.
Arguments
image: The binary image. the image should be a 2D array of 0 and 1.
Returns
Vector{Vector{CartesianIndex}}: A vector of contours. Each contour is a vector of CartesianIndex.
ParticleHolography.find_valid_labels — Method
Return sorted, non-zero connected-component labels.
ParticleHolography.gabor_wavefront — Method
Create a complex Gabor wavefront from a non-negative intensity image.
ParticleHolography.get_distortion_coefficients — Method
Estimate the 12 quadratic distortion coefficients from a stereo image pair.
ParticleHolography.isfunctional — Method
Return whether a backend is usable in the current Julia process.
ParticleHolography.labonte — Method
labonte(frame1, frame2; kwargs...)Apply the improved Labonté particle-correspondence algorithm to two frames. Input dictionaries are never mutated.
ParticleHolography.load_gray2float — Method
load_gray2float(path)Load a grayscale image from a file and return it as a Array{Float32, 2} array.
Arguments
path::String: The path to the image file.
Returns
Array{Float32, 2}: The image as a Float32 array.
ParticleHolography.load_grayimg — Method
load_grayimg(path)Load a grayscale image from a file and return it as a Array{Gray{N0f8}, 2} array.
Arguments
path::String: The path to the image file.
Returns
Array{Gray{N0f8}, 2}: The image as a Gray{N0f8} array.
ParticleHolography.make_background — Method
make_background(pathlist; mode=:mode)Make a background image from a list of image paths. The background image is calculated by taking the mean or mode of the images in the list. The default mode is :mode.
Arguments
pathlist::Vector{String}: A list of image paths.glob()can be used to generate this list.mode::Symbol: The mode to use for calculating the background. Options are :mean or :mode. Default is :mode.
Returns
Array{Float64, 2}: The background image.
ParticleHolography.make_background_mode — Method
make_background_mode(images; backend=backend())Compute the per-pixel 8-bit mode without allocating the former 256 × height × width vote volume. GPU inputs are staged to the host once; this preprocessing step deliberately favours bounded memory over acceleration.
ParticleHolography.memory_diagnostic — Function
memory_diagnostic(backend, working_shape, request;
output_shape=working_shape, include_plan=true,
safety_factor=1.2)Estimate new plan, output, and conversion allocations before reconstruction. The estimate is conservative because FFT libraries do not expose every internal allocation. Metal reports unified host/device memory.
ParticleHolography.memory_diagnostic — Method
Return a conservative memory estimate for an existing phase-retrieval plan.
ParticleHolography.node_distance — Function
Euclidean particle distance with a configurable optical-axis weight.
ParticleHolography.pad2d — Function
pad2d(input[, target_shape]; mode=:mean)Centre input in a larger 2-D array. The default target is twice each input dimension. mode=:mean fills the border with the input mean; mode=:zero uses zero. The result stays on the input backend.
ParticleHolography.particle_bounding_boxes — Method
particle_bounding_boxes(binary_volume)Connect slice components whenever their inclusive XY bounding boxes overlap. This keeps the original non-adjacent-z behaviour used to join fragmented holographic particle signatures.
ParticleHolography.particle_bounding_boxes_3d — Method
Variant that joins a component only to a component in the preceding slice.
ParticleHolography.particle_coor_diams — Method
Calculate [x, y, z, equivalent_diameter] for each particle box.
ParticleHolography.particle_coordinates — Method
Calculate [x, y, z] coordinates for detected particle bounding boxes.
ParticleHolography.phase_retrieval! — Method
phase_retrieval!(plan, hologram1, hologram2; iterations=10)Run Gerchberg-Saxton phase retrieval using buffers owned by plan. The returned Wavefront aliases the plan workspace and is overwritten by the next call. Use phase_retrieval when an owning copy is required.
ParticleHolography.phase_retrieval — Method
Run phase retrieval with plan and return an owning wavefront copy.
ParticleHolography.piv_map — Method
piv_map(backend, image1, image2; grid_size=128, interrogation_size=128, search_size=256)Compute the same brute-force normalized-cross-correlation PIV map used in v0.2. CPU is the portable reference; CUDA.jl supplies the accelerated method. Metal currently uses the documented CPU fallback for this calibration step.
ParticleHolography.propagation_grid — Method
propagation_grid([backend], shape, wavelength, pixel_pitch)Construct the distance-independent spatial-frequency grid used by the angular-spectrum method. shape may be a square side length or (height, width). All length parameters must use the same unit.
ParticleHolography.propagation_kernel — Method
propagation_kernel([backend], distance, wavelength, grid)Construct the angular-spectrum propagation multiplier for distance. The kernel is stored in the order consumed directly by plan_fft.
ParticleHolography.quadratic_distortion_correction — Method
Apply the package's 12-coefficient quadratic camera-distortion mapping.
ParticleHolography.reconstruct! — Method
Reconstruct intensity into a preallocated (height, width, slices) array.
ParticleHolography.reconstruct — Method
Allocate and return a reconstructed intensity volume using a reusable plan.
ParticleHolography.reconstruct — Method
reconstruct(plan, wavefront, request)Generate the requested volume and MinIP in one propagation pass. Access the outputs as result.volume and result.min_projection; an unrequested output is nothing. Set check_memory=false only when the conservative preflight should not stop allocation.
ParticleHolography.reconstruct_and_projection! — Method
Fill preallocated intensity volume and minimum-intensity projection.
ParticleHolography.reconstruct_and_projection — Method
Allocate and return both an intensity volume and its depth projection.
ParticleHolography.reconstruct_complex! — Method
Reconstruct complex amplitude into a preallocated volume.
ParticleHolography.reconstruct_complex — Method
Allocate and return the complex-amplitude reconstruction volume.
ParticleHolography.reconstruct_padded — Function
reconstruct_padded(plan, wavefront[, request]; mode=:mean)Pad wavefront to the plan shape and reconstruct only the original central field of view. The propagation uses the padded plane, but no padded 3-D output volume is allocated.
ParticleHolography.rectangle_filter — Method
Construct the rectangular angular-spectrum low-pass filter from Fugal (2009).
ParticleHolography.super_gaussian_filter — Method
Construct the sixth-order super-Gaussian low-pass filter from Fugal (2009).
ParticleHolography.synchronize — Method
Wait for queued work on b to complete.
ParticleHolography.synchronize_backend — Method
synchronize_backend(backend)Wait for queued work on an execution backend. Use this before timing GPU work. The longer name avoids collisions with functions exported by CUDA.jl/Metal.jl.
ParticleHolography.tamura — Method
Tamura focus coefficient (std / mean) with a stable all-zero case.
ParticleHolography.to_backend — Method
Copy x to b. An input already on b may be returned without copying.
ParticleHolography.to_backend — Method
Copy x to the currently selected backend().
ParticleHolography.to_host — Method
Copy an array or wrapped optical value to host memory.
ParticleHolography.update_particle_neighborhoods! — Method
Merge a slice's rectangles into all prior XY-overlapping neighborhoods.
ParticleHolography.update_particle_neighborhoods3d! — Method
Merge rectangles only with neighborhoods present in the immediately prior slice.
ParticleHolography.xyprojection! — Method
Compute the minimum-intensity projection along reconstruction depth.
ParticleHolography.xyprojection — Method
Allocate and return the minimum-intensity projection over reconstruction depth.
Index
ParticleHolography.AbstractBackendParticleHolography.CPUBackendParticleHolography.LowPassFilterParticleHolography.MemoryDiagnosticParticleHolography.PhaseRetrievalPlanParticleHolography.PropagationGridParticleHolography.PropagationKernelParticleHolography.ReconstructionPlanParticleHolography.ReconstructionRequestParticleHolography.ReconstructionResultParticleHolography.WavefrontParticleHolography.LabonteParticleHolography.append_path!ParticleHolography.apply_low_pass_filter!ParticleHolography.asm_propagateParticleHolography.asm_propagateParticleHolography.asm_propagate!ParticleHolography.asm_propagate!ParticleHolography.available_backendsParticleHolography.available_backendsParticleHolography.backendParticleHolography.backendParticleHolography.backendParticleHolography.connected_component_labelingParticleHolography.count_labelsParticleHolography.dictloadParticleHolography.dictsaveParticleHolography.dilateParticleHolography.finalize_particle_neighborhoods!ParticleHolography.find_external_contoursParticleHolography.find_valid_labelsParticleHolography.gabor_wavefrontParticleHolography.gabor_wavefrontParticleHolography.get_distortion_coefficientsParticleHolography.isfunctionalParticleHolography.labonteParticleHolography.load_gray2floatParticleHolography.load_grayimgParticleHolography.make_backgroundParticleHolography.make_background_modeParticleHolography.memory_diagnosticParticleHolography.memory_diagnosticParticleHolography.memory_diagnosticParticleHolography.node_distanceParticleHolography.pad2dParticleHolography.pad2dParticleHolography.particle_bounding_boxesParticleHolography.particle_bounding_boxes_3dParticleHolography.particle_coor_diamsParticleHolography.particle_coordinatesParticleHolography.phase_retrievalParticleHolography.phase_retrievalParticleHolography.phase_retrieval!ParticleHolography.phase_retrieval!ParticleHolography.piv_mapParticleHolography.propagation_gridParticleHolography.propagation_gridParticleHolography.propagation_kernelParticleHolography.propagation_kernelParticleHolography.quadratic_distortion_correctionParticleHolography.reconstructParticleHolography.reconstructParticleHolography.reconstructParticleHolography.reconstruct!ParticleHolography.reconstruct!ParticleHolography.reconstruct_and_projectionParticleHolography.reconstruct_and_projectionParticleHolography.reconstruct_and_projection!ParticleHolography.reconstruct_and_projection!ParticleHolography.reconstruct_complexParticleHolography.reconstruct_complexParticleHolography.reconstruct_complex!ParticleHolography.reconstruct_complex!ParticleHolography.reconstruct_paddedParticleHolography.reconstruct_paddedParticleHolography.rectangle_filterParticleHolography.super_gaussian_filterParticleHolography.synchronizeParticleHolography.synchronize_backendParticleHolography.synchronize_backendParticleHolography.tamuraParticleHolography.to_backendParticleHolography.to_backendParticleHolography.to_backendParticleHolography.to_hostParticleHolography.to_hostParticleHolography.update_particle_neighborhoods!ParticleHolography.update_particle_neighborhoods3d!ParticleHolography.xyprojectionParticleHolography.xyprojectionParticleHolography.xyprojection!ParticleHolography.xyprojection!