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
376340ec
Commit
376340ec
authored
4 years ago
by
Vojtech Moravec
Browse files
Options
Downloads
Patches
Plain Diff
Add reconstruct overload in Voxel.
The new overload can reconstruct single voxel array from many voxels.
parent
1cd3087b
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/data/Voxel.java
+54
-1
54 additions, 1 deletion
src/main/java/azgracompress/data/Voxel.java
with
54 additions
and
1 deletion
src/main/java/azgracompress/data/Voxel.java
+
54
−
1
View file @
376340ec
package
azgracompress.data
;
package
azgracompress.data
;
@SuppressWarnings
(
"DuplicatedCode"
)
public
final
class
Voxel
{
public
final
class
Voxel
{
/**
/**
* Voxel dimensions.
* Voxel dimensions.
...
@@ -69,7 +70,7 @@ public final class Voxel {
...
@@ -69,7 +70,7 @@ public final class Voxel {
* @param voxelData Voxel data.
* @param voxelData Voxel data.
* @return Dataset reconstructed from the voxel data.
* @return Dataset reconstructed from the voxel data.
*/
*/
public
ImageU16Dataset
reconstructFromVoxels
(
final
V3i
voxelDims
,
final
int
[][]
voxelData
)
{
public
ImageU16Dataset
reconstructFromVoxels
ToDataset
(
final
V3i
voxelDims
,
final
int
[][]
voxelData
)
{
final
short
[][]
reconstructedData
=
new
short
[
dims
.
getZ
()][
dims
.
toV2i
().
multiplyTogether
()];
final
short
[][]
reconstructedData
=
new
short
[
dims
.
getZ
()][
dims
.
toV2i
().
multiplyTogether
()];
final
int
xVoxelCount
=
(
int
)
Math
.
ceil
((
double
)
dims
.
getX
()
/
(
double
)
voxelDims
.
getX
());
final
int
xVoxelCount
=
(
int
)
Math
.
ceil
((
double
)
dims
.
getX
()
/
(
double
)
voxelDims
.
getX
());
...
@@ -121,4 +122,56 @@ public final class Voxel {
...
@@ -121,4 +122,56 @@ public final class Voxel {
return
new
ImageU16Dataset
(
dims
.
toV2i
(),
dims
.
getZ
(),
reconstructedData
);
return
new
ImageU16Dataset
(
dims
.
toV2i
(),
dims
.
getZ
(),
reconstructedData
);
}
}
public
short
[]
reconstructFromVoxelsToVoxelArray
(
final
V3i
voxelDims
,
final
int
[][]
voxelData
)
{
final
short
[]
reconstructedVoxel
=
new
short
[(
int
)
dims
.
multiplyTogether
()];
final
int
xVoxelCount
=
(
int
)
Math
.
ceil
((
double
)
dims
.
getX
()
/
(
double
)
voxelDims
.
getX
());
final
int
yVoxelCount
=
(
int
)
Math
.
ceil
((
double
)
dims
.
getY
()
/
(
double
)
voxelDims
.
getY
());
final
int
planeVoxelCount
=
xVoxelCount
*
yVoxelCount
;
final
int
planeDimX
=
dims
.
getX
();
final
int
planeDimY
=
dims
.
getY
();
final
int
voxelDimX
=
voxelDims
.
getX
();
final
int
voxelDimY
=
voxelDims
.
getY
();
final
int
voxelDimZ
=
voxelDims
.
getZ
();
int
voxelOffset
=
0
;
for
(
int
planeOffset
=
0
;
planeOffset
<
dims
.
getZ
();
planeOffset
+=
voxelDimZ
)
{
for
(
int
voxelZ
=
0
;
voxelZ
<
voxelDimZ
;
voxelZ
++)
{
final
int
planeIndex
=
planeOffset
+
voxelZ
;
if
(
planeIndex
>=
dims
.
getZ
())
break
;
for
(
int
voxelIndex
=
0
;
voxelIndex
<
planeVoxelCount
;
voxelIndex
++)
{
for
(
int
voxelY
=
0
;
voxelY
<
voxelDimY
;
voxelY
++)
{
final
int
dstY
=
((
voxelIndex
/
xVoxelCount
)
*
voxelDimY
)
+
voxelY
;
if
(
dstY
>=
planeDimY
)
{
break
;
}
for
(
int
voxelX
=
0
;
voxelX
<
voxelDimX
;
voxelX
++)
{
final
int
dstX
=
((
voxelIndex
%
xVoxelCount
)
*
voxelDimX
)
+
voxelX
;
if
(
dstX
>=
planeDimX
)
{
break
;
}
final
int
indexInsideVoxel
=
dataIndex
(
voxelX
,
voxelY
,
voxelZ
,
voxelDims
);
final
int
dstIndex
=
dataIndex
(
dstX
,
dstY
,
planeIndex
);
if
(
dstIndex
>=
reconstructedVoxel
.
length
)
{
System
.
out
.
printf
(
"Fail\n"
);
}
reconstructedVoxel
[
dstIndex
]
=
(
short
)
voxelData
[(
voxelOffset
+
voxelIndex
)][
indexInsideVoxel
];
}
}
}
}
voxelOffset
+=
planeVoxelCount
;
}
return
reconstructedVoxel
;
}
}
}
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