Skip to content

Commit

Permalink
keep improving the tile grid
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 25, 2023
1 parent 40656c2 commit de8872a
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/main/java/io/bioimage/modelrunner/tiling/TileGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import org.bioimageanalysis.icy.deepicy.tools.ImgLib2Utils;

import io.bioimage.modelrunner.utils.IndexingUtils;
import net.imglib2.img.Img;
import net.imglib2.img.array.ArrayImgFactory;
import net.imglib2.type.NativeType;
Expand Down Expand Up @@ -56,24 +57,30 @@ public class TileGrid

/**
*/
public static TileGrid create(PatchSpec tileSpecs, long[] imSize)
public static TileGrid create(PatchSpec tileSpecs, long[] imSize, int[] gridSize)
{
TileGrid ps = new TileGrid();
tileSpecs.
ps.patchInputSize = patchInputSize;
ps.patchGridSize = patchGridSize;
ps.patchPaddingSize = patchPaddingSize;
ps.tensorName = tensorName;
int tileCount = Arrays.stream(gridSize).reduce(1, (a, b) -> a * b);

for (int j = 0; j < tileCount; j ++) {
int[] patchIndex = IndexingUtils.flatIntoMultidimensionalIndex(j, gridSize);
int[] patchSize = tileSpecs.getPatchInputSize();
int[][] padSize = tileSpecs.getPatchPaddingSize();
int[][] padSizeSeparated = new int[padSize.length][padSize[0].length];
int[] roiSize = IntStream.range(0, patchIndex.length)
.map(i -> patchSize[i] - padSizeSeparated[0][i] - padSizeSeparated[1][i]).toArray();
int[] patchStart = IntStream.range(0, patchIndex.length)
.map(i -> roiSize[i] * patchIndex[i] - padSizeSeparated[0][i]).toArray();
}




PatchSpec grid = tileSpecs;
String patchAxesOrder = "xyczb";
int[] patchSize = grid.getPatchInputSize();
int[] patchSize = tileSpecs.getPatchInputSize();
int[] patchSizeTensorAxes = PatchGridCalculator.arrayToWantedAxesOrderAddOnes(patchSize, patchAxesOrder, tensor.getAxesOrder());
int[] patchIndexTensorAxes = PatchGridCalculator.arrayToWantedAxesOrderAddOnes(patchIndex, patchAxesOrder, tensor.getAxesOrder());
int[][] padSize = grid.getPatchPaddingSize();
int[][] padSize = tileSpecs.getPatchPaddingSize();
int[][] padSizeAxesTensorAxes = new int[padSize.length][padSize[0].length];
padSizeAxesTensorAxes[0] = PatchGridCalculator.arrayToWantedAxesOrderAddOnes(padSize[0], patchAxesOrder, tensor.getAxesOrder());
padSizeAxesTensorAxes[1] = PatchGridCalculator.arrayToWantedAxesOrderAddOnes(padSize[1], patchAxesOrder, tensor.getAxesOrder());
Expand Down

0 comments on commit de8872a

Please sign in to comment.