Internal Documentation
Documentation for LAP_julia.jl
's internal interface.
Functions
LAP_julia.add_figs_pflap
— Methodadd_figs_pflap(figs, level, iter_repeat, u_est, Δ_u, source_reg, level_count, max_repeats)
Fill the figs array specifically for the pflap
method.
LAP_julia.angle_mae
— Methodfunction angle_mae(x, y)
Calculate the mean absolute error in angle between x
and y
. Output in degrees.
LAP_julia.angle_rmse
— Methodfunction angle_rmse(x, y)
Calculate the root mean square error in angle between x
and y
. Output in degrees.
LAP_julia.back_substitution3d
— Methodback_substitution3d(A, b)
Solve the linear systems of equations $C_n x_n = d_n$, where the matrixes $C$ (in row echelon form) are slices from the first 2 dimensions of A
, the vectors $d$ are the slices from the first dimension of b
and $n$ is the size of the third dimension of A
. Returns the coefficients $x_n$ as a 2D matrix coeffs
, where the vectors $x_n$ are the rows of this matrix.
See also: gem3d!
, multi_mat_div_gem
LAP_julia.compare_dicts
— Methodcompare_dicts(old_dict, new_dict)
Compare two dicts by dividing their corresponding values, return the comparation dict.
Note: (old / new)
LAP_julia.cumsum2d!
— Methodcumsum2d!(result, A)
Cummulative sum over 2D matrix A
, storing the result into result
.
LAP_julia.estimation_noise_variance
— Methodestimation_noise_variance(img::Image)
Estimate the noise variance of an image y, by evaluating the Median of its Absolute Difference.
Note: Implementation in matlab by Thierry Blu, the Chinese University of Hong kong, Shatin, Hong Kong
LAP_julia.fill_circle!
— Methodfill_circle!(mag, pos, spacing, marker)
Fill a circle with a radius of spacing
around the point pos
into the matrix mag
with marker
.
LAP_julia.filter_border_inds
— Methodfilter_border_inds(inds, img_size, border_width)
Filter out the CartesianIndices inds
that are within the border_width
of an image of size img_size
.
LAP_julia.fun_on_dict_values
— Methodfun_on_dict_values(dicts, fun)
Run function fun
on all same keys of all dictionaries dicts
.
using BenchmarkTools
fun_on_dict_values((Dict(:a => 1), Dict(:a => 12)), mean)
# output
Dict{Any,Any} with 1 entry:
:a => 6.5
LAP_julia.gem3d!
— Methodgem3d!(A, b)
Reduce the linear systems of equations $C_n x_n = d_n$ to the row echelon form. The matrixes $C$ are slices from the first 2 dimensions of A
, the vectors $d$ are the slices from the first dimension of b
and $n$ is the size of the third dimension of A
.
See also: gem3d!
, back_substitution3d
LAP_julia.gen_one_spaghetti
— Methodgen_one_spaghetti(img_size, τ, len, spread)
Generate a single spaghetti image with the params τ
(thickness), len
(length) and spread
. The coordinates x
and y
in the equation are scaled from (-1, 1)
and the spread
gives the length of interval in which the (-1, 1)
is randomly located. The genereated spaghetti is also randomly rotated.
(Example for spread 10, the interval for x
and y
is randomly anywhere between (-9:1)
and (-1:9)
)
The intensity is equal to:
where
a
and b
are chosen randomly from a normal distribution.
See also: gen_spaghetti
, spaghetti_fun
LAP_julia.gen_rand_points
— Methodgen_rand_points(flow, point_count, mode; max_skew_const=4)
Generate point_count
random indices over flow
depending on selection mode
.
LAP_julia.gradient_magnitude
— Methodgradient_magnitude(f)
Return the directional derivatives (components of the gradient) and the gradient mag for both color and grayscale images. For spatialorder(f)=="xy"
, grad[1]
is a derivative wrt x, the first coordinate and grad[2]
wrt to the second...
LAP_julia.highpass_image
— Methodhighpass_image(img, window_half_size)
High-pass img
with a hight-pass filter. This high-pass filter is 1-gaussian
.
LAP_julia.inds_to_points
— Methodinds_to_points(inds::Array{CartesianIndex, 1})
Transform an array of CartersianIndexes
to an array of where each column is a vector of indices of the input array.
LAP_julia.inpaint_nans!
— Methodinpaint_nans!(flow::Flow)
Inpaint NaNs in flow
using surrounding non-NaN values.
References
Oliveira, Manuel & Bowen, Brian & McKenna, Richard & Chang, Yu-Sung. (2001). Fast Digital Image Inpainting.. 261-266. Here.
LAP_julia.interpolate_flow_rbf
— Methodinterpolate_flow_rbf(flow_at_inds,
inds::Array{CartesianIndex, 1},
flow_size,
rbf_method::T=Multiquadratic(2)) where {T <: ScatteredInterpolation.RadialBasisFunction}
Interpolate a complex displacement field of size flow_size
from displacement vectors flow_at_inds
at inds
using the a Multiquadratic RBF model with the parameter ε
and using only the values at inds
for the interpolation.
Examples of method
from ScatteredInterpolation:
Multiquadratic(ɛ = 1)
Polyharmonic(k = 1)
(See ScatteredInterpolation for more.)
See also: showflow
, Flow
, interpolate_flow
, interpolate_flow_quad
LAP_julia.load_H
— Methodload_H(path)
Load a homography matrix from path path
LAP_julia.make_flow_from_H
— Methodmake_flow_from_H(H, size)
Make a flow of size size
from the homography matrix H
.
LAP_julia.mapped_out
— Methodmapped_out(flow)
Return a mask that has true
at the locations where flow
would take the pixel out bounds of the image size.
LAP_julia.max_displacement
— Methodmax_displacement(flow)
Find the maximum displacement of flow
, ignoring NaN
s.
LAP_julia.move_landmarks
— Methodmove_landmarks(locations, flow)
Move each location::Tuple(T,T) where T <: Real
from the locations
vector using the flow
.
LAP_julia.multi_mat_div_gem
— Methodmulti_mat_div_gem(A, b)
Solve the linear systems of equations $C_n x_n = d_n$, where the matrixes $C$ are slices from the first 2 dimensions of A
, the vectors $d$ are the slices from the first dimension of b
and $n$ is the size of the third dimension of A
. Returns the coefficients $x_n$ as a 2D matrix coeffs
, where the vectors $x_n$ are the rows of this matrix.
Note: Uses Gaussian elimination and back substitution. Note: For small matrices $C$, this is an order of magnitude faster than
See also: gem3d!
, back_substitution3d
LAP_julia.multi_mat_div_using_qr
— Methodmulti_mat_div_using_qr(A, b)
Return E
, where E[i, :]
is the solutution of the least squares problem $\min\|D_ix - c_i\|^2$ for each $D_i$ and $c_i$, where $D_i$ is A[:, :, i]
, $c_i$ is b[:, i]
and $i$ is the size of the second dimension of b
and third dimension of A
. In other words, each row of E
is the solution to one matrix from A
and it's corresponding vector from b
.
LAP_julia.normalize_to_zero_one
— Methodnormalize_to_zero_one(arr)
Normalize arr
so that it has a maximum of 1 and minimum of 0.
LAP_julia.pad_images
— Methodpad_images(image1::Image, image2::Image)
Adds zeros to the right and bottom of image1
and image2
to make them the same size.
LAP_julia.pad_images_mask
— Methodpad_images(image1::Image, image2::Image)
Adds zeros to the right and bottom of image1
and image2
to make them the same size. Also create a mask, which has zeros at the edges of added zeros.
LAP_julia.points_to_inds
— Methodpoints_to_inds(points::Array{Int64,2})
Reverse of the inds_to_points
function.
LAP_julia.prepare_gaussian_filters
— Methodprepare_gaussian_filters(filter_half_size)
Get KernelFactors for the first 3 forward and backward gaussian filters from the LAP paper.
LAP_julia.rescale!
— Methodrescale!(image1::Image, image2::Image)
Rescale image1
and image2
intensities to span the whole [0, 1]
.
LAP_julia.smooth_with_gaussian!
— Methodsmooth_with_gaussian!(A::Matrix{<:Number}, window_half_size_one_dim::Integer)
Clean the Matrix A
by smoothing using a square 2D Gaussian filter of size 2 * window_half_size_one_dim + 1
in each dimension.
LAP_julia.smooth_with_gaussian!
— Methodsmooth_with_gaussian!(A::Matrix{<:Number}, window_half_size)
Smooth the Matrix A
by smoothing using a 2D Gaussian filter of size 2 * window_half_size + 1
.
LAP_julia.spaghetti_fun
— Methodspaghetti_fun(x, y, a, b, τ, len)
Gives the intensity for a single "spaghetti" at (x
, y
) with the params a
, b
, τ
and len
.
The intensity is equal to:
where
See also: gen_spaghetti
, gen_one_spaghetti
, gen_spaghetti
LAP_julia.to_lin_index
— Methodto_lin_index(cart_ind, size)
Get linear index from CartesianIndex cart_ind
of 2D matrix of size size
.
LAP_julia.vec_len
— Methodfunction vec_len(x)
Calculate the lenght of vector x
. x
is a complex number.
LAP_julia.window_sum!
— Methodfunction window_sum!(result, pixels, img_size, window)
Get a sum of values (using a "symmetric" padding on the borders) in a window window
around each point and saving the sum into result
.
Note: Uses a filter algorithm with a 2D ones kernel. Note: For small images (around 256x256
) and small filters (window of size 9 and below) is faster than window_sum3!
. <- factcheck this again
LAP_julia.window_sum3!
— Methodfunction window_sum3!(result, pixels, img_size, window)
Get a sum of values (using a "symmetric" padding on the borders) in a window window
around each point and saving the sum into result
.
Note: Uses a cumsum algorithm. Note: For small images (around 256x256
) and large filters (window of size 11 and above) is faster than window_sum!
. <- factcheck this again
LAP_julia.window_sum3_at_inds!
— Methodfunction window_sum3!(result, pixels, img_size, window, inds)
Get a sum of values (using a "symmetric" padding on the borders) in a window window
around inds
and saving the sum into result
.
Note: Uses a cumsum algorithm.