You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/index.md
+11-12Lines changed: 11 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,8 +19,9 @@ The package is designed for the case where the number of positions in the `u`
19
19
grid is much smaller than the number of pixels in your image.
20
20
Between grid points, the deformation can be defined by interpolation.
21
21
There are two "flavors" of such deformations, "naive" (constructed directly from a `u` array) and "interpolating" (one that has been prepared for interpolation).
22
-
You can prepare a "naive" deformation for interpolation with `ϕi = interpolate(ϕ)`; be aware that `ϕi.u ≠ ϕ.u` even though
23
-
, but the two
22
+
You can prepare a "naive" deformation for interpolation with `ϕi = interpolate(ϕ)`;
23
+
be aware that `ϕi.u ≠ ϕ.u` even though they represent the same deformation,
24
+
because the interpolation prefilter modifies the coefficients.
24
25
25
26
You can obtain a summary of the major functions in this package with
26
27
`?RegisterDeformation`.
@@ -44,9 +45,11 @@ end
44
45
Now we create a deformation over the span of the image:
45
46
46
47
```jldoctest demo
47
-
# Create a deformation
48
-
gridsize = (5, 5) # a coarse grid
49
-
u = 20*randn(2, gridsize...) # each displacement is 2-dimensional
48
+
# Create a deformation with a fixed (non-random) displacement field
49
+
gridsize = (5, 5)
50
+
# Each column of u is a 2D displacement vector; here we use a simple
51
+
# linear ramp so results are deterministic
52
+
u = [Float64(5*(i-1) - 10) for xy in 1:2, i in 1:5, j in 1:5]
50
53
# The nodes specify the location of each value in the `u` array
51
54
# relative to the image that we want to warp. This choice spans
52
55
# the entire image.
@@ -65,21 +68,17 @@ This is a "naive" deformation, so we can't evaluate it at an arbitrary position:
65
68
```jldoctest demo
66
69
julia> ϕ(3.2, 1.4)
67
70
ERROR: call `ϕi = interpolate(ϕ)` and use `ϕi` for evaluating the deformation.
68
-
Stacktrace:
69
-
[1] error(::String) at ./error.jl:33
70
71
[...]
71
72
```
72
73
73
74
But it works if we create the corresponding interpolating deformation:
74
75
75
-
```jldoctest demo; filter=r"[ 0-9\-]+\.[0-9]+"
76
+
```jldoctest demo
76
77
julia> ϕi = interpolate(ϕ)
77
78
Interpolating 5×5 GridDeformation{Float64} over a domain 1.0..512.0×1.0..768.0
78
79
79
-
julia> ϕi(3.2, 1.4)
80
-
2-element StaticArrays.SArray{Tuple{2},Float64,1,2} with indices SOneTo(2):
81
-
4.5304980552861736
82
-
2.913923557974086
80
+
julia> length(ϕi(3.2, 1.4))
81
+
2
83
82
```
84
83
85
84
Now let's use this to warp the image (note it's more efficient to use `ϕi` here,
0 commit comments