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
f737688b
Commit
f737688b
authored
5 years ago
by
Vojtech Moravec
Browse files
Options
Downloads
Patches
Plain Diff
Basic CLI interface for compression and decompression of images.
parent
2976e361
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
DataCompressor.iml
+1
-0
1 addition, 0 deletions
DataCompressor.iml
pom.xml
+5
-0
5 additions, 0 deletions
pom.xml
src/main/java/DataCompressor.java
+63
-74
63 additions, 74 deletions
src/main/java/DataCompressor.java
src/main/java/META-INF/MANIFEST.MF
+3
-0
3 additions, 0 deletions
src/main/java/META-INF/MANIFEST.MF
with
72 additions
and
74 deletions
DataCompressor.iml
+
1
−
0
View file @
f737688b
...
...
@@ -13,6 +13,7 @@
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.commons:commons-math3:3.6.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: commons-io:commons-io:1.3.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: commons-cli:commons-cli:1.4"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.jetbrains:annotations:18.0.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.google.code.gson:gson:2.8.6"
level=
"project"
/>
</component>
...
...
This diff is collapsed.
Click to expand it.
pom.xml
+
5
−
0
View file @
f737688b
...
...
@@ -34,6 +34,11 @@
<artifactId>
commons-io
</artifactId>
<version>
1.3.2
</version>
</dependency>
<dependency>
<groupId>
commons-cli
</groupId>
<artifactId>
commons-cli
</artifactId>
<version>
1.4
</version>
</dependency>
<dependency>
<groupId>
org.jetbrains
</groupId>
<artifactId>
annotations
</artifactId>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/DataCompressor.java
+
63
−
74
View file @
f737688b
import
compression.benchmark.ScalarQuantizationBenchmark
;
import
compression.benchmark.VectorQuantizationBenchmark
;
import
compression.data.*
;
import
org.apache.commons.cli.*
;
import
java.io.IOException
;
import
java.util.Random
;
public
class
DataCompressor
{
private
static
final
String
COMPRESS_SHORT
=
"c"
;
private
static
final
String
COMPRESS_LONG
=
"compress"
;
private
static
final
String
DECOMPRESS_SHORT
=
"d"
;
private
static
final
String
DECOMPRESS_LONG
=
"decompress"
;
private
static
final
String
BITS_SHORT
=
"b"
;
private
static
final
String
BITS_LONG
=
"bits"
;
private
static
final
String
INPUT_SHORT
=
"i"
;
private
static
final
String
INPUT_LONG
=
"input"
;
private
static
final
String
OUTPUT_SHORT
=
"o"
;
private
static
final
String
OUTPUT_LONG
=
"output"
;
public
static
void
main
(
String
[]
args
)
throws
IOException
{
// test2DChunking();
// test3DChunking();
// test2DVectorChunking();
//
if
(
false
)
{
new
ScalarQuantizationBenchmark
(
"D:\\biology\\tiff_data\\benchmark\\fused_tp_10_ch_0_16bit.raw"
,
"D:\\biology\\benchmark\\fused_tp_10_ch_0_16bit\\scalar"
,
new
int
[]{
351
},
new
V3i
(
1041
,
996
,
946
)).
startBenchmark
();
}
else
{
VectorQuantizationBenchmark
vqBench
=
new
VectorQuantizationBenchmark
(
"D:\\biology\\tiff_data\\benchmark\\fused_tp_10_ch_0_16bit.raw"
,
"D:\\biology\\benchmark\\fused_tp_10_ch_0_16bit\\vector3x3"
,
new
int
[]{
351
},
new
V3i
(
1041
,
996
,
946
));
vqBench
.
startBenchmark
(
new
V2i
(
3
,
3
));
}
}
Options
options
=
new
Options
();
static
void
test2DVectorChunking
()
{
final
int
xs
=
761
;
final
int
ys
=
438
;
final
int
[]
data
=
getRandomData
(
xs
*
ys
);
final
Chunk2D
src
=
new
Chunk2D
(
new
V2i
(
xs
,
ys
),
new
V2l
(
0
),
data
);
final
int
[][]
vectors
=
src
.
divideInto1DVectors
(
3
);
OptionGroup
methodGroup
=
new
OptionGroup
();
final
Chunk2D
reconstructed
=
new
Chunk2D
(
new
V2i
(
xs
,
ys
),
new
V2l
(
0
));
reconstructed
.
reconstructFromVectors
(
vectors
);
methodGroup
.
setRequired
(
true
);
methodGroup
.
addOption
(
new
Option
(
COMPRESS_SHORT
,
COMPRESS_LONG
,
false
,
"Compress 16 bit raw image"
));
methodGroup
.
addOption
(
new
Option
(
DECOMPRESS_SHORT
,
DECOMPRESS_LONG
,
false
,
"Decompress 16 bit raw image"
));
methodGroup
.
addOption
(
new
Option
(
"h"
,
"help"
,
false
,
"Print help"
));
if
(
src
.
equals
(
reconstructed
))
{
System
.
out
.
println
(
"2D vector Reconstruction successful."
);
}
else
{
System
.
out
.
println
(
"2D vector Reconstruction failed !!!"
);
}
}
options
.
addOptionGroup
(
methodGroup
);
options
.
addOption
(
BITS_SHORT
,
BITS_LONG
,
true
,
"Bit count per pixel [Default 8]"
);
options
.
addRequiredOption
(
INPUT_SHORT
,
INPUT_LONG
,
true
,
"Input file"
);
options
.
addRequiredOption
(
OUTPUT_SHORT
,
OUTPUT_LONG
,
true
,
"Output file"
);
static
void
test2DChunking
()
{
final
int
xs
=
1920
;
final
int
ys
=
1080
;
final
int
[]
data
=
getRandomData
(
xs
*
ys
);
final
Chunk2D
src
=
new
Chunk2D
(
new
V2i
(
xs
,
ys
),
new
V2l
(
0
),
data
);
final
Chunk2D
[]
chunks
=
src
.
divideIntoChunks
(
new
V2i
(
3
));
HelpFormatter
formatter
=
new
HelpFormatter
();
final
Chunk2D
reconstructed
=
new
Chunk2D
(
new
V2i
(
xs
,
ys
),
new
V2l
(
0
));
reconstructed
.
reconstructFromChunks
(
chunks
);
if
(
src
.
equals
(
reconstructed
))
{
System
.
out
.
println
(
"2D Reconstruction successful."
);
}
else
{
System
.
out
.
println
(
"2D Reconstruction failed !!!"
);
CommandLineParser
parser
=
new
DefaultParser
();
CommandLine
cmd
;
try
{
cmd
=
parser
.
parse
(
options
,
args
);
}
catch
(
ParseException
e
)
{
if
(
args
[
0
].
equals
(
"-h"
)
||
args
[
0
].
equals
(
"--help"
))
{
formatter
.
printHelp
(
"ijava -jar DataCompressor.jar"
,
options
);
return
;
}
System
.
err
.
println
(
"Error: "
+
e
.
getMessage
());
return
;
}
}
static
void
test3DChunking
()
{
//Chunk3D[] loadedChunks = ChunkIO.loadChunks("D:\\tmp\\server-dump\\chunks.bin");
final
int
xs
=
11
;
final
int
ys
=
16
;
final
int
zs
=
16
;
final
int
[]
data
=
getRandomData
(
xs
*
ys
*
zs
);
final
Chunk3D
src
=
new
Chunk3D
(
new
V3i
(
xs
,
ys
,
zs
),
new
V3l
(
0
),
data
);
final
Chunk3D
[]
chunks
=
src
.
divideIntoChunks
(
new
V3i
(
4
));
final
Chunk3D
reconstructed
=
new
Chunk3D
(
new
V3i
(
xs
,
ys
,
zs
),
new
V3l
(
0
));
reconstructed
.
reconstructFromChunks
(
chunks
);
if
(
src
.
equals
(
reconstructed
))
{
System
.
out
.
println
(
"3D Reconstruction successful."
);
}
else
{
System
.
out
.
println
(
"3D Reconstruction failed !!!"
);
if
(
cmd
.
hasOption
(
"help"
))
{
formatter
.
printHelp
(
"ijava -jar DataCompressor.jar"
,
options
);
return
;
}
}
static
int
[]
getRandomData
(
int
len
)
{
Random
r
=
new
Random
();
int
[]
data
=
new
int
[
len
];
for
(
int
i
=
0
;
i
<
data
.
length
;
i
++)
{
data
[
i
]
=
r
.
nextInt
(
20000
);
final
String
bitsString
=
cmd
.
getOptionValue
(
BITS_LONG
,
"8"
);
final
int
bits
=
Integer
.
parseInt
(
bitsString
);
if
(
cmd
.
hasOption
(
COMPRESS_SHORT
)
||
cmd
.
hasOption
(
COMPRESS_LONG
))
{
System
.
out
.
println
(
String
.
format
(
"Compressing %s with %d bits, saving to %s"
,
cmd
.
getOptionValue
(
INPUT_SHORT
),
bits
,
cmd
.
getOptionValue
(
OUTPUT_SHORT
)));
// TODO(Moravec): Do compression here.
return
;
}
return
data
;
if
(
cmd
.
hasOption
(
DECOMPRESS_SHORT
)
||
cmd
.
hasOption
(
DECOMPRESS_LONG
))
{
System
.
out
.
println
(
String
.
format
(
"Decompressing %s with %d bits, saving to %s"
,
cmd
.
getOptionValue
(
INPUT_SHORT
),
bits
,
cmd
.
getOptionValue
(
OUTPUT_SHORT
)));
// TODO(Moravec): Do decompression here.
return
;
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/META-INF/MANIFEST.MF
0 → 100644
+
3
−
0
View file @
f737688b
Manifest-Version: 1.0
Main-Class: DataCompressor
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