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
33f052a0
Commit
33f052a0
authored
Mar 29, 2024
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working on 100m AGL
parent
758adc65
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
174 additions
and
43 deletions
+174
-43
ItemMatch.java
src/main/java/com/elphel/imagej/orthomosaic/ItemMatch.java
+18
-0
OrthoMap.java
src/main/java/com/elphel/imagej/orthomosaic/OrthoMap.java
+48
-12
OrthoMapsCollection.java
...va/com/elphel/imagej/orthomosaic/OrthoMapsCollection.java
+108
-31
No files found.
src/main/java/com/elphel/imagej/orthomosaic/ItemMatch.java
View file @
33f052a0
...
@@ -70,6 +70,24 @@ public class ItemMatch {
...
@@ -70,6 +70,24 @@ public class ItemMatch {
return
match
.
getMatch
(
indx
);
return
match
.
getMatch
(
indx
);
}
}
/**
* Return correlation value as the one of the pattern correlations pointed
* by the best subpattern index.
* @param groundObjectPattern
* @return selected correlation value
*/
public
double
getMatchValue
(
GroundObjectPattern
groundObjectPattern
)
{
return
getMatchValue
(
groundObjectPattern
.
getPatternPath
());
}
public
double
getMatchValue
(
String
pattern_path
)
{
int
indx
=
getPatternMatch
(
pattern_path
).
getBestSub
();
// -1;
return
getMatchValue
(
pattern_path
,
indx
);
}
public
double
getMatchValue
(
GroundObjectPattern
groundObjectPattern
,
int
indx
)
{
public
double
getMatchValue
(
GroundObjectPattern
groundObjectPattern
,
int
indx
)
{
return
getMatchValue
(
groundObjectPattern
.
getPatternPath
(),
indx
);
return
getMatchValue
(
groundObjectPattern
.
getPatternPath
(),
indx
);
}
}
...
...
src/main/java/com/elphel/imagej/orthomosaic/OrthoMap.java
View file @
33f052a0
...
@@ -2073,18 +2073,28 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
...
@@ -2073,18 +2073,28 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
* @param ipattern square pattern array corresponding to data. 1 means
* @param ipattern square pattern array corresponding to data. 1 means
* average (w/o outliers) and add, 2 - average and subtract
* average (w/o outliers) and add, 2 - average and subtract
* @param outliers_frac - fraction of outliers to remove while averaging
* @param outliers_frac - fraction of outliers to remove while averaging
* @param obscure_frac fraction between center average and peripheral ring to compare when obscure_warm
* is set.
* @param masked_data null or double[data.length] - will return a copy of data
* @param masked_data null or double[data.length] - will return a copy of data
* with NaN for all unused for averaging
* with NaN for all unused for averaging
* @param debug show debug images
* @param debug show debug images
* @return difference between average in-pattern (1) and outside (2) average
* @return a pair of : difference between average in-pattern (1) and outside (2) average
* values
* values, and difference between third zone and a threshold between averages of zone1
* and zone2. For full patterns (no zone3) this value is NaN. Positive values are good,
* regardless the cold or warm center. For cold patterns (morning) positive means
* that zone 3 minimum is warmer than fraction point between zone1 and zone2 (cold
* object obscured by something warmer, for hot - that obscurant is colder.
*
*/
*/
public
static
double
getAbsoluteContrast
(
public
static
double
[]
getAbsoluteContrast
(
double
[]
data
,
double
[]
data
,
int
[]
ipattern
,
int
[]
ipattern
,
double
outliers_frac
,
double
outliers_frac
,
// boolean obscure_warm, // = true; // obscured can only be by warmer objects
double
obscure_frac
,
// 0.25; // obscured threshold between center and outer
double
[]
masked_data
,
// null or double [data.length] to return masked data
double
[]
masked_data
,
// null or double [data.length] to return masked data
boolean
debug
)
{
boolean
debug
)
{
int
num_segments
=
3
;
if
(
debug
)
{
if
(
debug
)
{
int
size
=
(
int
)
Math
.
sqrt
(
data
.
length
);
int
size
=
(
int
)
Math
.
sqrt
(
data
.
length
);
ShowDoubleFloatArrays
.
showArrays
(
ShowDoubleFloatArrays
.
showArrays
(
...
@@ -2095,11 +2105,14 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
...
@@ -2095,11 +2105,14 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
}
}
ArrayList
<
ArrayList
<
Integer
>>
lists
=
new
ArrayList
<
ArrayList
<
Integer
>>();
ArrayList
<
ArrayList
<
Integer
>>
lists
=
new
ArrayList
<
ArrayList
<
Integer
>>();
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
for
(
int
i
=
0
;
i
<
num_segments
;
i
++)
{
lists
.
add
(
new
ArrayList
<
Integer
>());
lists
.
add
(
new
ArrayList
<
Integer
>());
}
}
double
[]
swd
=
new
double
[
2
],
sw
=
new
double
[
2
],
avg
=
new
double
[
2
],
fracw
=
new
double
[
2
];
double
[]
swd
=
new
double
[
num_segments
],
for
(
int
n
=
0
;
n
<
swd
.
length
;
n
++)
{
sw
=
new
double
[
num_segments
],
avg
=
new
double
[
num_segments
],
fracw
=
new
double
[
num_segments
];
for
(
int
n
=
0
;
n
<
num_segments
;
n
++)
{
// swd.length; n++) {
ArrayList
<
Integer
>
list
=
lists
.
get
(
n
);
ArrayList
<
Integer
>
list
=
lists
.
get
(
n
);
int
n1
=
n
+
1
;
int
n1
=
n
+
1
;
for
(
int
i
=
0
;
i
<
ipattern
.
length
;
i
++)
if
(
ipattern
[
i
]
==
n1
){
for
(
int
i
=
0
;
i
<
ipattern
.
length
;
i
++)
if
(
ipattern
[
i
]
==
n1
){
...
@@ -2110,9 +2123,23 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
...
@@ -2110,9 +2123,23 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
avg
[
n
]
=
swd
[
n
]/
sw
[
n
];
avg
[
n
]
=
swd
[
n
]/
sw
[
n
];
fracw
[
n
]
=
(
1.0
-
outliers_frac
)
*
sw
[
n
];
fracw
[
n
]
=
(
1.0
-
outliers_frac
)
*
sw
[
n
];
}
}
double
[]
zone3_min_max
=
{
Double
.
NaN
,
Double
.
NaN
};
int
zone3
=
3
;
for
(
int
i:
lists
.
get
(
zone3
-
1
))
{
if
(
Double
.
isNaN
(
zone3_min_max
[
0
])
||
(
data
[
i
]
<
zone3_min_max
[
0
]))
{
zone3_min_max
[
0
]
=
data
[
i
];
}
if
(
Double
.
isNaN
(
zone3_min_max
[
1
])
||
(
data
[
i
]
>
zone3_min_max
[
1
]))
{
zone3_min_max
[
1
]
=
data
[
i
];
}
}
if
(
debug
)
{
if
(
debug
)
{
System
.
out
.
println
(
"getAbsoluteContrast() before outliers: avg[0] ="
+
avg
[
0
]+
", avg[1]="
+
avg
[
1
]+
", avg[0]-avg[1]="
+(
avg
[
0
]-
avg
[
1
]));
System
.
out
.
println
(
"getAbsoluteContrast() before outliers: avg[0] ="
+
avg
[
0
]+
", avg[1]="
+
avg
[
1
]+
", avg[0]-avg[1]="
+(
avg
[
0
]-
avg
[
1
]));
}
}
if
(
outliers_frac
>
0
)
{
if
(
outliers_frac
>
0
)
{
for
(
int
n
=
0
;
n
<
swd
.
length
;
n
++)
{
for
(
int
n
=
0
;
n
<
swd
.
length
;
n
++)
{
ArrayList
<
Integer
>
list
=
lists
.
get
(
n
);
ArrayList
<
Integer
>
list
=
lists
.
get
(
n
);
...
@@ -2124,7 +2151,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
...
@@ -2124,7 +2151,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
return
(
rhsd
>
lhsd
)
?
-
1
:
(
rhsd
<
lhsd
)
?
1
:
0
;
return
(
rhsd
>
lhsd
)
?
-
1
:
(
rhsd
<
lhsd
)
?
1
:
0
;
}
}
});
});
while
(
sw
[
n
]
>=
fracw
[
n
]
)
{
while
(
!
list
.
isEmpty
()
&&
(
sw
[
n
]
>=
fracw
[
n
])
)
{
int
indx_first
=
list
.
get
(
0
);
int
indx_first
=
list
.
get
(
0
);
int
indx_last
=
list
.
get
(
list
.
size
()-
1
);
int
indx_last
=
list
.
get
(
list
.
size
()-
1
);
boolean
remove_first
=
Math
.
abs
(
data
[
indx_first
]
-
avg
[
n
])
>
Math
.
abs
(
data
[
indx_last
]
-
avg
[
n
]);
boolean
remove_first
=
Math
.
abs
(
data
[
indx_first
]
-
avg
[
n
])
>
Math
.
abs
(
data
[
indx_last
]
-
avg
[
n
]);
...
@@ -2137,6 +2164,11 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
...
@@ -2137,6 +2164,11 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
}
}
}
}
}
}
double
threshold
=
obscure_frac
*
avg
[
0
]
+
(
1.0
-
obscure_frac
)
*
avg
[
1
];
double
over_thresh
=
(
avg
[
0
]
<
avg
[
1
])
?
(
zone3_min_max
[
0
]
-
threshold
)
:
(
threshold
-
zone3_min_max
[
1
]);
if
(
masked_data
!=
null
)
{
if
(
masked_data
!=
null
)
{
Arrays
.
fill
(
masked_data
,
Double
.
NaN
);
Arrays
.
fill
(
masked_data
,
Double
.
NaN
);
for
(
int
n
=
0
;
n
<
lists
.
size
();
n
++)
{
for
(
int
n
=
0
;
n
<
lists
.
size
();
n
++)
{
...
@@ -2175,14 +2207,15 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
...
@@ -2175,14 +2207,15 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
if
(
debug
)
{
if
(
debug
)
{
System
.
out
.
println
(
"getAbsoluteContrast() after outliers: avg[0] ="
+
avg
[
0
]+
", avg[1]="
+
avg
[
1
]+
", avg[0]-avg[1]="
+(
avg
[
0
]-
avg
[
1
]));
System
.
out
.
println
(
"getAbsoluteContrast() after outliers: avg[0] ="
+
avg
[
0
]+
", avg[1]="
+
avg
[
1
]+
", avg[0]-avg[1]="
+(
avg
[
0
]-
avg
[
1
]));
}
}
return
avg
[
0
]-
avg
[
1
]
;
return
new
double
[]
{
avg
[
0
]-
avg
[
1
],
over_thresh
}
;
}
}
/**
/**
* From existing pattern (only for simple dark main scene)
* From existing pattern (only for simple dark main scene)
* create two zones to calculate average (w/o outliers) inside
* create two zones to calculate average (w/o outliers) inside
* the pattern and around it. Mark inner with 1, outer - 2, keep
* the pattern and around it. Mark inner with 1, outer - 2,
* other 0. Then later find 2 averages (removing outliers) and their
* 3 - potential obscurant for partial patterns
* keep other 0. Then later find 2 averages (removing outliers) and their
* difference - absolute contrast.
* difference - absolute contrast.
* @param patterns set of square patterns, first [0] for full pattern,
* @param patterns set of square patterns, first [0] for full pattern,
* others - for half-patterns cut in different directions.
* others - for half-patterns cut in different directions.
...
@@ -2287,6 +2320,8 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
...
@@ -2287,6 +2320,8 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
(
fys
)*(
fxs
)*
npatterns
[
n
][
sindx
+
size
+
1
];
(
fys
)*(
fxs
)*
npatterns
[
n
][
sindx
+
size
+
1
];
if
(
sdn
/
sd0
>
0.5
)
{
if
(
sdn
/
sd0
>
0.5
)
{
ipatterns
[
n
][
indx
]
=
ipatterns
[
0
][
indx
];
// =2
ipatterns
[
n
][
indx
]
=
ipatterns
[
0
][
indx
];
// =2
}
else
{
ipatterns
[
n
][
indx
]
=
3
;
// =2
}
}
}
}
}
}
...
@@ -2305,6 +2340,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
...
@@ -2305,6 +2340,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
switch
(
ipatterns
[
n
][
i
])
{
switch
(
ipatterns
[
n
][
i
])
{
case
1
:
dbg_img
[
n
][
i
]
=
1.0
;
break
;
case
1
:
dbg_img
[
n
][
i
]
=
1.0
;
break
;
case
2
:
dbg_img
[
n
][
i
]
=
-
1.0
;
break
;
case
2
:
dbg_img
[
n
][
i
]
=
-
1.0
;
break
;
case
3
:
dbg_img
[
n
][
i
]
=
-
2.0
;
break
;
}
}
}
}
}
}
...
@@ -4297,7 +4333,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
...
@@ -4297,7 +4333,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
final
int
dbg_pix3
=
1439211
;
// 2827822;
final
int
dbg_pix3
=
1439211
;
// 2827822;
final
int
dbg_x
=
1445
;
final
int
dbg_x
=
1445
;
final
int
dbg_y
=
2338
;
final
int
dbg_y
=
2338
;
final
int
dbg_tolerance
=
10
;
final
int
dbg_tolerance
=
-
10
;
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
public
void
run
()
{
...
...
src/main/java/com/elphel/imagej/orthomosaic/OrthoMapsCollection.java
View file @
33f052a0
This diff is collapsed.
Click to expand it.
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