Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QcmpCompressionLibrary
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioinformaticDataCompression
QcmpCompressionLibrary
Commits
8c14ff72
Commit
8c14ff72
authored
5 years ago
by
Vojtech Moravec
Browse files
Options
Downloads
Patches
Plain Diff
Improved usability of MeasurePlaneErrorFunction.
parent
47497bfc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/azgracompress/cli/functions/MeasurePlaneErrorFunction.java
+125
-58
125 additions, 58 deletions
...zgracompress/cli/functions/MeasurePlaneErrorFunction.java
with
125 additions
and
58 deletions
src/main/java/azgracompress/cli/functions/MeasurePlaneErrorFunction.java
+
125
−
58
View file @
8c14ff72
...
@@ -17,85 +17,152 @@ public class MeasurePlaneErrorFunction extends CustomFunctionBase {
...
@@ -17,85 +17,152 @@ public class MeasurePlaneErrorFunction extends CustomFunctionBase {
super
(
options
);
super
(
options
);
}
}
private
final
String
COMP_FILE_ch0
=
"D:\\biology\\tiff_data\\benchmark\\fused_tp_10_ch_0_16bit.raw"
;
private
final
String
COMP_FILE_ch1
=
"D:\\biology\\tiff_data\\benchmark\\fused_tp_10_ch_1_16bit.raw"
;
@Override
@Override
public
boolean
run
()
{
public
boolean
run
()
{
// if (reportPlaneDifference(
final
int
channel
=
1
;
// "D:\\biology\\tiff_data\\quantized\\middle_frame\\fused_tp_10_ch_1_16bit_sq_cb256.raw",
assert
(
channel
==
0
||
channel
==
1
);
// "D:\\biology\\tiff_data\\quantized\\middle_frame\\plane_diff_ch1\\sq_cb256_plane_log.data")) {
final
String
comp_file
=
channel
==
0
?
COMP_FILE_ch0
:
COMP_FILE_ch1
;
// return false;
final
String
method
=
"sq"
;
// }
final
String
type
=
"plane_codebook"
;
final
String
folder
=
"D:\\biology\\tiff_data\\quantized"
;
// if (reportPlaneDifference(
// "D:\\biology\\tiff_data\\quantized\\middle_frame\\fused_tp_10_ch_1_16bit_vq3x3_cb128.raw",
if
(
reportPlaneDifference
(
// "D:\\biology\\tiff_data\\quantized\\middle_frame\\plane_diff_ch1\\vq3x3_cb128_plane_log.data")) {
String
.
format
(
"%s\\%s\\fused_tp_10_ch_%d_16bit_%s_cb256.raw"
,
folder
,
type
,
channel
,
method
),
// return false;
String
.
format
(
"%s\\%s\\plane_diff_ch%d\\%s_cb256_plane_log.data"
,
folder
,
type
,
channel
,
method
),
// }
comp_file
))
{
//
return
false
;
// if (reportPlaneDifference(
}
// "D:\\biology\\tiff_data\\quantized\\middle_frame\\fused_tp_10_ch_1_16bit_vq3x3_cb64.raw",
// "D:\\biology\\tiff_data\\quantized\\middle_frame\\plane_diff_ch1\\vq3x3_cb64_plane_log.data")) {
if
(
reportPlaneDifference
(
// return false;
String
.
format
(
"%s\\%s\\fused_tp_10_ch_%d_16bit_%s_cb128.raw"
,
folder
,
type
,
channel
,
method
),
// }
String
.
format
(
"%s\\%s\\plane_diff_ch%d\\%s_cb128_plane_log.data"
,
folder
,
type
,
channel
,
method
),
//
comp_file
))
{
// if (reportPlaneDifference(
return
false
;
// "D:\\biology\\tiff_data\\quantized\\middle_frame\\fused_tp_10_ch_1_16bit_vq3x3_cb32.raw",
}
// "D:\\biology\\tiff_data\\quantized\\middle_frame\\plane_diff_ch1\\vq3x3_cb32_plane_log.data")) {
// return false;
// }
//
// if (reportPlaneDifference(
// "D:\\biology\\tiff_data\\quantized\\middle_frame\\fused_tp_10_ch_1_16bit_vq3x3_cb16.raw",
// "D:\\biology\\tiff_data\\quantized\\middle_frame\\plane_diff_ch1\\vq3x3_cb16_plane_log.data")) {
// return false;
// }
//
// if (reportPlaneDifference(
// "D:\\biology\\tiff_data\\quantized\\middle_frame\\fused_tp_10_ch_1_16bit_vq3x3_cb8.raw",
// "D:\\biology\\tiff_data\\quantized\\middle_frame\\plane_diff_ch1\\vq3x3_cb8_plane_log.data")) {
// return false;
// }
//
if
(
reportPlaneDifference
(
if
(
reportPlaneDifference
(
"D:\\biology\\tiff_data\\quantized\\middle_frame\\fused_tp_10_ch_1_16bit_sq_cb4.raw"
,
String
.
format
(
"%s\\%s\\fused_tp_10_ch_%d_16bit_%s_cb64.raw"
,
folder
,
type
,
channel
,
method
),
"D:\\biology\\tiff_data\\quantized\\middle_frame\\plane_diff_ch1\\sq_cb4_plane_log.data"
))
{
String
.
format
(
"%s\\%s\\plane_diff_ch%d\\%s_cb64_plane_log.data"
,
folder
,
type
,
channel
,
method
),
comp_file
))
{
return
false
;
return
false
;
}
}
if
(
reportPlaneDifference
(
String
.
format
(
"%s\\%s\\fused_tp_10_ch_%d_16bit_%s_cb32.raw"
,
folder
,
type
,
channel
,
method
),
String
.
format
(
"%s\\%s\\plane_diff_ch%d\\%s_cb32_plane_log.data"
,
folder
,
type
,
channel
,
method
),
comp_file
))
{
return
false
;
}
if
(
reportPlaneDifference
(
String
.
format
(
"%s\\%s\\fused_tp_10_ch_%d_16bit_%s_cb16.raw"
,
folder
,
type
,
channel
,
method
),
String
.
format
(
"%s\\%s\\plane_diff_ch%d\\%s_cb16_plane_log.data"
,
folder
,
type
,
channel
,
method
),
comp_file
))
{
return
false
;
}
if
(
reportPlaneDifference
(
String
.
format
(
"%s\\%s\\fused_tp_10_ch_%d_16bit_%s_cb8.raw"
,
folder
,
type
,
channel
,
method
),
String
.
format
(
"%s\\%s\\plane_diff_ch%d\\%s_cb8_plane_log.data"
,
folder
,
type
,
channel
,
method
),
comp_file
))
{
return
false
;
}
if
(
reportPlaneDifference
(
String
.
format
(
"%s\\%s\\fused_tp_10_ch_%d_16bit_%s_cb4.raw"
,
folder
,
type
,
channel
,
method
),
String
.
format
(
"%s\\%s\\plane_diff_ch%d\\%s_cb4_plane_log.data"
,
folder
,
type
,
channel
,
method
),
comp_file
))
{
return
false
;
}
// if (reportPlaneDifference(
// "D:\\biology\\tiff_data\\quantized\\plane_codebook\\fused_tp_10_ch_1_16bit_sq_cb4.raw",
// "D:\\biology\\tiff_data\\quantized\\plane_codebook\\plane_diff_ch1\\sq_cb4_plane_log.data",
// comp_file)) {
// return false;
// }
return
true
;
return
true
;
}
}
private
boolean
reportPlaneDifference
(
final
String
compressedFile
,
final
String
reportFile
)
{
private
boolean
reportPlaneDifference
(
final
String
compressedFile
,
final
String
reportFile
,
final
String
compFile
)
{
final
String
referenceFile
=
"D:\\biology\\tiff_data\\benchmark\\fused_tp_10_ch_1_16bit.raw"
;
final
String
referenceFile
=
compFile
;
final
int
workerCount
=
8
;
final
V3i
dims
=
new
V3i
(
1041
,
996
,
946
);
final
V3i
dims
=
new
V3i
(
1041
,
996
,
946
);
final
int
planePixelCount
=
dims
.
getX
()
*
dims
.
getY
();
final
int
planePixelCount
=
dims
.
getX
()
*
dims
.
getY
();
System
.
out
.
println
(
options
.
report
());
System
.
out
.
println
(
options
.
report
());
System
.
out
.
println
(
"Run custom function."
);
System
.
out
.
println
(
"Run custom function."
);
ImageU16
compressedPlane
=
null
;
//
ImageU16 compressedPlane = null;
ImageU16
originalPlane
=
null
;
//
ImageU16 originalPlane = null;
ImageU16
differencePlane
=
null
;
//
ImageU16 differencePlane = null;
PlaneError
[]
planeErrors
=
new
PlaneError
[
dims
.
getZ
()];
PlaneError
[]
planeErrors
=
new
PlaneError
[
dims
.
getZ
()];
for
(
int
planeIndex
=
0
;
planeIndex
<
dims
.
getZ
();
planeIndex
++)
{
Thread
[]
workers
=
new
Thread
[
workerCount
];
try
{
final
int
workSize
=
dims
.
getZ
()
/
workerCount
;
originalPlane
=
RawDataIO
.
loadImageU16
(
referenceFile
,
dims
,
planeIndex
);
compressedPlane
=
RawDataIO
.
loadImageU16
(
compressedFile
,
dims
,
planeIndex
);
for
(
int
wId
=
0
;
wId
<
workerCount
;
wId
++)
{
}
catch
(
IOException
e
)
{
final
int
fromIndex
=
wId
*
workSize
;
e
.
printStackTrace
();
final
int
toIndex
=
(
wId
==
workerCount
-
1
)
?
dims
.
getZ
()
:
(
workSize
+
(
wId
*
workSize
));
return
true
;
}
final
int
[]
diffData
=
Utils
.
getDifference
(
originalPlane
.
getData
(),
compressedPlane
.
getData
());
Utils
.
applyAbsFunction
(
diffData
);
workers
[
wId
]
=
new
Thread
(()
->
{
final
double
absDiffSum
=
Arrays
.
stream
(
diffData
).
mapToDouble
(
v
->
v
).
sum
();
ImageU16
originalPlane
,
compressedPlane
,
differencePlane
;
final
double
meanPixelError
=
absDiffSum
/
(
double
)
planePixelCount
;
for
(
int
planeIndex
=
fromIndex
;
planeIndex
<
toIndex
;
planeIndex
++)
{
try
{
originalPlane
=
RawDataIO
.
loadImageU16
(
referenceFile
,
dims
,
planeIndex
);
compressedPlane
=
RawDataIO
.
loadImageU16
(
compressedFile
,
dims
,
planeIndex
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
break
;
}
planeErrors
[
planeIndex
]
=
new
PlaneError
(
planeIndex
,
absDiffSum
,
meanPixelError
);
// System.out.println("Finished plane: " + planeIndex);
final
int
[]
diffData
=
Utils
.
getDifference
(
originalPlane
.
getData
(),
compressedPlane
.
getData
());
Utils
.
applyAbsFunction
(
diffData
);
final
double
absDiffSum
=
Arrays
.
stream
(
diffData
).
mapToDouble
(
v
->
v
).
sum
();
final
double
meanPixelError
=
absDiffSum
/
(
double
)
planePixelCount
;
planeErrors
[
planeIndex
]
=
new
PlaneError
(
planeIndex
,
absDiffSum
,
meanPixelError
);
}
});
workers
[
wId
].
start
();
}
}
try
{
for
(
int
wId
=
0
;
wId
<
workerCount
;
wId
++)
{
workers
[
wId
].
join
();
}
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
// for (int planeIndex = 0; planeIndex < dims.getZ(); planeIndex++) {
// try {
// originalPlane = RawDataIO.loadImageU16(referenceFile, dims, planeIndex);
// compressedPlane = RawDataIO.loadImageU16(compressedFile, dims, planeIndex);
// } catch (IOException e) {
// e.printStackTrace();
// return true;
// }
//
//
// final int[] diffData = Utils.getDifference(originalPlane.getData(), compressedPlane.getData());
// Utils.applyAbsFunction(diffData);
//
//
// final double absDiffSum = Arrays.stream(diffData).mapToDouble(v -> v).sum();
// final double meanPixelError = absDiffSum / (double) planePixelCount;
//
// planeErrors[planeIndex] = new PlaneError(planeIndex, absDiffSum, meanPixelError);
// // System.out.println("Finished plane: " + planeIndex);
// }
try
(
FileOutputStream
fos
=
new
FileOutputStream
(
reportFile
,
false
);
try
(
FileOutputStream
fos
=
new
FileOutputStream
(
reportFile
,
false
);
OutputStreamWriter
writer
=
new
OutputStreamWriter
(
fos
))
{
OutputStreamWriter
writer
=
new
OutputStreamWriter
(
fos
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment