Skip to content
Snippets Groups Projects
Commit dc7978ff authored by Vojtech Moravec's avatar Vojtech Moravec
Browse files

Deprecated reference plane index in favor of middle plane.

parent cf76dd71
No related branches found
No related tags found
No related merge requests found
Showing
with 82 additions and 101 deletions
...@@ -13,7 +13,7 @@ usage: azgracompress.DataCompressor [options] input ...@@ -13,7 +13,7 @@ usage: azgracompress.DataCompressor [options] input
-h,--help Print help -h,--help Print help
-i,--inspect Inspect the compressed file -i,--inspect Inspect the compressed file
-o,--output <arg> Custom output file -o,--output <arg> Custom output file
-rp,--reference-plane <arg> Reference plane index -mp,--middle-plane Use middle plane for codebook training.
-sq,--scalar-quantization Use scalar quantization. -sq,--scalar-quantization Use scalar quantization.
-tcb,--train-codebook Train codebook and save learned -tcb,--train-codebook Train codebook and save learned
codebook to cache file. codebook to cache file.
...@@ -39,9 +39,9 @@ usage: azgracompress.DataCompressor [options] input ...@@ -39,9 +39,9 @@ usage: azgracompress.DataCompressor [options] input
- QT is required - QT is required
- Set the bits per pixel using `-b` or `--bits` and integer value from 1 to 8. Codebook size is equal to (*2^bits*). - Set the bits per pixel using `-b` or `--bits` and integer value from 1 to 8. Codebook size is equal to (*2^bits*).
- Normally the codebook is created for each image plane separately, if one wants to use general codebook for all planes, these are the options: - Normally the codebook is created for each image plane separately, if one wants to use general codebook for all planes, these are the options:
- Set the reference plane index using `-rp` or `--reference-plane`. Reference plane is used to create codebook for all planes. - Set the middle plane index using `-mp` or `--middle-plane`. Middle plane is used to create codebook for all planes.
- Set the cache folder by `cbc` or `--codebook-cache`, quantizer will look for cached codebook of given file and codebook size. - Set the cache folder by `cbc` or `--codebook-cache`, quantizer will look for cached codebook of given file and codebook size.
- For input file info seee Input File section - For input file info see Input File section
### Decompress ### Decompress
- Use with `-d` or `--decompress` - Use with `-d` or `--decompress`
...@@ -50,7 +50,7 @@ usage: azgracompress.DataCompressor [options] input ...@@ -50,7 +50,7 @@ usage: azgracompress.DataCompressor [options] input
### Inspect ### Inspect
- Use with `-i` or `--inspect` - Use with `-i` or `--inspect`
- Inspect the compressed file. Read compressed file header are write the informations from that header. - Inspect the compressed file. Read compressed file header are write the information from that header.
### Train codebook ### Train codebook
- Use with `-tcb` or `--train-codebook` - Use with `-tcb` or `--train-codebook`
......
...@@ -23,8 +23,7 @@ abstract class BenchmarkBase { ...@@ -23,8 +23,7 @@ abstract class BenchmarkBase {
protected final int[] planes; protected final int[] planes;
protected final V3i rawImageDims; protected final V3i rawImageDims;
protected final boolean hasReferencePlane; protected final boolean useMiddlePlane;
protected final int referencePlaneIndex;
protected final int codebookSize; protected final int codebookSize;
protected final boolean hasCacheFolder; protected final boolean hasCacheFolder;
protected final String cacheFolder; protected final String cacheFolder;
...@@ -41,8 +40,7 @@ abstract class BenchmarkBase { ...@@ -41,8 +40,7 @@ abstract class BenchmarkBase {
this.planes = planes; this.planes = planes;
this.rawImageDims = rawImageDims; this.rawImageDims = rawImageDims;
hasReferencePlane = false; useMiddlePlane = false;
referencePlaneIndex = -1;
codebookSize = 256; codebookSize = 256;
hasCacheFolder = false; hasCacheFolder = false;
...@@ -56,8 +54,7 @@ abstract class BenchmarkBase { ...@@ -56,8 +54,7 @@ abstract class BenchmarkBase {
this.inputFile = options.getInputFile(); this.inputFile = options.getInputFile();
this.outputDirectory = options.getOutputFile(); this.outputDirectory = options.getOutputFile();
this.rawImageDims = options.getImageDimension(); this.rawImageDims = options.getImageDimension();
this.hasReferencePlane = options.hasReferencePlaneIndex(); this.useMiddlePlane = options.shouldUseMiddlePlane();
this.referencePlaneIndex = options.getReferencePlaneIndex();
this.codebookSize = (int) Math.pow(2, options.getBitsPerPixel()); this.codebookSize = (int) Math.pow(2, options.getBitsPerPixel());
if (options.hasPlaneIndexSet()) { if (options.hasPlaneIndexSet()) {
...@@ -81,7 +78,7 @@ abstract class BenchmarkBase { ...@@ -81,7 +78,7 @@ abstract class BenchmarkBase {
hasCacheFolder = options.hasCodebookCacheFolder(); hasCacheFolder = options.hasCodebookCacheFolder();
cacheFolder = options.getCodebookCacheFolder(); cacheFolder = options.getCodebookCacheFolder();
hasGeneralQuantizer = hasReferencePlane || hasCacheFolder; hasGeneralQuantizer = useMiddlePlane || hasCacheFolder;
workerCount = options.getWorkerCount(); workerCount = options.getWorkerCount();
} }
......
...@@ -49,19 +49,20 @@ public class ScalarQuantizationBenchmark extends BenchmarkBase { ...@@ -49,19 +49,20 @@ public class ScalarQuantizationBenchmark extends BenchmarkBase {
return; return;
} }
System.out.println("Created quantizer from cache"); System.out.println("Created quantizer from cache");
} else if (hasReferencePlane) { } else if (useMiddlePlane) {
final int[] refPlaneData = loadPlaneData(referencePlaneIndex); final int middlePlaneIndex = rawImageDims.getZ() / 2;
if (refPlaneData.length == 0) { final int[] middlePlaneData = loadPlaneData(middlePlaneIndex);
System.err.println("Failed to load reference plane data."); if (middlePlaneData.length == 0) {
System.err.println("Failed to load middle plane data.");
return; return;
} }
if (useDiffEvolution) { if (useDiffEvolution) {
assert (false) : "DE is depracated"; assert (false) : "DE is depracated";
quantizer = null; quantizer = null;
} else { } else {
quantizer = trainLloydMaxQuantizer(refPlaneData, codebookSize); quantizer = trainLloydMaxQuantizer(middlePlaneData, codebookSize);
} }
System.out.println("Created reference quantizer."); System.out.println("Created quantizer from middle plane.");
} }
for (final int planeIndex : planes) { for (final int planeIndex : planes) {
......
...@@ -76,19 +76,20 @@ public class VectorQuantizationBenchmark extends BenchmarkBase { ...@@ -76,19 +76,20 @@ public class VectorQuantizationBenchmark extends BenchmarkBase {
return; return;
} }
System.out.println("Created quantizer from cache"); System.out.println("Created quantizer from cache");
} else if (hasReferencePlane) { } else if (useMiddlePlane) {
final ImageU16 plane = loadPlane(referencePlaneIndex); final int middlePlaneIndex = rawImageDims.getZ() / 2;
final ImageU16 middlePlane = loadPlane(middlePlaneIndex);
if (plane == null) { if (middlePlane == null) {
System.err.println("Failed to load reference plane data."); System.err.println("Failed to load middle plane data.");
return; return;
} }
final int[][] refPlaneData = getPlaneVectors(plane, qVector); final int[][] refPlaneData = getPlaneVectors(middlePlane, qVector);
LBGVectorQuantizer vqInitializer = new LBGVectorQuantizer(refPlaneData, codebookSize, workerCount); LBGVectorQuantizer vqInitializer = new LBGVectorQuantizer(refPlaneData, codebookSize, workerCount);
final LBGResult vqResult = vqInitializer.findOptimalCodebook(); final LBGResult vqResult = vqInitializer.findOptimalCodebook();
quantizer = new VectorQuantizer(vqResult.getCodebook()); quantizer = new VectorQuantizer(vqResult.getCodebook());
System.out.println("Created reference quantizer."); System.out.println("Created quantizer from middle plane.");
} }
for (final int planeIndex : planes) { for (final int planeIndex : planes) {
......
...@@ -51,8 +51,8 @@ public class CliConstants { ...@@ -51,8 +51,8 @@ public class CliConstants {
public static final String VECTOR_QUANTIZATION_SHORT = "vq"; public static final String VECTOR_QUANTIZATION_SHORT = "vq";
public static final String VECTOR_QUANTIZATION_LONG = "vector-quantization"; public static final String VECTOR_QUANTIZATION_LONG = "vector-quantization";
public static final String REFERENCE_PLANE_SHORT = "rp"; public static final String USE_MIDDLE_PLANE_SHORT = "md";
public static final String REFERENCE_PLANE_LONG = "reference-plane"; public static final String USE_MIDDLE_PLANE_LONG = "middle-plane";
@NotNull @NotNull
public static Options getOptions() { public static Options getOptions() {
...@@ -105,10 +105,10 @@ public class CliConstants { ...@@ -105,10 +105,10 @@ public class CliConstants {
options.addOptionGroup(compressionMethodGroup); options.addOptionGroup(compressionMethodGroup);
options.addOption(CliConstants.BITS_SHORT, CliConstants.BITS_LONG, true, "Bit count per pixel [Default 8]"); options.addOption(CliConstants.BITS_SHORT, CliConstants.BITS_LONG, true, "Bit count per pixel [Default 8]");
options.addOption(CliConstants.REFERENCE_PLANE_SHORT, options.addOption(CliConstants.USE_MIDDLE_PLANE_SHORT,
CliConstants.REFERENCE_PLANE_LONG, CliConstants.USE_MIDDLE_PLANE_LONG,
true, false,
"Reference plane index"); "Use middle plane for codebook creation");
options.addOption(new Option(CliConstants.VERBOSE_SHORT, options.addOption(new Option(CliConstants.VERBOSE_SHORT,
CliConstants.VERBOSE_LONG, CliConstants.VERBOSE_LONG,
......
...@@ -27,8 +27,7 @@ public class ParsedCliOptions { ...@@ -27,8 +27,7 @@ public class ParsedCliOptions {
private boolean planeIndexSet = false; private boolean planeIndexSet = false;
private int planeIndex; private int planeIndex;
private boolean refPlaneIndexSet = false; private boolean useMiddlePlane = false;
private int referencePlaneIndex = -1;
private boolean verbose; private boolean verbose;
...@@ -93,7 +92,7 @@ public class ParsedCliOptions { ...@@ -93,7 +92,7 @@ public class ParsedCliOptions {
parseBitsPerPixel(cmd, errorBuilder); parseBitsPerPixel(cmd, errorBuilder);
parseReferencePlaneIndex(cmd, errorBuilder); useMiddlePlane = cmd.hasOption(CliConstants.USE_MIDDLE_PLANE_LONG);
final String[] fileInfo = cmd.getArgs(); final String[] fileInfo = cmd.getArgs();
parseInputFilePart(errorBuilder, fileInfo); parseInputFilePart(errorBuilder, fileInfo);
...@@ -219,23 +218,6 @@ public class ParsedCliOptions { ...@@ -219,23 +218,6 @@ public class ParsedCliOptions {
} }
private void parseReferencePlaneIndex(CommandLine cmd, StringBuilder errorBuilder) {
if (cmd.hasOption(CliConstants.REFERENCE_PLANE_LONG)) {
final String rpString = cmd.getOptionValue(CliConstants.REFERENCE_PLANE_LONG);
final ParseResult<Integer> parseResult = tryParseInt(rpString);
if (parseResult.isSuccess()) {
referencePlaneIndex = parseResult.getValue();
refPlaneIndexSet = true;
} else {
errorOccurred = true;
errorBuilder.append("Failed to parse reference plane index").append('\n');
errorBuilder.append(parseResult.getErrorMessage()).append('\n');
}
} else {
refPlaneIndexSet = false;
}
}
private void parseBitsPerPixel(CommandLine cmd, StringBuilder errorBuilder) { private void parseBitsPerPixel(CommandLine cmd, StringBuilder errorBuilder) {
if (cmd.hasOption(CliConstants.BITS_LONG)) { if (cmd.hasOption(CliConstants.BITS_LONG)) {
final String bitsString = cmd.getOptionValue(CliConstants.BITS_LONG); final String bitsString = cmd.getOptionValue(CliConstants.BITS_LONG);
...@@ -375,16 +357,12 @@ public class ParsedCliOptions { ...@@ -375,16 +357,12 @@ public class ParsedCliOptions {
return planeIndex; return planeIndex;
} }
public int getReferencePlaneIndex() {
return referencePlaneIndex;
}
public boolean isVerbose() { public boolean isVerbose() {
return verbose; return verbose;
} }
public boolean hasReferencePlaneIndex() { public boolean shouldUseMiddlePlane() {
return refPlaneIndexSet; return useMiddlePlane;
} }
public boolean hasPlaneIndexSet() { public boolean hasPlaneIndexSet() {
...@@ -482,8 +460,8 @@ public class ParsedCliOptions { ...@@ -482,8 +460,8 @@ public class ParsedCliOptions {
if (planeIndexSet) { if (planeIndexSet) {
sb.append("PlaneIndex: ").append(planeIndex).append('\n'); sb.append("PlaneIndex: ").append(planeIndex).append('\n');
} }
if (refPlaneIndexSet) { if (useMiddlePlane) {
sb.append("ReferencePlaneIndex: ").append(referencePlaneIndex).append('\n'); sb.append("Use middle plane for codebook training\n");
} }
if (planeRangeSet) { if (planeRangeSet) {
sb.append("FromPlaneIndex: ").append(fromPlaneIndex).append('\n'); sb.append("FromPlaneIndex: ").append(fromPlaneIndex).append('\n');
......
...@@ -122,9 +122,6 @@ public class MeasurePlaneErrorFunction extends CustomFunctionBase { ...@@ -122,9 +122,6 @@ public class MeasurePlaneErrorFunction extends CustomFunctionBase {
final int workerCount = 8; 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();
// ImageU16 compressedPlane = null;
// ImageU16 originalPlane = null;
// ImageU16 differencePlane = null;
PlaneError[] planeErrors = new PlaneError[dims.getZ()]; PlaneError[] planeErrors = new PlaneError[dims.getZ()];
......
...@@ -70,4 +70,12 @@ public abstract class CompressorDecompressorBase { ...@@ -70,4 +70,12 @@ public abstract class CompressorDecompressorBase {
System.err.println(message); System.err.println(message);
} }
} }
/**
* Get index of the middle plane.
* @return Index of the middle plane.
*/
protected int getMiddlePlaneIndex() {
return (options.getImageDimension().getZ() / 2);
}
} }
...@@ -128,8 +128,8 @@ public class ImageCompressor extends CompressorDecompressorBase { ...@@ -128,8 +128,8 @@ public class ImageCompressor extends CompressorDecompressorBase {
header.setQuantizationType(options.getQuantizationType()); header.setQuantizationType(options.getQuantizationType());
header.setBitsPerPixel((byte) options.getBitsPerPixel()); header.setBitsPerPixel((byte) options.getBitsPerPixel());
// Codebook per plane is used only if reference plane isn't set nor is the cache folder. // Codebook per plane is used only if middle plane isn't set nor is the cache folder.
final boolean oneCodebook = options.hasReferencePlaneIndex() || options.hasCodebookCacheFolder(); final boolean oneCodebook = options.shouldUseMiddlePlane() || options.hasCodebookCacheFolder();
header.setCodebookPerPlane(!oneCodebook); header.setCodebookPerPlane(!oneCodebook);
header.setImageSizeX(options.getImageDimension().getX()); header.setImageSizeX(options.getImageDimension().getX());
......
...@@ -90,9 +90,7 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -90,9 +90,7 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
*/ */
public long[] compress(DataOutputStream compressStream) throws ImageCompressionException { public long[] compress(DataOutputStream compressStream) throws ImageCompressionException {
Stopwatch stopwatch = new Stopwatch(); Stopwatch stopwatch = new Stopwatch();
final boolean hasGeneralQuantizer = options.hasCodebookCacheFolder() || options.shouldUseMiddlePlane();
final boolean hasGeneralQuantizer = options.hasCodebookCacheFolder() || options.hasReferencePlaneIndex();
ScalarQuantizer quantizer = null; ScalarQuantizer quantizer = null;
Huffman huffman = null; Huffman huffman = null;
final int[] huffmanSymbols = createHuffmanSymbols(); final int[] huffmanSymbols = createHuffmanSymbols();
...@@ -102,27 +100,27 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -102,27 +100,27 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
quantizer = loadQuantizerFromCache(); quantizer = loadQuantizerFromCache();
Log("Cached quantizer created."); Log("Cached quantizer created.");
writeCodebookToOutputStream(quantizer, compressStream); writeCodebookToOutputStream(quantizer, compressStream);
} else if (options.hasReferencePlaneIndex()) { } else if (options.shouldUseMiddlePlane()) {
// TODO(Moravec): Reference plane will be deprecated in favor of 'middle' plane.
stopwatch.restart(); stopwatch.restart();
ImageU16 referencePlane = null; ImageU16 middlePlane = null;
final int middlePlaneIndex = getMiddlePlaneIndex();
try { try {
referencePlane = RawDataIO.loadImageU16(options.getInputFile(), middlePlane = RawDataIO.loadImageU16(options.getInputFile(),
options.getImageDimension(), options.getImageDimension(),
options.getReferencePlaneIndex()); getMiddlePlaneIndex());
// TODO(Moravec): Create huffman. // TODO(Moravec): Create huffman.
} catch (Exception ex) { } catch (Exception ex) {
throw new ImageCompressionException("Unable to load reference plane data.", ex); throw new ImageCompressionException("Unable to load plane data.", ex);
} }
Log(String.format("Training scalar quantizer from reference plane %d.", options.getReferencePlaneIndex())); Log(String.format("Training scalar quantizer from middle plane %d.", middlePlaneIndex));
quantizer = trainScalarQuantizerFromData(referencePlane.getData()); quantizer = trainScalarQuantizerFromData(middlePlane.getData());
stopwatch.stop(); stopwatch.stop();
writeCodebookToOutputStream(quantizer, compressStream); writeCodebookToOutputStream(quantizer, compressStream);
Log("Reference codebook created in: " + stopwatch.getElapsedTimeString()); Log("Middle plane codebook created in: " + stopwatch.getElapsedTimeString());
} }
final int[] planeIndices = getPlaneIndicesForCompression(); final int[] planeIndices = getPlaneIndicesForCompression();
...@@ -157,19 +155,19 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -157,19 +155,19 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
Log("Compressing plane..."); Log("Compressing plane...");
final int[] indices = quantizer.quantizeIntoIndices(plane.getData(), 1); final int[] indices = quantizer.quantizeIntoIndices(plane.getData(), 1);
// //////////////////////// // ////////////////////////
// for (int i = 0; i < indices.length; i++) { // for (int i = 0; i < indices.length; i++) {
// final boolean[] huffmanCode = huffman.getCode(indices[i]); // final boolean[] huffmanCode = huffman.getCode(indices[i]);
// HuffmanNode currentHuffmanNode = huffman.getRoot(); // HuffmanNode currentHuffmanNode = huffman.getRoot();
// boolean bit; // boolean bit;
// int index = 0; // int index = 0;
// while (!currentHuffmanNode.isLeaf()) { // while (!currentHuffmanNode.isLeaf()) {
// bit = huffmanCode[index++]; // bit = huffmanCode[index++];
// currentHuffmanNode = currentHuffmanNode.traverse(bit); // currentHuffmanNode = currentHuffmanNode.traverse(bit);
// } // }
// assert (indices[i] == currentHuffmanNode.getSymbol()); // assert (indices[i] == currentHuffmanNode.getSymbol());
// } // }
// //////////////////////////////// // ////////////////////////////////
try (OutBitStream outBitStream = new OutBitStream(compressStream, options.getBitsPerPixel(), 2048)) { try (OutBitStream outBitStream = new OutBitStream(compressStream, options.getBitsPerPixel(), 2048)) {
...@@ -199,7 +197,7 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -199,7 +197,7 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
options.getImageDimension(), options.getImageDimension(),
options.getPlaneIndex()).getData(); options.getPlaneIndex()).getData();
} catch (IOException e) { } catch (IOException e) {
throw new ImageCompressionException("Failed to load reference image data.", e); throw new ImageCompressionException("Failed to load plane data.", e);
} }
} else if (options.hasPlaneRangeSet()) { } else if (options.hasPlaneRangeSet()) {
Log("Loading plane range data."); Log("Loading plane range data.");
......
...@@ -78,9 +78,9 @@ public class SQImageDecompressor extends CompressorDecompressorBase implements I ...@@ -78,9 +78,9 @@ public class SQImageDecompressor extends CompressorDecompressorBase implements I
Huffman huffman = null; Huffman huffman = null;
if (!header.isCodebookPerPlane()) { if (!header.isCodebookPerPlane()) {
// There is only one codebook. // There is only one codebook.
Log("Loading reference codebook...");
huffman = null; huffman = null;
// TODO(Moravec): Handle loading of Huffman. // TODO(Moravec): Handle loading of Huffman.
Log("Loading codebook from cache...");
//quantizationValues = readScalarQuantizationValues(compressedStream, codebookSize); //quantizationValues = readScalarQuantizationValues(compressedStream, codebookSize);
} }
......
...@@ -88,7 +88,7 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -88,7 +88,7 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
public long[] compress(DataOutputStream compressStream) throws ImageCompressionException { public long[] compress(DataOutputStream compressStream) throws ImageCompressionException {
long[] planeDataSizes = new long[options.getImageDimension().getZ()]; long[] planeDataSizes = new long[options.getImageDimension().getZ()];
Stopwatch stopwatch = new Stopwatch(); Stopwatch stopwatch = new Stopwatch();
final boolean hasGeneralQuantizer = options.hasCodebookCacheFolder() || options.hasReferencePlaneIndex(); final boolean hasGeneralQuantizer = options.hasCodebookCacheFolder() || options.shouldUseMiddlePlane();
VectorQuantizer quantizer = null; VectorQuantizer quantizer = null;
if (options.hasCodebookCacheFolder()) { if (options.hasCodebookCacheFolder()) {
...@@ -96,24 +96,25 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -96,24 +96,25 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
quantizer = loadQuantizerFromCache(); quantizer = loadQuantizerFromCache();
Log("Cached quantizer created."); Log("Cached quantizer created.");
writeQuantizerToCompressStream(quantizer, compressStream); writeQuantizerToCompressStream(quantizer, compressStream);
} else if (options.hasReferencePlaneIndex()) { } else if (options.shouldUseMiddlePlane()) {
stopwatch.restart(); stopwatch.restart();
ImageU16 referencePlane = null; final int middlePlaneIndex = getMiddlePlaneIndex();
ImageU16 middlePlane = null;
try { try {
referencePlane = RawDataIO.loadImageU16(options.getInputFile(), middlePlane = RawDataIO.loadImageU16(options.getInputFile(),
options.getImageDimension(), options.getImageDimension(),
options.getReferencePlaneIndex()); middlePlaneIndex);
} catch (Exception ex) { } catch (Exception ex) {
throw new ImageCompressionException("Unable to load reference plane data.", ex); throw new ImageCompressionException("Unable to load plane data.", ex);
} }
Log(String.format("Training vector quantizer from reference plane %d.", options.getReferencePlaneIndex())); Log(String.format("Training vector quantizer from middle plane %d.", middlePlaneIndex));
final int[][] refPlaneVectors = referencePlane.toQuantizationVectors(options.getVectorDimension()); final int[][] refPlaneVectors = middlePlane.toQuantizationVectors(options.getVectorDimension());
quantizer = trainVectorQuantizerFromPlaneVectors(refPlaneVectors); quantizer = trainVectorQuantizerFromPlaneVectors(refPlaneVectors);
writeQuantizerToCompressStream(quantizer, compressStream); writeQuantizerToCompressStream(quantizer, compressStream);
stopwatch.stop(); stopwatch.stop();
Log("Reference codebook created in: " + stopwatch.getElapsedTimeString()); Log("Middle plane codebook created in: " + stopwatch.getElapsedTimeString());
} }
final int[] planeIndices = getPlaneIndicesForCompression(); final int[] planeIndices = getPlaneIndicesForCompression();
...@@ -184,7 +185,7 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -184,7 +185,7 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
try { try {
trainData = loadPlaneQuantizationVectors(options.getPlaneIndex()); trainData = loadPlaneQuantizationVectors(options.getPlaneIndex());
} catch (IOException e) { } catch (IOException e) {
throw new ImageCompressionException("Failed to load reference image data.", e); throw new ImageCompressionException("Failed to load plane data.", e);
} }
} else { } else {
Log(options.hasPlaneRangeSet() ? "VQ: Loading plane range data." : "VQ: Loading all planes data."); Log(options.hasPlaneRangeSet() ? "VQ: Loading plane range data." : "VQ: Loading all planes data.");
......
...@@ -102,7 +102,7 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I ...@@ -102,7 +102,7 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
int[][] quantizationVectors = null; int[][] quantizationVectors = null;
if (!header.isCodebookPerPlane()) { if (!header.isCodebookPerPlane()) {
// There is only one codebook. // There is only one codebook.
Log("Loading reference codebook..."); Log("Loading codebook from cache...");
quantizationVectors = readCodebookVectors(compressedStream, codebookSize, vectorSize); quantizationVectors = readCodebookVectors(compressedStream, codebookSize, vectorSize);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment