Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
75c570c2
Commit
75c570c2
authored
May 02, 2024
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tested LMA equalization, some bug fixes
parent
f7f4a8dd
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
770 additions
and
105 deletions
+770
-105
ComboMatch.java
src/main/java/com/elphel/imagej/orthomosaic/ComboMatch.java
+18
-5
OrthoEqualizeLMA.java
.../java/com/elphel/imagej/orthomosaic/OrthoEqualizeLMA.java
+659
-0
OrthoMap.java
src/main/java/com/elphel/imagej/orthomosaic/OrthoMap.java
+4
-1
OrthoMapsCollection.java
...va/com/elphel/imagej/orthomosaic/OrthoMapsCollection.java
+25
-8
OrthoMultiLMA.java
...ain/java/com/elphel/imagej/orthomosaic/OrthoMultiLMA.java
+61
-91
PairwiseOrthoMatch.java
...ava/com/elphel/imagej/orthomosaic/PairwiseOrthoMatch.java
+3
-0
No files found.
src/main/java/com/elphel/imagej/orthomosaic/ComboMatch.java
View file @
75c570c2
...
...
@@ -159,6 +159,8 @@ public class ComboMatch {
boolean
create_overlaps
=
false
;
boolean
equalize_overlaps
=
false
;
boolean
create_map
=
false
;
boolean
create_equalize
=
false
;
// boolean show_combo_mask = false; // generate image mas (where it is defined)_
// boolean use_alt = false;
// boolean show_centers = true;
...
...
@@ -194,7 +196,7 @@ public class ComboMatch {
}
GenericJTabbedDialog
gd
=
new
GenericJTabbedDialog
(
"Set image pair"
,
1200
,
7
00
);
GenericJTabbedDialog
gd
=
new
GenericJTabbedDialog
(
"Set image pair"
,
1200
,
8
00
);
gd
.
addChoice
(
"Files list/data path (w/o extension):"
,
files_lists_paths
,
files_lists_paths
[
default_list_choice
]);
gd
.
addCheckbox
(
"Use saved maps collection"
,
use_saved_collection
,
"If false - use files list."
);
gd
.
addCheckbox
(
"Save maps collection"
,
save_collection
,
"Save maps collection to be able to restore."
);
...
...
@@ -235,6 +237,7 @@ public class ComboMatch {
gd
.
addCheckbox
(
"Create overlap pairs"
,
create_overlaps
,
"Create scene pairs overlaps."
);
gd
.
addCheckbox
(
"Equalize overlap pairs"
,
equalize_overlaps
,
"Equalize intensities in overlaps."
);
gd
.
addCheckbox
(
"Create map"
,
create_map
,
"Create combined map from pairwise matches."
);
gd
.
addCheckbox
(
"Equalize intensities"
,
create_equalize
,
"Create map intensities equalization from pairwise matches."
);
// gd.addCheckbox ("Show combo image mask", show_combo_mask, "Display combo binary image.");
// gd.addCheckbox ("Show altitude combo image", use_alt, "Load and process altitude maps.");
gd
.
addNumericField
(
"Remove fraction of worst matches"
,
frac_remove
,
3
,
7
,
""
,
"When fitting scenes remove this fraction of worst match."
);
...
...
@@ -263,6 +266,7 @@ public class ComboMatch {
String
orthoMapsCollection_path
=
files_lists_paths
[
choice_index
]+
".data"
;
use_saved_collection
=
gd
.
getNextBoolean
();
save_collection
=
gd
.
getNextBoolean
();
String
orthoMapsCollection_savepath
=
save_collection
?
orthoMapsCollection_path:
null
;
process_correlation
=
gd
.
getNextBoolean
();
num_tries_fit
=
(
int
)
gd
.
getNextNumber
();
update_match
=
gd
.
getNextBoolean
();
...
...
@@ -292,6 +296,7 @@ public class ComboMatch {
create_overlaps
=
gd
.
getNextBoolean
();
equalize_overlaps
=
gd
.
getNextBoolean
();
create_map
=
gd
.
getNextBoolean
();
create_equalize
=
gd
.
getNextBoolean
();
frac_remove
=
gd
.
getNextNumber
();
metric_error
=
gd
.
getNextNumber
();
if
(
use_marked_image
)
{
// will only be used if found and asked
...
...
@@ -778,20 +783,28 @@ public class ComboMatch {
OrthoMultiLMA
.
buildOrthoMap
(
clt_parameters
,
// CLTParameters clt_parameters,
maps_collection
,
// OrthoMapsCollection maps_collection
orthoMapsCollection_path
);
// String orthoMapsCollection_path
orthoMapsCollection_savepath
);
// String orthoMapsCollection_path
return
true
;
}
if
(
create_equalize
)
{
OrthoEqualizeLMA
.
buildEqualize
(
clt_parameters
,
// CLTParameters clt_parameters,
maps_collection
,
// OrthoMapsCollection maps_collection
orthoMapsCollection_savepath
);
// String orthoMapsCollection_path
return
true
;
}
if
(
create_overlaps
)
{
boolean
ok
=
maps_collection
.
getIntersectedPairs
(
clt_parameters
,
// CLTParameters clt_parameters,
orthoMapsCollection_path
);
// String orthoMapsCollection_path);
orthoMapsCollection_
save
path
);
// String orthoMapsCollection_path);
return
ok
;
// Just exit, do not try other commands. if (!ok) return false;
}
if
(
equalize_overlaps
)
{
boolean
ok
=
maps_collection
.
equalizeIntersectedPairs
(
clt_parameters
,
// CLTParameters clt_parameters,
orthoMapsCollection_path
);
// String orthoMapsCollection_path);
orthoMapsCollection_
save
path
);
// String orthoMapsCollection_path);
return
ok
;
// Just exit, do not try other commands. if (!ok) return false;
}
...
...
src/main/java/com/elphel/imagej/orthomosaic/OrthoEqualizeLMA.java
0 → 100644
View file @
75c570c2
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/orthomosaic/OrthoMap.java
View file @
75c570c2
...
...
@@ -117,6 +117,9 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
public
transient
double
sfm_gain
=
Double
.
NaN
;
// maximal SfM gain of this map
public
transient
double
[]
equalize
=
{
1
,
0
};
// rectified value = equalize[0]*source_value+equalize[1]
private
void
writeObject
(
ObjectOutputStream
oos
)
throws
IOException
{
// temporary fix:
// double [][] affine_clone = {affine[0].clone(), affine[1].clone()};
// affine = affine_clone;
oos
.
defaultWriteObject
();
oos
.
writeObject
(
path
);
// oos.writeObject(scenes_path);
...
...
@@ -511,7 +514,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
}
public
void
setAffine
(
double
[][]
affine
)
{
this
.
affine
=
affine
;
this
.
affine
=
new
double
[][]
{
affine
[
0
].
clone
(),
affine
[
1
].
clone
()}
;
}
public
double
[][]
getAffine
(){
return
affine
;
...
...
src/main/java/com/elphel/imagej/orthomosaic/OrthoMapsCollection.java
View file @
75c570c2
...
...
@@ -4893,7 +4893,7 @@ public class OrthoMapsCollection implements Serializable{
int
debugLevel
)
{
int
[]
indices
=
getScenesSelection
(
null
,
// boolean select_all,
" to process"
);
// String purpose)
" to process
/display
"
);
// String purpose)
if
(
indices
==
null
)
{
return
false
;
}
...
...
@@ -4907,7 +4907,7 @@ public class OrthoMapsCollection implements Serializable{
int
[]
indices
,
int
debugLevel
)
{
boolean
show_map_stats
=
false
;
boolean
show_combo_map
=
false
;
// true;
boolean
show_combo_map
=
true
;
//
false; // true;
boolean
show_alt_map
=
false
;
boolean
show_combo_mask
=
false
;
// generate image mas (where it is defined)
boolean
show_frames
=
false
;
...
...
@@ -4920,6 +4920,8 @@ public class OrthoMapsCollection implements Serializable{
boolean
show_centers
=
true
;
boolean
bounds_to_indices
=
true
;
boolean
merge_layers
=
false
;
// instead of individuals
boolean
ignore_affines
=
false
;
boolean
ignore_equalize
=
false
;
String
save_top_dir
=
"/media/elphel/NVME/lwir16-proc/ortho_videos/debug/sept12-13/pattern_match/"
;
String
sub_dir
=
"combo_maps"
;
...
...
@@ -4942,10 +4944,15 @@ public class OrthoMapsCollection implements Serializable{
gd
.
addNumericField
(
"Margins"
,
margins
,
0
,
4
,
""
,
"Add margins around images"
);
gd
.
addCheckbox
(
"Show transformation centers"
,
show_centers
,
"Mark verticals from the UAS on the ground."
);
gd
.
addCheckbox
(
"Show transformation centers"
,
show_centers
,
"Mark verticals from the UAS on the ground."
);
gd
.
addCheckbox
(
"Bounds to selected images"
,
bounds_to_indices
,
"Set combo image bounds to selected images only. False - all images."
);
gd
.
addCheckbox
(
"Merge layers"
,
merge_layers
,
"Generate composite binary image."
);
gd
.
addCheckbox
(
"Ignore affines"
,
ignore_affines
,
"Ignore available affines, use unity."
);
gd
.
addCheckbox
(
"Ignore equalization"
,
ignore_equalize
,
"Ignore available intensity equalization, use unity."
);
gd
.
addStringField
(
"Pattern match save directory"
,
save_top_dir
,
120
,
"Top directory to save combo maps"
);
gd
.
addStringField
(
"Save subdirectory"
,
sub_dir
,
80
,
"Subdirectory for versions of the same scene/pair of scenes"
);
gd
.
addCheckbox
(
"Show generated images"
,
show_images
,
"Display generated images."
);
...
...
@@ -4968,7 +4975,8 @@ public class OrthoMapsCollection implements Serializable{
show_centers
=
gd
.
getNextBoolean
();
bounds_to_indices
=
gd
.
getNextBoolean
();
merge_layers
=
gd
.
getNextBoolean
();
ignore_affines
=
gd
.
getNextBoolean
();
ignore_equalize
=
gd
.
getNextBoolean
();
save_top_dir
=
gd
.
getNextString
();
sub_dir
=
gd
.
getNextString
();
show_images
=
gd
.
getNextBoolean
();
...
...
@@ -5015,13 +5023,22 @@ public class OrthoMapsCollection implements Serializable{
int
[]
wh
=
new
int
[
2
];
int
[]
origin
=
new
int
[
2
];
double
[][]
centers
=
show_centers
?
(
new
double
[
indices
.
length
][]):
null
;
double
[][][]
affines
=
null
;
if
(
ignore_affines
)
{
affines
=
new
double
[
indices
.
length
][
2
][
3
];
for
(
int
i
=
0
;
i
<
indices
.
length
;
i
++)
{
affines
[
i
][
0
][
0
]
=
1
;
affines
[
i
][
1
][
1
]
=
1
;
}
}
double
[][]
dmulti
=
renderMultiDouble
(
null
,
// double [][] ground_planes, // null - images, non-null altitudes. use new double[2][3] for old way alt
indices
,
// int [] indices, // null or which indices to use (normally just 2 for pairwise comparison)
bounds_to_indices
,
// boolean bounds_to_indices,
null
,
// affines, // double [][][] affines, // null or [indices.length][2][3]
affines
,
// null,
// affines, // double [][][] affines, // null or [indices.length][2][3]
null
,
// double [][] equalize,
true
,
// boolean ignore_equalize,
ignore_equalize
,
//
true, // boolean ignore_equalize,
null
,
// warp, // FineXYCorr warp,,
zoom_lev
,
// int zoom_level,
wh
,
// int [] wh,
...
...
src/main/java/com/elphel/imagej/orthomosaic/OrthoMultiLMA.java
View file @
75c570c2
/**
**
** OrthoMultiLMA - Fit multiple scenes orthographic using pair-wise affine
** tr
4
ansform matrices already calculated.
** transform matrices already calculated.
**
** Copyright (C) 2024 Elphel, Inc.
**
...
...
@@ -48,8 +48,6 @@ public class OrthoMultiLMA {
private
double
[]
parameters_vector
=
null
;
// private double [] x_vector = null; // not used. Save total weight
private
double
[]
y_vector
=
null
;
private
double
[][]
tile_centers
=
null
;
private
double
weight
=
0
;
// total weight
private
double
pure_weight
;
// weight of samples only as a fraction of total weight
private
double
[]
weights
;
// normalized so sum is 1.0 for all - samples and extra regularization
// private double pure_weight; // weight of samples only
...
...
@@ -219,17 +217,18 @@ public class OrthoMultiLMA {
OrthoMapsCollection
maps_collection
,
String
orthoMapsCollection_path
)
{
int
debugLevel
=
1
;
int
debugLevel
=
2
;
boolean
move_only
=
false
;
double
[]
val_coord
=
null
;
// 1 - valid, 0 - invalid, minimize coordinates errors
boolean
ignore_affines
=
false
;
boolean
use_inv
=
false
;
double
overlap_pow
=
2.0
;
// match weight as overlap fraction to this power
double
skew_pull
=
1.0
;
double
tilt_pull
=
1.0
;
double
scale_pull
=
0.1
;
// .0;
double
position_pull
=
0.0001
;
boolean
corr_avg
=
(
skew_pull
>
0
)
||
(
tilt_pull
>
0
)
||
(
scale_pull
>
0
);
boolean
show_result_image
=
false
;
int
[]
indices
=
maps_collection
.
getScenesSelection
(
null
,
// boolean select_all,
" to build a map"
);
// String purpose)
...
...
@@ -247,6 +246,7 @@ public class OrthoMultiLMA {
clt_parameters
,
// CLTParameters clt_parameters,
maps_collection
,
// OrthoMapsCollection maps_collection,
indices
,
// int [] indices,
ignore_affines
,
// boolean ignore_affines,
val_coord
,
// double [] val_coord, // 1 - valid, 0 - invalid, minimize coordinates errors
position_pull
,
// double position_pull,
skew_pull
,
// double skew_pull,
...
...
@@ -273,26 +273,10 @@ public class OrthoMultiLMA {
}
//Get and apply affines
//oml.updateAffines(maps_collection);
oml
.
updateAffines
(
maps_collection
);
if
(
show_result_image
)
{
double
[][][]
affines
=
oml
.
getAffines
();
double
[]
fx
=
oml
.
getFx
();
// test
/*
PairwiseOrthoMatch match = maps_collection.ortho_maps[indices[0]].getMatch(maps_collection.ortho_maps[indices[1]].getName());
double [][] match_affine = match.getAffine();
double [] enuOffset = maps_collection.ortho_maps[indices[1]].enuOffsetTo(maps_collection.ortho_maps[indices[0]]);
double [] rd = {enuOffset[0], -enuOffset[1]}; // {right,down} of the image
double [][] affine1a = PairwiseOrthoMatch.combineAffines(
affines[0], // double [][] affine0,
match_affine, //double [][] affine, // differential
rd); // double [] rd);
PairwiseOrthoMatch test_match = new PairwiseOrthoMatch (
affines[0], // double [][] affine0,
affines[1], // double [][] affine1,
rd); // double [] rd);
*/
int
zoom_level
=
-
2
;
int
[]
wh
=
new
int
[
2
];
...
...
@@ -328,21 +312,8 @@ public class OrthoMultiLMA {
roi
.
setOptions
(
"label"
);
imp_multi
.
setRoi
(
roi
);
imp_multi
.
show
();
/*
double [][] affine = getAffineAndDerivatives(
move_only, //boolean move_only,
affines[0], // double [][] affine00,
affines[1], // double [][] affine10,
oml.offsets[0], // double [] rd,
null); // double [][][] derivs)
PairwiseOrthoMatch pom = new PairwiseOrthoMatch (
affines[0],
affines[1],
oml.offsets[0]);
*/
}
/*
if
(
orthoMapsCollection_path
!=
null
)
{
try
{
maps_collection
.
writeOrthoMapsCollection
(
orthoMapsCollection_path
);
...
...
@@ -354,7 +325,6 @@ public class OrthoMultiLMA {
System
.
out
.
println
(
"Saved data to "
+
orthoMapsCollection_path
);
}
}
*/
return
0
;
}
...
...
@@ -373,6 +343,7 @@ public class OrthoMultiLMA {
CLTParameters
clt_parameters
,
OrthoMapsCollection
maps_collection
,
int
[]
indices
,
boolean
ignore_affines
,
double
[]
val_coord
,
// 1 - valid, 0 - invalid, minimize coordinates errors
double
position_pull
,
double
skew_pull
,
...
...
@@ -434,7 +405,7 @@ public class OrthoMultiLMA {
weights
=
new
double
[
n62
*
num_pairs
+
2
*
num_scenes
+
(
corr_avg
?
3
:
0
)];
parameters_vector
=
new
double
[
n62
*
num_scenes
];
// maybe will need move-only mode?
for
(
int
n
=
0
;
n
<
num_scenes
;
n
++)
{
double
[][]
affine
=
maps_collection
.
ortho_maps
[
indices
[
n
]].
getAffine
();
double
[][]
affine
=
ignore_affines
?
(
new
double
[][]
{{
1
,
0
,
0
},{
0
,
1
,
0
}}):
maps_collection
.
ortho_maps
[
indices
[
n
]].
getAffine
();
System
.
arraycopy
(
affine
[
0
],
0
,
parameters_vector
,
n62
*
n
,
n13
);
System
.
arraycopy
(
affine
[
1
],
0
,
parameters_vector
,
n62
*
n
+
n13
,
n13
);
y_vector
[
n62
*
num_pairs
+
2
*
n
+
0
]
=
affine
[
0
][
2
];
...
...
@@ -760,7 +731,7 @@ public class OrthoMultiLMA {
return
affine
;
// _alt;
}
p
rivate
static
int
[][]
createNonIntersectingPairs
(
int
[][]
pairs
)
{
p
ublic
static
int
[][]
createNonIntersectingPairs
(
int
[][]
pairs
)
{
ArrayList
<
Integer
>
pairs_list
=
new
ArrayList
<
Integer
>();
for
(
int
i
=
0
;
i
<
pairs
.
length
;
i
++)
{
pairs_list
.
add
(
i
);
...
...
@@ -835,7 +806,7 @@ public class OrthoMultiLMA {
System
.
out
.
println
(
"LMA step "
+
iter
+
": {"
+
rslt
[
0
]+
","
+
rslt
[
1
]+
"} full RMS= "
+
good_or_bad_rms
[
0
]+
" ("
+
initial_rms
[
0
]+
"), pure RMS="
+
good_or_bad_rms
[
1
]+
" ("
+
initial_rms
[
1
]+
") + lambda="
+
lambda
);
}
if
(
rslt
[
1
])
{
if
(
rslt
[
1
])
{
// the place to put a breakpoint
break
;
}
if
(
rslt
[
0
])
{
// good
...
...
@@ -1035,7 +1006,6 @@ public class OrthoMultiLMA {
return
rslt
;
}
private
double
[][]
getWJtJlambda
(
final
double
lambda
,
final
double
[][]
jt
)
...
...
@@ -1129,11 +1099,11 @@ public class OrthoMultiLMA {
return
last_rms
;
}
public
double
[]
getInitialRms
()
{
return
initial_rms
;
}
private
double
[]
getFxDerivs
(
final
double
[]
vector
,
final
double
[][]
jt
,
// should be null or initialized with [vector.length][]
...
...
src/main/java/com/elphel/imagej/orthomosaic/PairwiseOrthoMatch.java
View file @
75c570c2
...
...
@@ -19,6 +19,9 @@ public class PairwiseOrthoMatch implements Serializable {
public
PairwiseOrthoMatch
()
{
}
public
double
getOverlap
()
{
return
overlap
;
}
public
PairwiseOrthoMatch
(
double
[][]
affine
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment