Skip to content

Commit c5afcac

Browse files
committed
Update out of bounds to use correct count
if running downsampler on a previously downsampled image, the out of bounds labels are now correctly weighted
1 parent 14f4b5b commit c5afcac

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/bdv/bigcat/spark/SparkDownsampleFunction.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
import org.janelia.saalfeldlab.n5.N5Reader;
1111
import org.janelia.saalfeldlab.n5.N5Writer;
1212

13+
import bdv.labels.labelset.Label;
1314
import bdv.labels.labelset.LabelMultisetType;
1415
import bdv.labels.labelset.LabelMultisetTypeDownscaler;
1516
import bdv.labels.labelset.LabelUtils;
17+
import bdv.labels.labelset.Multiset.Entry;
1618
import bdv.labels.labelset.N5CacheLoader;
1719
import bdv.labels.labelset.VolatileLabelMultisetArray;
1820
import net.imglib2.RandomAccessible;
@@ -26,7 +28,7 @@
2628

2729
public class SparkDownsampleFunction implements Function<DownsampleBlock, Integer> {
2830

29-
private static final long serialVersionUID = 1384028449836651389L;
31+
private static final long serialVersionUID = 1384028449836651390L;
3032
private final String inputGroupName;
3133
private final String inputDatasetName;
3234
private final int[] factor;
@@ -68,7 +70,11 @@ public Integer call(DownsampleBlock targetRegion) throws Exception {
6870
final CachedCellImg<LabelMultisetType,VolatileLabelMultisetArray> inputImg = new CachedCellImg<LabelMultisetType,VolatileLabelMultisetArray>(
6971
new CellGrid(dimensions, blocksize), new LabelMultisetType(), wrappedCache, new VolatileLabelMultisetArray(0, true));
7072

71-
final RandomAccessible<LabelMultisetType> extendedImg = Views.extendValue(inputImg, LabelUtils.getOutOfBounds());
73+
int eachCount = 0;
74+
for(Entry<Label> e : inputImg.firstElement().entrySet())
75+
eachCount += e.getCount();
76+
77+
final RandomAccessible<LabelMultisetType> extendedImg = Views.extendValue(inputImg, LabelUtils.getOutOfBounds(eachCount));
7278

7379
VolatileLabelMultisetArray downscaledCell;
7480

0 commit comments

Comments
 (0)