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

RawDataLoader: Allow loading of image data to 2D array.

parent d0892e25
No related branches found
No related tags found
No related merge requests found
...@@ -130,6 +130,28 @@ public final class RawDataLoader extends BasicLoader implements IPlaneLoader { ...@@ -130,6 +130,28 @@ public final class RawDataLoader extends BasicLoader implements IPlaneLoader {
return values; return values;
} }
public int[][] loadAllPlanesTo2DArray() throws IOException {
final V3i imageDims = inputDataInfo.getDimensions();
final int planePixelCount = imageDims.getX() * imageDims.getY();
final int planeDataSize = planePixelCount * 2;
final int[][] result = new int[imageDims.getZ()][];
final byte[] planeBuffer = new byte[planeDataSize];
try (final FileInputStream fileStream = new FileInputStream(inputDataInfo.getFilePath())) {
for (int plane = 0; plane < imageDims.getZ(); plane++) {
int toRead = planeDataSize;
while (toRead > 0) {
final int read = fileStream.read(planeBuffer, planeDataSize - toRead, toRead);
assert (read > 0);
toRead -= read;
}
result[plane] = TypeConverter.unsignedShortBytesToIntArray(planeBuffer);
}
}
return result;
}
@Override @Override
public int[][] loadRowVectors(final int vectorSize, final Range<Integer> planeRange) throws IOException { public int[][] loadRowVectors(final int vectorSize, final Range<Integer> planeRange) throws IOException {
return loadRowVectorsImplByLoadPlaneData(vectorSize, planeRange); return loadRowVectorsImplByLoadPlaneData(vectorSize, planeRange);
...@@ -144,4 +166,6 @@ public final class RawDataLoader extends BasicLoader implements IPlaneLoader { ...@@ -144,4 +166,6 @@ public final class RawDataLoader extends BasicLoader implements IPlaneLoader {
public int[][] loadVoxels(final V3i voxelDim, final Range<Integer> planeRange) throws IOException { public int[][] loadVoxels(final V3i voxelDim, final Range<Integer> planeRange) throws IOException {
return loadVoxelsImplByLoadPlaneData(voxelDim, planeRange); return loadVoxelsImplByLoadPlaneData(voxelDim, planeRange);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment