diff --git a/org.knime.knip.base/src/org/knime/knip/base/node/nodesettings/SettingsModelSubsetSelection2.java b/org.knime.knip.base/src/org/knime/knip/base/node/nodesettings/SettingsModelSubsetSelection2.java index cf1cfd79..ae56690c 100644 --- a/org.knime.knip.base/src/org/knime/knip/base/node/nodesettings/SettingsModelSubsetSelection2.java +++ b/org.knime.knip.base/src/org/knime/knip/base/node/nodesettings/SettingsModelSubsetSelection2.java @@ -140,7 +140,8 @@ protected final SettingsModelSubsetSelection2 createClone() { * @throws KNIPException */ @SuppressWarnings("unchecked") - public final Interval[] createSelectedIntervals(final long[] dimensions, final CalibratedAxis[] axes) + public final Interval[] createSelectedIntervals(final long[] min, final long[] dimensions, + final CalibratedAxis[] axes) throws KNIPException { List[] minPosList; @@ -160,8 +161,8 @@ public final Interval[] createSelectedIntervals(final long[] dimensions, final C maxPosList[d] = new ArrayList(dimensions.length); if (selectionInformation[d]) { - minPosList[d].add(0l); - maxPosList[d].add(dimensions[d] - 1); + minPosList[d].add(min[d]); + maxPosList[d].add(min[d] + dimensions[d] - 1); numIntervalsPerDim[d] = 1; } else { final int[] selection = SubsetSelectionUtils.parseString(m_selection.get(axes[d].type().getLabel())); @@ -246,12 +247,12 @@ public final Interval[] createSelectedIntervals(final long[] dimensions, final C * @return the intervals * @throws KNIPException */ - public final Interval[] createSelectedIntervals(final long[] dimensions, + public final Interval[] createSelectedIntervals(final long[] minimum, final long[] dimensions, final CalibratedSpace labeledAxes) - throws KNIPException { + throws KNIPException { final CalibratedAxis[] axes = new CalibratedAxis[dimensions.length]; labeledAxes.axes(axes); - return createSelectedIntervals(dimensions, axes); + return createSelectedIntervals(minimum, dimensions, axes); } /** @@ -260,10 +261,11 @@ public final Interval[] createSelectedIntervals(final long[] dimensions, * @return the intervals * @throws KNIPException */ - public Interval[] createSelectedIntervalsPlaneWise(final long[] dimensions, final CalibratedAxis[] axes) + public Interval[] createSelectedIntervalsPlaneWise(final long[] minimum, final long[] dimensions, + final CalibratedAxis[] axes) throws KNIPException { - final Interval[] selected = createSelectedIntervals(dimensions, axes); + final Interval[] selected = createSelectedIntervals(minimum, dimensions, axes); if (selected.length == 1) { boolean same = true; @@ -645,7 +647,8 @@ protected final void validateSettingsForModel(final NodeSettingsRO settings) thr */ @SuppressWarnings("unchecked") public Pair[] createSelectionConstraints(final long[] dimensions, - final CalibratedAxis[] calibAxes) throws KNIPException { + final CalibratedAxis[] calibAxes) + throws KNIPException { ArrayList> ret = new ArrayList>(); diff --git a/org.knime.knip.base/src/org/knime/knip/base/nodes/proc/AlignerNodeFactory2.java b/org.knime.knip.base/src/org/knime/knip/base/nodes/proc/AlignerNodeFactory2.java index 963cc22f..c4a8faa3 100644 --- a/org.knime.knip.base/src/org/knime/knip/base/nodes/proc/AlignerNodeFactory2.java +++ b/org.knime.knip.base/src/org/knime/knip/base/nodes/proc/AlignerNodeFactory2.java @@ -76,6 +76,7 @@ import net.imglib2.Interval; import net.imglib2.ops.operation.Operations; import net.imglib2.type.numeric.RealType; +import net.imglib2.util.Intervals; /** * AlignerNodeFactory. Uses {@link DialogComponentSubsetSelection2} instead of {@link DialogComponentSubsetSelection}; @@ -248,7 +249,8 @@ protected ImgPlusCell compute(final ImgPlusValue cellValueA, final ImgPlus final long[] dims = new long[zeroMinFromCell.numDimensions()]; zeroMinFromCell.dimensions(dims); - Interval ivs[] = m_subsetSelect.createSelectedIntervals(dims, zeroMinFromCell); + Interval ivs[] = m_subsetSelect.createSelectedIntervals(Intervals.minAsLongArray(zeroMinFromCell), dims, + zeroMinFromCell); if ((ivs == null) || (ivs.length == 0)) { ivs = new Interval[1]; final long mins[] = new long[zeroMinFromCell.numDimensions()]; @@ -258,16 +260,13 @@ protected ImgPlusCell compute(final ImgPlusValue cellValueA, final ImgPlus ivs[0] = new FinalInterval(mins, maxs); } - return m_imgCellFactory - .createCell(MinimaUtils - .getTranslatedImgPlus(fromCell, new ImgPlus<>( - Operations.compute( - new Aligner(selectedDims1, selectedDim2, ivs[0], - sizemode, alignmode, m_stepSize.getIntValue(), - m_minPixOverlap.getIntValue()), - zeroMinFromCell, - MinimaUtils.getZeroMinImgPlus(cellValueB.getImgPlus())), - cellValueA.getMetadata()))); + return m_imgCellFactory.createCell(MinimaUtils + .getTranslatedImgPlus(fromCell, new ImgPlus<>( + Operations.compute(new Aligner(selectedDims1, selectedDim2, ivs[0], sizemode, + alignmode, m_stepSize.getIntValue(), m_minPixOverlap.getIntValue()), + zeroMinFromCell, + MinimaUtils.getZeroMinImgPlus(cellValueB.getImgPlus())), + cellValueA.getMetadata()))); } /** diff --git a/org.knime.knip.base/src/org/knime/knip/base/nodes/proc/ImgCropperNodeFactory2.java b/org.knime.knip.base/src/org/knime/knip/base/nodes/proc/ImgCropperNodeFactory2.java index 50bdbf6b..c5b94e48 100644 --- a/org.knime.knip.base/src/org/knime/knip/base/nodes/proc/ImgCropperNodeFactory2.java +++ b/org.knime.knip.base/src/org/knime/knip/base/nodes/proc/ImgCropperNodeFactory2.java @@ -156,13 +156,13 @@ protected ImgPlusCell compute(final ImgPlusValue cellValue) throws Excepti final ImgPlus img = cellValue.getImgPlus(); final Interval[] intervals = - m_smSubsetSel.createSelectedIntervals(Intervals.dimensionsAsLongArray(img), img); + m_smSubsetSel.createSelectedIntervals(cellValue.getMinimum(), Intervals.dimensionsAsLongArray(img), img); @SuppressWarnings("unchecked") final IntervalView[] iis = new IntervalView[intervals.length]; for (int i = 0; i < intervals.length; i++) { - iis[i] = Views.interval(img, intervals[i]); + iis[i] = Views.interval(img.getImg(), intervals[i]); } if ((iis.length == 1) && m_smAdjustDimensionality.getBooleanValue()) { diff --git a/org.knime.knip.base/src/org/knime/knip/base/nodes/seg/LabelingOrthoCropperNodeFactory2.java b/org.knime.knip.base/src/org/knime/knip/base/nodes/seg/LabelingOrthoCropperNodeFactory2.java index a03f867d..c48b2e34 100644 --- a/org.knime.knip.base/src/org/knime/knip/base/nodes/seg/LabelingOrthoCropperNodeFactory2.java +++ b/org.knime.knip.base/src/org/knime/knip/base/nodes/seg/LabelingOrthoCropperNodeFactory2.java @@ -78,6 +78,7 @@ import net.imglib2.roi.labeling.ImgLabeling; import net.imglib2.roi.labeling.LabelingType; import net.imglib2.type.numeric.IntegerType; +import net.imglib2.util.Intervals; import net.imglib2.util.Util; import net.imglib2.view.Views; @@ -163,7 +164,8 @@ protected LabelingCell compute(final LabelingValue cellValue) throws Excep lab.dimensions(dimensions); final Interval[] intervals = - m_subsetSel.createSelectedIntervals(dimensions, cellValue.getLabelingMetadata()); + m_subsetSel.createSelectedIntervals(Intervals.minAsLongArray(lab), dimensions, + cellValue.getLabelingMetadata()); @SuppressWarnings("unchecked") final RandomAccessibleInterval>[] subLab = @@ -201,14 +203,11 @@ protected LabelingCell compute(final LabelingValue cellValue) throws Excep } - return m_labCellFactory - .createCell(res, - new DefaultLabelingMetadata( - new DefaultCalibratedSpace( - validAxes.toArray(new CalibratedAxis[validAxes.size()])), - new DefaultNamed(cellValue.getLabelingMetadata().getName()), - new DefaultSourced(cellValue.getLabelingMetadata().getSource()), - cellValue.getLabelingMetadata().getLabelingColorTable())); + return m_labCellFactory.createCell(res, new DefaultLabelingMetadata( + new DefaultCalibratedSpace(validAxes.toArray(new CalibratedAxis[validAxes.size()])), + new DefaultNamed(cellValue.getLabelingMetadata().getName()), + new DefaultSourced(cellValue.getLabelingMetadata().getSource()), + cellValue.getLabelingMetadata().getLabelingColorTable())); } }