Skip to content

Commit 5f588b3

Browse files
ctruedengselzer
authored andcommitted
Update code to ImgLib2 7.x
And fix backwards incompatibilities due to the new getType() method.
1 parent d8276ac commit 5f588b3

File tree

9 files changed

+21
-19
lines changed

9 files changed

+21
-19
lines changed

scijava-ops-image/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@
266266
<scijava-maven-plugin.version>3.0.0</scijava-maven-plugin.version>
267267
<imglib2-mesh.version>1.0.0</imglib2-mesh.version>
268268
<net.imglib2.imglib2-mesh.version>${imglib2-mesh.version}</net.imglib2.imglib2-mesh.version>
269+
270+
<imglib2.version>7.0.1</imglib2.version>
271+
<imglib2-roi.version>0.15.0</imglib2-roi.version>
272+
<imglib2-algorithm.version>0.15.1</imglib2-algorithm.version>
273+
<imglib2-realtransform.version>4.0.3</imglib2-realtransform.version>
269274
</properties>
270275

271276
<dependencies>

scijava-ops-image/src/main/java/org/scijava/ops/image/coloc/ShuffledView.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ public void shuffleBlocks(long seed) {
125125
shuffleBlocks();
126126
}
127127

128+
@Override
129+
public T getType() {
130+
return image.getType();
131+
}
132+
128133
@Override
129134
public RandomAccess<T> randomAccess() {
130135
return new ShuffledRandomAccess();

scijava-ops-image/src/main/java/org/scijava/ops/image/geom/geom3d/DefaultInertiaTensor3D.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public RealMatrix apply(final IterableRegion<B> input) {
6868
"Only three-dimensional inputs allowed!");
6969

7070
final var output = new BlockRealMatrix(3, 3);
71-
var c = input.localizingCursor();
71+
var c = input.inside().localizingCursor();
7272
var pos = new double[3];
7373
var computedCentroid = new double[3];
7474
centroid.apply(input).localize(computedCentroid);
@@ -95,7 +95,7 @@ public RealMatrix apply(final IterableRegion<B> input) {
9595
output.setEntry(2, 1, output.getEntry(1, 2));
9696
}
9797

98-
final double size = input.size();
98+
final double size = input.inside().size();
9999
output.setEntry(0, 0, output.getEntry(0, 0) / size);
100100
output.setEntry(0, 1, output.getEntry(0, 1) / size);
101101
output.setEntry(0, 2, output.getEntry(0, 2) / size);

scijava-ops-image/src/main/java/org/scijava/ops/image/image/watershed/Watershed.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public void compute(final RandomAccessibleInterval<T> in, //
138138
final List<Long> imiList = new ArrayList<>();
139139

140140
if (mask != null) {
141-
final var c = Regions.iterable(mask).localizingCursor();
141+
final var c = Regions.iterable(mask).inside().localizingCursor();
142142
while (c.hasNext()) {
143143
c.next();
144144
imiList.add(IntervalIndexer.positionToIndex(c, in));

scijava-ops-image/src/main/java/org/scijava/ops/image/image/watershed/WatershedSeeded.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ public void compute( //
206206

207207
// Only iterate seeds that are not excluded by the mask
208208
final var maskRegions = Regions.iterable(mask);
209-
final var seedsMasked = Regions.sample(
210-
(IterableInterval<Void>) maskRegions, seeds);
209+
final var seedsMasked = Regions.sample(maskRegions.inside(), seeds);
211210
final var cursorSeeds = seedsMasked
212211
.localizingCursor();
213212

scijava-ops-image/src/main/java/org/scijava/ops/image/imagemoments/AbstractImageMomentOp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public interface AbstractImageMomentOp<I extends RealType<I>, O extends RealType
4646
extends Computers.Arity1<RandomAccessibleInterval<I>, O>
4747
{
4848

49-
public void computeMoment(RandomAccessibleInterval<I> input, O output);
49+
void computeMoment(RandomAccessibleInterval<I> input, O output);
5050

5151
/**
5252
* TODO

scijava-ops-image/src/main/java/org/scijava/ops/image/labeling/MergeLabeling.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,14 @@
3232
import java.util.function.BiFunction;
3333
import java.util.function.Function;
3434

35-
import net.imglib2.Cursor;
3635
import net.imglib2.Dimensions;
37-
import net.imglib2.IterableInterval;
38-
import net.imglib2.RandomAccess;
3936
import net.imglib2.RandomAccessibleInterval;
4037
import net.imglib2.roi.IterableRegion;
4138
import net.imglib2.roi.Regions;
4239
import net.imglib2.roi.labeling.ImgLabeling;
4340
import net.imglib2.roi.labeling.LabelingType;
4441
import net.imglib2.type.BooleanType;
4542
import net.imglib2.type.numeric.IntegerType;
46-
import net.imglib2.view.Views;
4743

4844
import org.scijava.function.Computers;
4945
import org.scijava.function.Functions;
@@ -72,24 +68,21 @@ public class MergeLabeling<L, I extends IntegerType<I>, B extends BooleanType<B>
7268
* TODO
7369
*
7470
* @param input1
75-
* @param input1
71+
* @param input2
7672
* @param mask
7773
* @return an {@link ImgLabeling} that combines the labels of {@code input1}
7874
* and {@code input2}
7975
*/
8076
@Override
81-
@SuppressWarnings({ "unchecked", "rawtypes", "hiding" })
8277
public ImgLabeling<L, I> apply( //
8378
final ImgLabeling<L, I> input1, //
8479
final ImgLabeling<L, I> input2, //
8580
@Nullable final RandomAccessibleInterval<B> mask //
8681
) {
87-
final var output = imgLabelingCreator.apply(input1, Views
88-
.iterable(input1.getSource()).firstElement());
82+
final var output = imgLabelingCreator.apply(input1, input1.getSource().firstElement());
8983
if (mask != null) {
90-
final IterableRegion iterable = Regions.iterable(mask);
91-
final var sample = Regions.sample(
92-
(IterableInterval<Void>) iterable, output);
84+
final IterableRegion<B> iterable = Regions.iterable(mask);
85+
final var sample = Regions.sample(iterable.inside(), output);
9386
final var randomAccess = input1.randomAccess();
9487
final var randomAccess2 = input2.randomAccess();
9588
final var cursor = sample.cursor();

scijava-ops-image/src/test/java/org/scijava/ops/image/image/watershed/WatershedSeededTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private void assertResults(final RandomAccessibleInterval<FloatType> in,
219219
// count labels
220220
Set<Integer> labelSet = new HashSet<>();
221221
for (LabelingType<Integer> pixel : Regions.sample(
222-
(IterableInterval<Void>) regions, out))
222+
regions.inside(), out))
223223
{
224224
labelSet.addAll(pixel);
225225
}

scijava-ops-image/src/test/java/org/scijava/ops/image/image/watershed/WatershedTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private void assertResults(final RandomAccessibleInterval<FloatType> in,
220220
// count labels
221221
Set<Integer> labelSet = new HashSet<>();
222222
for (LabelingType<Integer> pixel : Regions.sample(
223-
(IterableInterval<Void>) regions, out))
223+
regions.inside(), out))
224224
{
225225
labelSet.addAll(pixel);
226226
}

0 commit comments

Comments
 (0)