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
388810b4
Commit
388810b4
authored
4 years ago
by
Vojtech Moravec
Browse files
Options
Downloads
Patches
Plain Diff
Wrap quantizeIntoIndices call.
This allow us to set usage of KDTree lookup.
parent
c891f3eb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/cz/it4i/qcmp/compression/ImageCompressor.java
+13
-0
13 additions, 0 deletions
src/main/java/cz/it4i/qcmp/compression/ImageCompressor.java
src/main/java/cz/it4i/qcmp/compression/VQImageCompressor.java
+27
-6
27 additions, 6 deletions
...main/java/cz/it4i/qcmp/compression/VQImageCompressor.java
with
40 additions
and
6 deletions
src/main/java/cz/it4i/qcmp/compression/ImageCompressor.java
+
13
−
0
View file @
388810b4
...
...
@@ -197,6 +197,19 @@ public class ImageCompressor extends CompressorDecompressorBase {
}
}
/**
* Allow usage of the KD tree when looking for the best quantization vector.
*
* @return True if imageCompressor is VQImageCompressor and KD tree was enabled.
*/
public
boolean
allowKdTreeVectorLookup
()
{
if
((
imageCompressor
!=
null
)
&&
(
imageCompressor
instanceof
VQImageCompressor
))
{
((
VQImageCompressor
)
imageCompressor
).
setUseKdTree
(
true
);
return
true
;
}
return
false
;
}
/**
* Create QCMPFile header for compressed file.
...
...
This diff is collapsed.
Click to expand it.
src/main/java/cz/it4i/qcmp/compression/VQImageCompressor.java
+
27
−
6
View file @
388810b4
...
...
@@ -26,6 +26,8 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
private
VectorQuantizer
cachedQuantizer
=
null
;
private
Huffman
cachedHuffman
=
null
;
private
boolean
useKdTree
=
false
;
public
VQImageCompressor
(
final
CompressionOptions
options
)
{
super
(
options
);
}
...
...
@@ -37,6 +39,14 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
cachedHuffman
=
createHuffmanCoder
(
createHuffmanSymbols
(
cachedCodebook
.
getCodebookSize
()),
cachedCodebook
.
getVectorFrequencies
());
}
public
boolean
shouldUseKdTree
()
{
return
useKdTree
;
}
public
void
setUseKdTree
(
final
boolean
useKdTree
)
{
this
.
useKdTree
=
useKdTree
;
}
/**
* Train vector quantizer from plane vectors.
*
...
...
@@ -200,10 +210,7 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
writeQuantizerToCompressStream
(
quantizer
,
compressStream
);
}
// Use BestBinFirst KDTree for codebook lookup.
// final int[] indices = quantizer.quantizeIntoIndicesUsingKDTree(planeVectors, options.getWorkerCount());
// Use BruteForce for codebook lookup.
final
int
[]
indices
=
quantizer
.
quantizeIntoIndices
(
planeVectors
,
options
.
getWorkerCount
());
final
int
[]
indices
=
quantizeVectorsImpl
(
quantizer
,
planeVectors
,
options
.
getWorkerCount
());
planeDataSizes
[
planeCounter
++]
=
writeHuffmanEncodedIndices
(
compressStream
,
huffman
,
indices
);
...
...
@@ -219,6 +226,20 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
return
planeDataSizes
;
}
/**
* Quantize into indices call wrapper for KDTree switch.
*
* @param quantizer Vector quantizer.
* @param srcVectors Vectors to quantize.
* @param workerCount Maximum number of worker threads.
* @return Indices of codebook vectors.
*/
private
int
[]
quantizeVectorsImpl
(
final
VectorQuantizer
quantizer
,
final
int
[][]
srcVectors
,
final
int
workerCount
)
{
if
(
useKdTree
)
return
quantizer
.
quantizeIntoIndicesUsingKDTree
(
srcVectors
,
workerCount
);
return
quantizer
.
quantizeIntoIndices
(
srcVectors
,
workerCount
);
}
/**
* Calculate the number of voxel layers needed for dataset of plane count.
*
...
...
@@ -284,8 +305,8 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
throw
new
ImageCompressionException
(
"Unable to load voxels from voxel layer "
+
voxelLayerRange
,
e
);
}
final
int
[]
indices
=
quantize
r
.
quantizeIntoIndices
(
voxelData
,
options
.
getWorkerCount
());
// final int[] indices = quantizer.quantizeIntoIndicesUsingKDTree(voxelData, options.getWorkerCount());
final
int
[]
indices
=
quantize
VectorsImpl
(
quantizer
,
voxelData
,
options
.
getWorkerCount
());
voxelLayersSizes
[
voxelLayerIndex
]
=
writeHuffmanEncodedIndices
(
compressStream
,
huffman
,
indices
);
stopwatch
.
stop
();
if
(
options
.
isConsoleApplication
())
{
...
...
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