Internal Documentation

Documentation for LAP_julia.jl's internal interface.

Functions

LAP_julia.add_figs_pflapMethod
add_figs_pflap(figs, level, iter_repeat, u_est, Δ_u, source_reg, level_count, max_repeats)

Fill the figs array specifically for the pflap method.

source
LAP_julia.angle_maeMethod
function angle_mae(x, y)

Calculate the mean absolute error in angle between x and y. Output in degrees.

source
LAP_julia.angle_rmseMethod
function angle_rmse(x, y)

Calculate the root mean square error in angle between x and y. Output in degrees.

source
LAP_julia.back_substitution3dMethod
back_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

source
LAP_julia.compare_dictsMethod
compare_dicts(old_dict, new_dict)

Compare two dicts by dividing their corresponding values, return the comparation dict.

Note: (old / new)

source
LAP_julia.estimation_noise_varianceMethod
estimation_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

source
LAP_julia.fill_circle!Method
fill_circle!(mag, pos, spacing, marker)

Fill a circle with a radius of spacing around the point pos into the matrix mag with marker.

source
LAP_julia.filter_border_indsMethod
filter_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.

source
LAP_julia.fun_on_dict_valuesMethod
fun_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
source
LAP_julia.gem3d!Method
gem3d!(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

source
LAP_julia.gen_one_spaghettiMethod
gen_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:

\[I(\mathrm{x,y})=\left(1-\frac{f(\mathrm{x, y})}{τ^{2}}\right)\left(1+\mathrm{e} ^{\left(\left(\mathrm{x}^2 +\mathrm{y}^2 \right) -\mathrm{len}^{2}\right) /\left(50 τ^{2} \right)}\right)^{-1} \mathrm{e}^{-f(\mathrm{x, y}) /\left(2 τ^{2}\right)}\]

where

\[f(\mathrm{x, y})=\left|y-a x^{3}-b x\right|^{2} /\left(1+\left|3 a x^{2}-b\right|^{2}\right)\]

a and b are chosen randomly from a normal distribution.

See also: gen_spaghetti, spaghetti_fun

source
LAP_julia.gen_rand_pointsMethod
gen_rand_points(flow, point_count, mode; max_skew_const=4)

Generate point_count random indices over flow depending on selection mode.

source
LAP_julia.gradient_magnitudeMethod
gradient_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...

source
LAP_julia.highpass_imageMethod
highpass_image(img, window_half_size)

High-pass img with a hight-pass filter. This high-pass filter is 1-gaussian.

source
LAP_julia.inds_to_pointsMethod
inds_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.

source
LAP_julia.inpaint_nans!Method
inpaint_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.

See also: showflow, Flow

source
LAP_julia.interpolate_flow_rbfMethod
interpolate_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)

\[ϕ(r) = \sqrt{1 + (ɛr)^2}\]

Polyharmonic(k = 1)

\[ϕ(r) = r^k, k = 1, 3, 5, ... \\ ϕ(r) = r^k ln(r), k = 2, 4, 6, ...\]

(See ScatteredInterpolation for more.)

See also: showflow, Flow, interpolate_flow, interpolate_flow_quad

source
LAP_julia.mapped_outMethod
mapped_out(flow)

Return a mask that has true at the locations where flow would take the pixel out bounds of the image size.

source
LAP_julia.move_landmarksMethod
move_landmarks(locations, flow)

Move each location::Tuple(T,T) where T <: Real from the locations vector using the flow.

source
LAP_julia.multi_mat_div_gemMethod
multi_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

source
LAP_julia.multi_mat_div_using_qrMethod
multi_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.

source
LAP_julia.pad_imagesMethod
pad_images(image1::Image, image2::Image)

Adds zeros to the right and bottom of image1 and image2 to make them the same size.

source
LAP_julia.pad_images_maskMethod
pad_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.

source
LAP_julia.rescale!Method
rescale!(image1::Image, image2::Image)

Rescale image1 and image2 intensities to span the whole [0, 1].

source
LAP_julia.smooth_with_gaussian!Method
smooth_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.

source
LAP_julia.smooth_with_gaussian!Method
smooth_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.

source
LAP_julia.spaghetti_funMethod
spaghetti_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:

\[I(\mathrm{x,y})=\left(1-\frac{f(\mathrm{x, y})}{τ^{2}}\right)\left(1+\mathrm{e} ^{\left(\left(\mathrm{x}^2 +\mathrm{y}^2 \right) -\mathrm{len}^{2}\right) /\left(50 τ^{2} \right)}\right)^{-1} \mathrm{e}^{-f(\mathrm{x, y}) /\left(2 τ^{2}\right)}\]

where

\[f(\mathrm{x, y})=\left|y-a x^{3}-b x\right|^{2} /\left(1+\left|3 a x^{2}-b\right|^{2}\right)\]

See also: gen_spaghetti, gen_one_spaghetti, gen_spaghetti

source
LAP_julia.window_sum!Method
function 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

source
LAP_julia.window_sum3!Method
function 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

source
LAP_julia.window_sum3_at_inds!Method
function 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.

source