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
8cfd4834
Commit
8cfd4834
authored
Aug 03, 2025
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding diamonds
parent
22a12ccf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
235 additions
and
1 deletion
+235
-1
ShowDoubleFloatArrays.java
.../java/com/elphel/imagej/common/ShowDoubleFloatArrays.java
+24
-0
CuasMotion.java
src/main/java/com/elphel/imagej/cuas/CuasMotion.java
+211
-1
No files found.
src/main/java/com/elphel/imagej/common/ShowDoubleFloatArrays.java
View file @
8cfd4834
...
...
@@ -506,6 +506,30 @@ import ij.process.ImageProcessor;
}
else
imp
[
i
]=
null
;
return
imp
;
}
public
static
ImagePlus
makeArrays
(
float
[][]
pixels
,
int
width
,
int
height
,
String
title
,
String
[]
titles
)
{
int
i
,
j
;
if
(
pixels
==
null
)
{
System
.
out
.
println
(
"showDoubleFloatArrays.makeArrays(): - pixel array is null"
);
}
float
[]
fpixels
;
ImageStack
array_stack
=
new
ImageStack
(
width
,
height
);
boolean
not_empty
=
false
;
for
(
i
=
0
;
i
<
pixels
.
length
;
i
++)
if
(
pixels
[
i
]!=
null
)
{
not_empty
=
true
;
fpixels
=
new
float
[
pixels
[
i
].
length
];
for
(
j
=
0
;
j
<
fpixels
.
length
;
j
++)
fpixels
[
j
]=(
float
)
pixels
[
i
][
j
];
array_stack
.
addSlice
(
titles
[
i
],
fpixels
);
}
if
(
not_empty
)
{
ImagePlus
imp_stack
=
new
ImagePlus
(
title
,
array_stack
);
imp_stack
.
getProcessor
().
resetMinAndMax
();
return
imp_stack
;
}
return
null
;
}
public
static
ImagePlus
makeArrays
(
double
[][]
pixels
,
int
width
,
int
height
,
String
title
,
String
[]
titles
)
{
int
i
,
j
;
if
(
pixels
==
null
)
{
...
...
src/main/java/com/elphel/imagej/cuas/CuasMotion.java
View file @
8cfd4834
package
com
.
elphel
.
imagej
.
cuas
;
import
java.awt.Color
;
import
java.awt.Font
;
import
java.awt.Rectangle
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
com.elphel.imagej.cameras.CLTParameters
;
import
com.elphel.imagej.common.GenericJTabbedDialog
;
...
...
@@ -11,6 +17,7 @@ import com.elphel.imagej.common.ShowDoubleFloatArrays;
import
com.elphel.imagej.gpu.GPUTileProcessor
;
import
com.elphel.imagej.gpu.GpuQuad
;
import
com.elphel.imagej.gpu.TpTask
;
import
com.elphel.imagej.readers.ImagejJp4Tiff
;
import
com.elphel.imagej.tileprocessor.Correlation2d
;
import
com.elphel.imagej.tileprocessor.ImageDtt
;
import
com.elphel.imagej.tileprocessor.IntersceneMatchParameters
;
...
...
@@ -19,6 +26,13 @@ import com.elphel.imagej.tileprocessor.TDCorrTile;
import
com.elphel.imagej.tileprocessor.TileNeibs
;
import
ij.ImagePlus
;
import
ij.ImageStack
;
import
ij.process.ByteProcessor
;
import
ij.process.ColorProcessor
;
import
ij.process.FloatProcessor
;
import
ij.process.ImageConverter
;
import
ij.process.ImageProcessor
;
import
loci.formats.FormatException
;
public
class
CuasMotion
{
final
static
private
int
INDX_VX
=
0
;
...
...
@@ -741,7 +755,25 @@ public class CuasMotion {
true
,
title_accumulated
+
"-REPLACED-TARGETS"
,
// "-corr2d"+"-"+frame0+"-"+frame1+"-"+corr_pairs,
scene_titles
);
// titles_accum);
double
input_range
=
5
;
boolean
scale2x
=
true
;
String
diamond_path_1x
=
"/media/elphel/NVME/lwir16-proc/eagle_mountain/graphics/diamond21x17.png"
;
String
diamond_path_2x
=
"/media/elphel/NVME/lwir16-proc/eagle_mountain/graphics/diamond43x35_2px.png"
;
String
diamond_path
=
scale2x
?
diamond_path_2x
:
diamond_path_1x
;
ImagePlus
imp_color
=
convertToRgbAnnotateTargets
(
clt_parameters
,
// CLTParameters clt_parameters,
input_range
,
// final double input_range, // 5
scale2x
,
// boolean scale2x,
replaced_targets
,
// final float [][] fpixels,
targets60hz
,
// final double [][][] targets60hz,
frame0
,
// final int frame0,
corr_step
,
// final int frame_step,
cuasMotion
.
gpu_max_width
,
// final int width,
title_accumulated
+
"-COLOR"
,
// String title,
scene_titles
,
// String [] titles,
diamond_path
,
// //String diamond_path,
debugLevel
);
// final int debugLevel) {
imp_color
.
show
();
continue
;
}
...
...
@@ -2886,6 +2918,184 @@ public class CuasMotion {
return
iclt_fimg
[
0
][
0
].
clone
();
}
public
static
ImagePlus
convertToRgbAnnotateTargets
(
CLTParameters
clt_parameters
,
final
double
input_range
,
// 5
final
boolean
scale2x
,
final
float
[][]
fpixels
,
final
double
[][][]
targets60hz
,
final
int
frame0
,
final
int
frame_step
,
final
int
width_src
,
String
title
,
String
[]
titles
,
String
diamond_path
,
final
int
debugLevel
)
{
final
int
scale
=
scale2x
?
2
:
1
;
// String diamond_path = "/media/elphel/NVME/lwir16-proc/eagle_mountain/graphics/diamond21x17.png";
boolean
annotate_mono
=
clt_parameters
.
imp
.
annotate_mono
;
boolean
annotate_transparent_mono
=
clt_parameters
.
imp
.
annotate_transparent_mono
;
final
Color
annotate_color_mono
=
clt_parameters
.
imp
.
annotate_color_mono
;
ColorProcessor
diamond_cp
=
null
;
try
{
diamond_cp
=
new
ColorProcessor
(
ImageIO
.
read
(
new
File
(
diamond_path
)));
}
catch
(
IOException
e1
)
{
// TODO Auto-generated catch block
e1
.
printStackTrace
();
}
final
int
diamond_width
=
diamond_cp
.
getWidth
();
final
int
diamond_height
=
diamond_cp
.
getHeight
();
final
int
[]
diamond_pixels
=
((
int
[])
diamond_cp
.
getPixels
());
final
int
[][]
diamond_rgba
=
new
int
[
diamond_pixels
.
length
][
4
];
for
(
int
i
=
0
;
i
<
diamond_rgba
.
length
;
i
++)
{
for
(
int
s
=
0
;
s
<
4
;
s
++)
{
diamond_rgba
[
i
][
s
]
=
(
diamond_pixels
[
i
]
>>
(
8
*
s
))
&
0xff
;
}
}
final
int
num_scenes
=
fpixels
.
length
;
final
int
num_pixels
=
fpixels
[
0
].
length
;
final
int
num_seq
=
targets60hz
.
length
;
// final int height = num_pixels/width;
ImagePlus
imp
=
ShowDoubleFloatArrays
.
makeArrays
(
fpixels
,
// float[][] pixels,
width_src
,
// int width,
num_pixels
/
width_src
,
// int height,
title
,
// String title,
titles
);
// String [] titles)
imp
.
getProcessor
().
setMinAndMax
(-
input_range
/
2
,
input_range
/
2
);
String
imp_title
=
imp
.
getTitle
();
FloatProcessor
fp
=
(
FloatProcessor
)
imp
.
getProcessor
();
if
(
scale2x
)
{
ImageStack
stack
=
imp
.
getStack
();
int
width_new
=
scale
*
imp
.
getWidth
();
int
height_new
=
scale
*
imp
.
getHeight
();
String
[]
labels
=
new
String
[
stack
.
getSize
()];
for
(
int
i
=
0
;
i
<
labels
.
length
;
i
++)
{
labels
[
i
]
=
stack
.
getSliceLabel
(
i
+
1
);
}
FloatProcessor
[]
stackfp
=
new
FloatProcessor
[
stack
.
getSize
()];
for
(
int
i
=
0
;
i
<
stackfp
.
length
;
i
++)
{
stackfp
[
i
]
=
(
FloatProcessor
)
stack
.
getProcessor
(
i
+
1
);
}
System
.
out
.
println
(
"stackfp.length="
+
stackfp
.
length
);
// TODO: multithreaded
for
(
int
i
=
0
;
i
<
stackfp
.
length
;
i
++)
{
stackfp
[
i
]
=
(
FloatProcessor
)
stackfp
[
i
].
resize
(
stackfp
[
i
].
getWidth
()
*
2
,
stackfp
[
i
].
getHeight
()*
2
);
}
stack
=
new
ImageStack
(
width_new
,
height_new
);
// ,num_scenes);
for
(
int
i
=
0
;
i
<
stackfp
.
length
;
i
++)
{
stack
.
addSlice
(
labels
[
i
],
stackfp
[
i
]);
}
// FloatProcessor fp2x = (FloatProcessor) fp.resize(fp.getWidth() * 2, fp.getHeight()*2);
imp
=
new
ImagePlus
(
imp_title
,
stack
);
// imp.getTitle(),stack);
imp
.
show
();
// imp.setProcessor(fp2x);
// fp.scale(2.0, 2.0);
}
// imp.show();
ImageConverter
imageConverter
=
new
ImageConverter
(
imp
);
imageConverter
.
convertToRGB
();
// very slow - need multitherading
final
int
width
=
imp
.
getProcessor
().
getWidth
();
final
int
height
=
imp
.
getProcessor
().
getHeight
();
// imp.show();
final
Color
fcolor
=
annotate_color_mono
;
final
ImageStack
fstack_scenes
=
imp
.
getImageStack
();
// final int width = imp_scenes_pair[nstereo].getWidth();
// final int height = imp_scenes_pair[nstereo].getHeight();
final
int
posX
=
scale
*
(
width
-
119
);
// 521;
final
int
posY
=
scale
*
(
height
+
1
);
// 513;
final
Font
font
=
new
Font
(
"Monospaced"
,
Font
.
PLAIN
,
scale2x
?
24
:
12
);
final
int
nSlices
=
fstack_scenes
.
getSize
();
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
QuadCLT
.
THREADS_MAX
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
if
(
annotate_mono
)
{
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
for
(
int
nSlice
=
ai
.
getAndIncrement
();
nSlice
<
nSlices
;
nSlice
=
ai
.
getAndIncrement
())
{
String
scene_title
=
fstack_scenes
.
getSliceLabel
(
nSlice
+
1
);
ImageProcessor
ip
=
fstack_scenes
.
getProcessor
(
nSlice
+
1
);
ip
.
setColor
(
fcolor
);
// Color.BLUE);
ip
.
setFont
(
font
);
ip
.
drawString
(
scene_title
,
posX
,
posY
);
// transparent
}
}
};
}
ImageDtt
.
startAndJoin
(
threads
);
}
ImageStack
stack
=
imp
.
getStack
();
int
[][]
ipixels
=
new
int
[
num_scenes
][];
for
(
int
i
=
0
;
i
<
num_scenes
;
i
++)
{
ipixels
[
i
]
=
(
int
[])
stack
.
getPixels
(
i
+
1
);
}
// final int num_seq = targets60hz.length;
final
int
half_step0
=
-(
frame_step
+
1
)/
2
;
final
int
half_step1
=
frame_step
+
half_step0
;
ai
.
set
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
for
(
int
nSeq
=
ai
.
getAndIncrement
();
nSeq
<
num_seq
;
nSeq
=
ai
.
getAndIncrement
())
{
int
frame_center
=
frame0
+
nSeq
*
frame_step
;
for
(
int
dscene
=
half_step0
;
dscene
<
half_step1
;
dscene
++)
{
int
nscene
=
frame_center
+
dscene
;
if
((
nscene
>=
0
)
&&
(
nscene
<
num_scenes
))
{
double
[][]
targets
=
targets60hz
[
nscene
];
if
(
targets
!=
null
)
{
// TODO: find why
for
(
int
ntarget
=
0
;
ntarget
<
targets
.
length
;
ntarget
++)
{
int
xc
=
(
int
)
Math
.
round
(
scale
*
targets
[
ntarget
][
TARGET_X
]);
int
yc
=
(
int
)
Math
.
round
(
scale
*
targets
[
ntarget
][
TARGET_Y
]);
int
xl
=
xc
-
diamond_width
/
2
;
int
yt
=
yc
-
diamond_height
/
2
;
for
(
int
y
=
0
;
y
<
diamond_height
;
y
++)
{
int
py
=
yt
+
y
;
if
((
py
>=
0
)
&&
(
py
<
height
))
{
for
(
int
x
=
0
;
x
<
diamond_width
;
x
++)
{
int
px
=
xl
+
x
;
int
dpix
=
x
+
y
*
diamond_width
;
int
ipix
=
px
+
py
*
width
;
if
((
px
>=
0
)
&&
(
px
<
width
))
{
int
alpha
=
diamond_rgba
[
dpix
][
3
];
if
(
alpha
>
0
)
{
// alpha
int
dp
=
diamond_pixels
[
x
+
y
*
diamond_width
];
if
(
alpha
==
255
)
{
ipixels
[
nscene
][
ipix
]
=
dp
;
}
else
{
double
k
=
alpha
/
255.0
;
int
img_pix
=
ipixels
[
nscene
][
ipix
];
int
new_pix
=
0xff000000
;
for
(
int
c
=
0
;
c
<
3
;
c
++)
{
int
rgb
=
(
img_pix
>>
(
8
*
c
))
&
0xff
;
rgb
=
(
int
)
Math
.
round
((
1
-
k
)*
rgb
+
k
*
diamond_rgba
[
dpix
][
c
]);
if
(
rgb
>
255
)
rgb
=
255
;
new_pix
|=
(
rgb
<<
(
8
*
c
));
}
ipixels
[
nscene
][
ipix
]
=
new_pix
;
}
}
}
}
}
}
}
}
}
}
}
}
};
}
ImageDtt
.
startAndJoin
(
threads
);
imp
.
show
();
return
imp
;
}
...
...
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