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

Fix loading of single plane in middle plane codebook training.

parent d65bb181
No related branches found
No related tags found
No related merge requests found
...@@ -181,7 +181,7 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -181,7 +181,7 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
return planeDataSizes; return planeDataSizes;
} }
private int[] loadConfiguredPlanesData() throws ImageCompressionException { private int[] loadConfiguredPlanesData() throws ImageCompressionException, IOException {
final InputData inputDataInfo = options.getInputDataInfo(); final InputData inputDataInfo = options.getInputDataInfo();
final IPlaneLoader planeLoader; final IPlaneLoader planeLoader;
try { try {
...@@ -191,36 +191,32 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -191,36 +191,32 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
} }
int[] trainData = null; int[] trainData = null;
if (inputDataInfo.isPlaneIndexSet()) { if (options.getCodebookType() == CompressionOptions.CodebookType.MiddlePlane) {
try { final int middlePlaneIndex = inputDataInfo.getDimensions().getZ() / 2;
reportStatusToListeners("Loading single plane data."); reportStatusToListeners("Loading single plane data.");
trainData = planeLoader.loadPlaneData(inputDataInfo.getPlaneIndex()); trainData = planeLoader.loadPlaneData(middlePlaneIndex);
} catch (final IOException e) { } else if (inputDataInfo.isPlaneIndexSet()) {
throw new ImageCompressionException("Failed to load plane data.", e); reportStatusToListeners("Loading single plane data.");
} trainData = planeLoader.loadPlaneData(inputDataInfo.getPlaneIndex());
} else if (inputDataInfo.isPlaneRangeSet()) { } else if (inputDataInfo.isPlaneRangeSet()) {
reportStatusToListeners("Loading plane range data."); reportStatusToListeners("Loading plane range data.");
final int[] planes = getPlaneIndicesForCompression(options.getInputDataInfo()); final int[] planes = getPlaneIndicesForCompression(options.getInputDataInfo());
try { trainData = planeLoader.loadPlanesU16Data(planes);
trainData = planeLoader.loadPlanesU16Data(planes);
} catch (final IOException e) {
e.printStackTrace();
throw new ImageCompressionException("Failed to load plane range data.", e);
}
} else { } else {
reportStatusToListeners("Loading all planes data."); reportStatusToListeners("Loading all planes data.");
try { trainData = planeLoader.loadAllPlanesU16Data();
trainData = planeLoader.loadAllPlanesU16Data();
} catch (final IOException e) {
throw new ImageCompressionException("Failed to load all planes data.", e);
}
} }
return trainData; return trainData;
} }
@Override @Override
public void trainAndSaveCodebook() throws ImageCompressionException { public void trainAndSaveCodebook() throws ImageCompressionException {
final int[] trainData = loadConfiguredPlanesData(); final int[] trainData;
try {
trainData = loadConfiguredPlanesData();
} catch (final IOException e) {
throw new ImageCompressionException("Failed to load configured plane data in SQImageCompressor.");
}
final LloydMaxU16ScalarQuantization lloydMax = new LloydMaxU16ScalarQuantization(trainData, final LloydMaxU16ScalarQuantization lloydMax = new LloydMaxU16ScalarQuantization(trainData,
getCodebookSize(), getCodebookSize(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment