Commit bfcd96d0 authored by Éric Thiébaut's avatar Éric Thiébaut
Browse files

Change method names

parent f177eb2e
......@@ -7,6 +7,7 @@ version = "0.1.0"
ArrayTools = "1dc0ca97-c5ce-4e77-ac6d-c576ac9d7f27"
EasyFITS = "a977f4a2-36a7-4172-89e7-19c2726f82e5"
MayOptimize = "049513e6-5a5e-4281-9d48-334ebac8954e"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
TwoDimensional = "1907e7ba-7586-4310-a2ba-dd01462aeb50"
......
......@@ -52,6 +52,11 @@ include("types.jl")
include("utils.jl")
include("weighted.jl")
include("geometry.jl")
for sym in exported_symbols(Geometry)
@eval import .Geometry: $sym
end
include("iterators.jl")
for sym in exported_symbols(Iterators)
@eval import .Iterators: $sym
......
#
# Geometry.jl --
# geometry.jl -
#
# Methods for calibrating the geometry of the wavefront sensor.
#
#-------------------------------------------------------------------------------
#
# This file if part of the TAO software (https://github.com/emmt/TAO) licensed
# under the MIT license.
# This file is part of TAO software (https://git-cral.univ-lyon1.fr/tao)
# licensed under the MIT license.
#
# Copyright (C) 2020, Éric Thiébaut.
# Copyright (C) 2020-2021, Éric Thiébaut.
#
module Geometry
export
find_aligned_boxes
using Printf
using TwoDimensional, ArrayTools, MappedArrays
using TwoDimensional, ArrayTools
"""
......@@ -24,10 +27,7 @@ using TwoDimensional, ArrayTools, MappedArrays
const Subtractable = Union{Signed,AbstractFloat}
"""
```julia
findalignedboxes(img, msk, siz=26:40)
```
find_aligned_boxes(img, msk, siz=26:40)
yields an array of aligned bounding boxes found in image `img` accroding to the
layout given by the true values in mask `msk`. Optional argument `siz` is to
......@@ -42,12 +42,12 @@ margin yields large boxes. The default value is `margin=0`.
Keyword `plot` can be set with a reference to `PyPlot` module to plot results.
"""
function findalignedboxes(A::AbstractMatrix{<:Real},
mask::AbstractMatrix{Bool},
boxsizes::AbstractVector{<:Integer} = 26:40;
margin::Integer = 0,
quiet::Bool = false,
plot = nothing)
function find_aligned_boxes(A::AbstractMatrix{<:Real},
mask::AbstractMatrix{Bool},
boxsizes::AbstractVector{<:Integer} = 26:40;
margin::Integer = 0,
quiet::Bool = false,
plot = nothing)
@assert length(boxsizes) > 0 && minimum(boxsizes) > 0
T = Float64
......@@ -120,10 +120,10 @@ function findalignedboxes(A::AbstractMatrix{<:Real},
best_xorigins = Array{Int}(undef, nx)
best_yorigins = Array{Int}(undef, ny)
for boxsize in of_eltype(Int, boxsizes)
matchopposite!(Qx, Gx, boxsize - 1)
matchopposite!(Qy, Gy, boxsize - 1)
findmaxima!(Ix, Qx, boxsize - 1, Sx)
findmaxima!(Iy, Qy, boxsize - 1, Sy)
match_opposite!(Qx, Gx, boxsize - 1)
match_opposite!(Qy, Gy, boxsize - 1)
find_maxima!(Ix, Qx, boxsize - 1, Sx)
find_maxima!(Iy, Qy, boxsize - 1, Sy)
if length(Ix) nx && length(Iy) ny
score1 = zero(T)
@inbounds for k in 1:nx
......@@ -206,27 +206,20 @@ function print_values(io::IO, A::AbstractVector; newline::Bool=false)
end
"""
```julia
differentiate(A) -> G
```
differentiate(A) -> G
yields the discrete derivative of vector `A`. The result is a vector of
floating-point values of same size as `A`.
The output vector may be provided:
```julia
differentiate!(dst, src) -> dst
```
differentiate!(dst, src) -> dst
overwrites the contents of `dst` with the discrete derivative of vector `src`.
The operation can be done in-place, that is with `src` and `dst` the same
object. In that case, just call:
```julia
differentiate!(A) -> A
```
differentiate!(A) -> A
When the output array is provided and has integer elements, twice the discrete
derivatives are computed.
......@@ -287,16 +280,11 @@ end
@inline diff2(::Type{T}, a, b) where {T<:Signed} = (T(a) - T(b))
"""
```julia
matchopposite(A, off) -> B
```
match_opposite(A, off) -> B
yields vector `B` whose elements are given by:
```
B[i] = A[i] - A[i+off] (∀i)
```
B[i] = A[i] - A[i+off] (∀i)
and assuming `A[i+off] = 0` if `i+off` is beyond limits.
......@@ -305,18 +293,16 @@ This linear filter is useful to detect opposite features of a given size (here
A destination array can be provided to avoid allocating memory:
```julia
matchopposite!(dst, src, off) -> dst
```
match_opposite!(dst, src, off) -> dst
overwrites `dst` with the result. The operation can be applied *in-place*,
that is with `src` and `dst` being the same object.
"""
matchopposite(A::AbstractVector{T}, off::Int) where {T<:Subtractable} =
matchopposite!(similar(Array{T}, axes(A)), A, off)
match_opposite(A::AbstractVector{T}, off::Int) where {T<:Subtractable} =
match_opposite!(similar(Array{T}, axes(A)), A, off)
function matchopposite!(dst::AbstractVector{<:Subtractable},
function match_opposite!(dst::AbstractVector{<:Subtractable},
src::AbstractVector{<:Subtractable},
off::Int)
off 1 || throw(ArgumentError("offset must be at least 1"))
......@@ -331,15 +317,12 @@ function matchopposite!(dst::AbstractVector{<:Subtractable},
return dst
end
@doc @doc(matchopposite) matchopposite!
@doc @doc(match_opposite) match_opposite!
throw_not_same_axes() = throw(DimensionMismatch("arrays must have same axes"))
"""
```julia
findmaxima!(I, A, gap, ws=similar(A)) -> I
```
find_maxima!(I, A, gap, ws=similar(A)) -> I
overwrites `I` with the list of the indices of the most significant local
maxima in vector `A`. Local maxima are detected in decreasing order of
......@@ -352,17 +335,14 @@ will be set to zero at all positions but those corresponding to the local
maxima found.
"""
function findmaxima!(I::AbstractVector{Int},
A::AbstractVector,
gap::Integer, args...)
function find_maxima!(I::AbstractVector{Int},
A::AbstractVector,
gap::Integer, args...)
return _find!(I, zero, identity, >, A, Int(gap), args...)
end
"""
```julia
findminima!(I, A, gap, ws=similar(A)) -> I
```
find_minima!(I, A, gap, ws=similar(A)) -> I
overwrites `I` with the list of the indices of the most significant local
minima in vector `A`. Local minima are detected in decreasing order of
......@@ -375,17 +355,14 @@ will be set to zero at all positions but those corresponding to the local
minima found.
"""
function findminima!(I::AbstractVector{Int},
A::AbstractVector,
gap::Integer, args...)
function find_minima!(I::AbstractVector{Int},
A::AbstractVector,
gap::Integer, args...)
return _find!(I, zero, identity, <, A, Int(gap), args...)
end
"""
```julia
findextrema!(I, A, gap, ws=similar(A)) -> I
```
find_extrema!(I, A, gap, ws=similar(A)) -> I
overwrites `I` with the list of the indices of the most significant local
extrema in vector `A`. Local extrema are detected in decreasing order of
......@@ -397,9 +374,9 @@ allocating memory. Argument `A` can be used as workspace if its contents
is no longer needed.
"""
function findextrema!(I::AbstractVector{Int},
A::AbstractVector,
gap::Integer, args...)
function find_extrema!(I::AbstractVector{Int},
A::AbstractVector,
gap::Integer, args...)
return _find!(I, zero, abs, >, A, Int(gap), args...)
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment