Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
julia 0.6
Images
Interpolations
AffineTransforms 0.2.1
StaticArrays
Images 0.14.0 0.15.0
Interpolations 0.7.3 0.7.3+
AffineTransforms 0.2.3 0.2.3+
StaticArrays 0.7.2 0.7.2+
NLsolve
MathProgBase 0.4
Ipopt
IterativeSolvers 0.3
MathProgBase 0.7.2 0.7.2+
Ipopt 0.4.0 0.4.0+
IterativeSolvers 0.6.0 0.6.0+
CUDArt
CUFFT
HDF5
JLD
Reexport
CUFFT 0.0.4 0.0.4+
HDF5 0.9.3 0.9.3+
JLD 0.8.3 0.8.3+
Reexport 0.1.0 0.1.0+
ForwardDiff 0.2.0
ProgressMeter
AxisArrays
Ratios
Compat 0.44
ColorTypes
OffsetArrays
ProgressMeter 0.5.6 0.5.6+
AxisArrays 0.2.1 0.2.1+
Ratios 0.3.0 0.3.0+
Compat 1.0.1 1.0.1+
ColorTypes 0.6.7 0.6.7+
OffsetArrays 0.6.0 0.6.0+
Optim
CoordinateTransformations
Rotations
Rotations 0.7.2 0.7.2+
5 changes: 5 additions & 0 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ else
end
end

if VERSION < v"0.7.0"
Pkg.checkout("ImageAxes", "julia0.6")
Pkg.pin("ImageAxes")
end

basedir = splitdir(splitdir(@__FILE__)[1])[1]
cd(joinpath(basedir, "src")) do
run(`make`)
Expand Down
2 changes: 1 addition & 1 deletion src/qd_rigid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ end

########### Rigid Transformation (rotation + translation) Search ############

update_SD(SD, tfm::Union{LinearMap, AffineMap}) = update_SD(SD, tfm.m)
update_SD(SD, tfm::Union{LinearMap, AffineMap}) = update_SD(SD, tfm.linear)
update_SD(SD, tfm::Transformation) = SD
update_SD(SD::AbstractArray, m::StaticArray) = update_SD(SD, Array(m))
update_SD(SD::AbstractArray, m::AbstractArray) = m\SD*m
Expand Down
30 changes: 15 additions & 15 deletions test/register_affine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ end

tfm, mm = qd_translate(fixed, moving, mxshift; maxevals=1000, thresh=thresh, rtol=0)

@test sum(abs.(tfm0.v - tfm.v)) < 1e-3
@test sum(abs.(tfm0.translation - tfm.translation)) < 1e-3

#3D
moving = rand(30,30,30)
Expand All @@ -67,7 +67,7 @@ end

tfm, mm = qd_translate(fixed, moving, mxshift; maxevals=1000, thresh=thresh, rtol=0)

@test sum(abs.(tfm0.v - tfm.v)) < 0.1
@test sum(abs.(tfm0.translation - tfm.translation)) < 0.1

######Rotations + Translations
#2D
Expand All @@ -85,7 +85,7 @@ end

tfm, mm = qd_rigid(centered(fixed), moving, mxshift, mxrot, minwidth_rot, SD; thresh=thresh, maxevals=1000, rtol=0, fvalue=1e-8)

@test sum(abs.(tfm0.m - tfm.m)) < 1e-3
@test sum(abs.(tfm0.linear - tfm.linear)) < 1e-3

#3D
moving = centered(rand(30,30,30))
Expand All @@ -102,7 +102,7 @@ end

tfm, mm = qd_rigid(centered(fixed), moving, mxshift, mxrot, minwidth_rot, SD; thresh=thresh, maxevals=1000, rtol=0)

@test sum(abs.(vcat(tfm0.m[:], tfm0.v) - vcat(RotXYZ(tfm.m)[:], tfm.v))) < 0.1
@test sum(abs.(vcat(tfm0.linear[:], tfm0.translation) - vcat(RotXYZ(tfm.linear)[:], tfm.translation))) < 0.1

#NOTE: the 2D test below fails rarely and the 3D test fails often, apparently because full affine is too difficult with these images
#####General Affine Transformations
Expand All @@ -122,7 +122,7 @@ end

tfm, mm = qd_affine(centered(fixed), moving, mxshift, SD; thresh=thresh, maxevals=1500, rtol=0, fvalue=1e-6)

@test sum(abs.(vcat(tfm0.m[:], tfm0.v) - vcat(tfm.m[:], tfm.v))) < 0.1
@test sum(abs.(vcat(tfm0.linear[:], tfm0.translation) - vcat(tfm.linear[:], tfm.translation))) < 0.1

#The tests below fail. Probably two factors contributing to failure:
# 1) Full affine 3D is a lot of parameters so it's just difficuilt (12 parameters)
Expand All @@ -146,7 +146,7 @@ end
#tfm, mm = qd_affine(centered(fixed), centered(moving), mxshift, SD; thresh=thresh, rtol=0, fvalue=1e-4);

#@test mm <= 1e-4
#@test sum(abs.(vcat(tfm0.m[:], tfm0.v) - vcat(tfm.m[:], tfm.v))) < 0.1
#@test sum(abs.(vcat(tfm0.linear[:], tfm0.translation) - vcat(tfm.linear[:], tfm.translation))) < 0.1

#not random
#moving = zeros(10,10,10);
Expand All @@ -165,12 +165,12 @@ end
#thresh = 0.5 * sum(abs2.(fixed[.!(isnan.(fixed))]));
#mxshift = [5;5;5];
#SD = eye(ndims(fixed));
#@test RegisterOptimize.aff(vcat(tfm00.v[:], tfm00.m[:]), fixed, SD) == tfm0
#@test RegisterOptimize.aff(vcat(tfm00.translation[:], tfm00.linear[:]), fixed, SD) == tfm0

#tfm, mm = qd_affine(centered(fixed), centered(moving), mxshift, SD; thresh=thresh, rtol=0, fvalue=1e-4);

#@test mm <= 1e-4
#@test sum(abs.(vcat(tfm0.m[:], tfm0.v) - vcat(tfm.m[:], tfm.v))) < 0.1
#@test sum(abs.(vcat(tfm0.linear[:], tfm0.translation) - vcat(tfm.linear[:], tfm.translation))) < 0.1

end #tests with random images

Expand All @@ -185,8 +185,8 @@ function fixedmov(img, tfm)
end

#helpers to convert Transformations to AffineMaps
to_affine(tfm::Translation) = AffineMap(eye(length(tfm.v)), tfm.v)
to_affine(tfm::LinearMap) = AffineMap(eye(length(tfm.v)), tfm.v)
to_affine(tfm::Translation) = AffineMap(eye(length(tfm.translation)), tfm.translation)
to_affine(tfm::LinearMap) = AffineMap(eye(length(tfm.translation)), tfm.translation)
to_affine(tfm::AffineMap) = tfm

#Helper to test that a found transform is (roughly) the inverse of the original transform
Expand All @@ -195,9 +195,9 @@ function tfmtest(tfm, tfminv)
diagtol = 0.005
offdiagtol = 0.005
vtol = 0.1
@test all(x->(1-diagtol < x < 1+diagtol), diag(comp.m))
@test all(x->(-offdiagtol < x < offdiagtol), comp.m.-diagm(diag(comp.m)))
@test all(abs.(comp.v) .< vtol)
@test all(x->(1-diagtol < x < 1+diagtol), diag(comp.linear))
@test all(x->(-offdiagtol < x < offdiagtol), comp.linear.-diagm(diag(comp.linear)))
@test all(abs.(comp.translation) .< vtol)
end

# tests with standard images
Expand Down Expand Up @@ -235,7 +235,7 @@ end
#make it harder with nonuniform scaling
scale = @SMatrix [1.005 0; 0 0.995]
SD = eye(2)
tfm = AffineMap(tfm.m*scale, tfm.v)
tfm = AffineMap(tfm.linear*scale, tfm.translation)
mxshift = (100,100) #make sure this isn't too small
fixed, moving = fixedmov(centered(img), tfm)
tform, mm = qd_affine(centered(fixed), centered(moving), mxshift, SD; maxevals=1000, rtol=0, fvalue=0.0002)
Expand All @@ -245,7 +245,7 @@ end
SD = diagm([0.5; 1.0])
tfm = Translation(@SVector([14.3, 17.8]))∘LinearMap(SD\RotMatrix(0.01)*SD)
scale = @SMatrix [1.005 0; 0 0.995]
tfm = AffineMap(tfm.m*scale, tfm.v)
tfm = AffineMap(tfm.linear*scale, tfm.translation)
fixed, moving = fixedmov(centered(img), tfm)
tform, mm = qd_affine(centered(fixed), centered(moving), mxshift, SD; maxevals=1000, rtol=0, fvalue=0.0002)
tfmtest(tfm, tform)
Expand Down