Repository navigation
Migrate many classic Fiji plugins to SciJava Ops #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gselzer
wants to merge
174
commits into
main
Choose a base branch
from
scijava-ops-image/fiji-plugin-ops
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
174 commits
Select commit
Hold shift + click to select a range
fe8c0c5
Fix generated class names for nested array types
ctrueden 74c83c4
Test ops with nested array parameters in the engine
ctrueden c8af21a
Add a changelog for SciJava Ops Engine
ctrueden f2bbc94
Add segment.statisticalRegionMerging ops
ctrueden 5404521
Add morphology.localThickness op
ctrueden 88d8ecc
Add segment.hWatershed op
ctrueden 318217a
Add transform.bin op
ctrueden ed3e7f0
Add image.localExtrema ops
ctrueden 6603fe8
Add segment.detectSpotsDoG op
ctrueden 5c8659d
Add image.kymograph op
ctrueden 42dca72
Add Hessian and structure tensor filter ops
ctrueden 289ab24
Add filter.pseudoFlatField op
ctrueden bac4a8b
Add filter.flatFieldCorrect op
ctrueden db0bcf1
Add filter.convolvedBackgroundSubtraction op
ctrueden 96c51b5
Add filter.weightedMedian op
ctrueden b25a13a
Add filter.gaussianWeightedMedian op
ctrueden c0a6235
Add labeling.edgeCorrectedCount op
ctrueden 6568a9d
Add labeling.nearestNeighborDistances and labeling.clarkEvans ops
ctrueden 81e5628
Add geom.extent op
ctrueden c1f20e2
Add geom.compactness op
ctrueden 8c71a46
Add geom.feretAspectRatio op
ctrueden bab055a
Add labeling.featureMap op
ctrueden 18aaaea
Add scijava-ops-image-gpl component
ctrueden ea2c54e
Add scijava-ops-image-lgpl component
ctrueden 270b976
Add transform.houghCircle op
ctrueden b25f6ba
Add segment.detectHoughCircles op
ctrueden 2cdeb06
Add segment.siox ops
ctrueden aaf5e84
Add labeling filtering ops
ctrueden 171da52
Add labeling relabel, merge, hole filling and crop ops
ctrueden e600693
Add labeling.boundaries and labeling.adjacency ops
ctrueden c583b24
Add image.runLengthMatrix and features.glrlm.* ops
ctrueden e44f654
Add image.sizeZoneMatrix and features.glszm.* ops
ctrueden 626aa56
Add image.distanceZoneMatrix and features.gldzm.* ops
ctrueden 5b1bedf
Add image.neighborhoodGrayToneDifferenceMatrix and features.ngtdm.* ops
ctrueden 6918830
Add image.neighboringGrayLevelDependenceMatrix and features.ngldm.* ops
ctrueden 614f49f
Add missing IBSI GLCM features to features.haralick
ctrueden 9753b1f
Add morphological reconstruction and extrema ops
ctrueden 68966dc
Add filter.localContrast and segment.phantast ops
ctrueden d8423e3
Add filter.helmholtzWavelength and filter.helmholtzOrientation ops
ctrueden 4ccd45d
Add color.deconvolveStains op
ctrueden 8f94a47
Fix image.integral for images with more than two dimensions
ctrueden a2ca77f
Add filter.kuwahara op
ctrueden 2da7d00
Add filter.tvDenoise op
ctrueden 1c28612
Add filter.anisotropicDiffusion op
ctrueden caf9cdd
Correct provenance of built-in stain vectors
ctrueden 472d8ba
Fix filter.tubeness ignoring the calibration
ctrueden d7082e1
Fix geom.majorAxis/minorAxis on aligned or clockwise polygons
ctrueden bd2b0e2
Fix coloc.pValue block shuffling of trimmed images
ctrueden 680953b
Document coloc.pValue as the Costes significance test
ctrueden cb384c3
Add labeling.distanceMap and label morphology ops
ctrueden 2f2dee9
Add morphological gradient and Laplacian ops
ctrueden 4820259
Add morphology.skeletonize3D op
ctrueden 24b9255
Add skeleton analysis ops
ctrueden 1772d51
Add compact, extended-minima and distance transform watershed ops
ctrueden a87df08
Add grayscale attribute openings and closings
ctrueden 0cc2af6
Add AbstractOpTest base class to scijava-ops-image-lgpl
ctrueden f05e286
Add features.intrinsicVolumes ops
ctrueden cccf1f4
Move MorphoLibJ-derived ops to scijava-ops-image-lgpl
ctrueden 4d35c97
Rename volume attribute filters to grayVolume
ctrueden 98e4519
Add optional watershed line label to LGPL watershed ops
ctrueden 6c1a535
Put Curtis Rueden and Claude Opus 5.5 first in @author tags
ctrueden 56d73e7
Add features.directionality op
ctrueden 82140f1
Add threshold.limitedMean op
ctrueden 5199613
Add labeling.countContained and labeling.filterByContainedCount ops
ctrueden 65d64a8
Add threshold.hysteresis op
ctrueden 345f76c
Add filter.waveletATrous and filter.waveletDenoise ops
ctrueden e37062e
Add image.bleachCorrect, image.bleachFit and image.histogramMatch ops
ctrueden e9570cd
Add transform.focusStack and transform.focusStackIndex ops
ctrueden b0b5575
Add threshold.rats and threshold.ratsSurface ops
ctrueden a4f8c2f
Move clean-room ops back to scijava-ops-image
ctrueden 9a6f39f
Add stats.entropy op
ctrueden a469747
Add image.histogram2D op
ctrueden a8dc259
Add coloc.mutualInformation op
ctrueden 07e6419
Add coloc.spearman op
ctrueden 07e18ca
Add coloc.manders op
ctrueden 9b6d436
Add coloc.costesThreshold op
ctrueden fbf76b0
Add filter.phaseCorrelate op
ctrueden 2959d23
Add morphology.geodesicDistanceMap and labeling.geodesicDiameter ops
ctrueden 0f52a1f
Add labeling.overlap.* segmentation evaluation ops
ctrueden 999c298
Add n-D labeling region shape measure ops
ctrueden 1534742
Use matching centroid coordinates in 3D inertia tensor
ctrueden ad2a670
Add deconvolve.wiener and deconvolve.tikhonov ops
ctrueden cb8a887
Add deconvolve.landweber op
ctrueden d42e4d4
Add color.convert and color.deltaE ops
ctrueden dbf9922
Add filter.kuwaharaLinear ops
ctrueden b24e94c
Add filter.retinex ops
ctrueden 4f5d775
Add filter.kalman op
ctrueden 455971f
Add image.signedDistanceTransform and morphology.interpolateSlices ops
ctrueden 90c8d13
Add segment.detectLines and segment.estimateLineParameters ops
ctrueden 8d7da1c
Add segment.spotsFromSeeds op
ctrueden e337009
Add Canny-Deriche edge detection ops
ctrueden b58f178
Add morphology.directionalFilter op
ctrueden abf4617
Add filter.coherenceEnhancingDiffusion op
ctrueden 5e2c38b
Add segment.kMeans op
ctrueden fa2c396
Add segment.seededRegionGrowing op
ctrueden 0a1b15b
Add image.quantileNormalize op
ctrueden 5072103
Add features.twoPointCorrelation op
ctrueden bdf1395
Add labeling.shapeBasedAverage op
ctrueden cfbb791
Fix Landweber default step size for unnormalized kernels
ctrueden 22d40dd
Use one histogram bin per grey level in threshold ops
ctrueden 23425c2
Add bilevel shortcut to global threshold ops
ctrueden f4a870a
Add ignoreBlack and ignoreWhite to global threshold ops
ctrueden 3c7a2e5
Fix threshold.minError when the iteration does not converge
ctrueden adfaa71
Resolve threshold.otsu ties toward the lowest bin
ctrueden 4682093
Make threshold.huang match Fiji Huang; add threshold.huang2
ctrueden 0231213
Fix inverted threshold.localContrast
ctrueden ab22d61
Fix the threshold.localSauvola formula
ctrueden bb0d1d4
Fix local threshold ops on rectangles computed via integral images
ctrueden 692f4f7
Make threshold.localPhansalkar stretch its input to [0, 1]
ctrueden 8adcb73
Pin threshold.localBernsen and localNiblack to Fiji
ctrueden e3c87ff
Add transform.piv op
ctrueden 2e916a9
Add segment.graphCut ops
ctrueden 623895c
Add image.fastMarching and segment.fastMarching ops
ctrueden a62d3b7
Add segment.levelSet and image.levelSet ops
ctrueden 5aa4556
Clamp flat-field corrections to the output type range
ctrueden 21d820b
Compute filter.localContrast moments in double precision
ctrueden 42222f5
Keep deconvolve.landweber buffers in double precision
ctrueden 1d9d54f
Fix filter.weightedMedian for inputs with a non-zero min
ctrueden 9987d46
Fix filter.tubeness for inputs with a non-zero min
ctrueden 3967b3b
Keep filter.helmholtzOrientation within [0, 180)
ctrueden 1d5b016
Match filter.kalman to the documented Kalman stack filter
ctrueden ab11fd7
Clamp edge-preserving smoothers to the output type range
ctrueden a400929
Extract the flat-array helpers into filter.FlatImage
ctrueden 09b72f8
Move the CED Jacobi eigensolver into TensorUtils
ctrueden 11110cf
Move defaultChannelDim into a shared ColorUtils class
ctrueden d1363ae
Limit hill climbing in filter.phaseCorrelate
ctrueden bb55a04
Test the MSRCR value of filter.retinex analytically
ctrueden c012991
Fix image.distanceTransform for inputs with non-zero min
ctrueden 4429459
Keep the input interval in segment.distanceTransformWatershed
ctrueden 7758980
Reject NaN in the morphology reconstruction ops
ctrueden 0203f49
Reject all-foreground input in morphology.localThickness
ctrueden bae89fc
Order labeling.geodesicDiameterPath from first to second extremity
ctrueden 8a0b5a8
Lowercase string options with Locale.ROOT
ctrueden ad282c7
Share the neighbor offset and spacing helpers
ctrueden 41ecd98
Reuse image.signedDistanceTransform in labeling.shapeBasedAverage
ctrueden 67c59e5
Exclude NaN pixels from threshold.limitedMean
ctrueden b8d0c81
Keep NaN pixels out of segment.spotsFromSeeds spots
ctrueden 01e332e
Reject size-1 dimensions in intrinsicVolumes.densities
ctrueden cd97bd4
Add op-count regression tests to the GPL and LGPL modules
ctrueden 178d9d7
Normalize GPL license headers in the ridge package
ctrueden 0faa80e
Clean up the ridge package to the project style
ctrueden 5e18d0f
Share one Gaussian curve fit in the GPL module
ctrueden 1cba88c
Fix RATS noise estimate on quantized low-noise images
ctrueden 6fcdc0e
Fix segment.kMeans iteration limit, output interval and NaN pixels
ctrueden edd1e23
Round the Bernsen mid grey down on integer images, as Fiji does
ctrueden c59471a
Use the population standard deviation in threshold.localNiblack
ctrueden 7ddca33
Match Fiji in threshold.localSauvola, including its default r
ctrueden 3b20f40
Match Fiji in threshold.localPhansalkar; add normalize option
ctrueden 79f48ba
Cap the histograms of local thresholds at 256 bins
ctrueden fcfc8dc
Remove unused grey level counts from IBSI Haralick features
ctrueden 414ba21
Reject NaN in the watershed and region growing ops
ctrueden 171368e
Test translated inputs of transform.focusStack and threshold.hysteresis
ctrueden 80a770c
Handle NaN in the other segment ops
ctrueden 9b26511
Use the shared neighbor offsets in threshold.hysteresis
ctrueden 33e5078
Reproduce upstream license notices and fix @author attributions
ctrueden 49feb43
Remove unused dependencies from the GPL and LGPL POMs
ctrueden 39bb397
Fix half-bin bias of features.directionality gradient method
ctrueden 080f0b0
Drop java.awt.geom.Point2D from the ridge LineDetector
ctrueden 6b10b1a
Use a nullable Shape connectivity, defaulting to full, in new ops
ctrueden 18048e1
Name the pixel spacing parameter calibration in new ops
ctrueden 1e24675
Number the labels of new partition ops from 1
ctrueden ab137bc
Remove the noiseVariance parameter of filter.kalman
ctrueden 9122a25
Rename four new filter ops to avoid name clashes
ctrueden 0bba7ec
Rename features.directionality and morphology.skeletonize3D
ctrueden 8965f97
Rename three new segment and labeling ops for consistency
ctrueden 3dbf3bc
Rename image.fastMarching, image.levelSet and transform.piv
ctrueden 4b53aba
Add changelogs and list the GPL and LGPL components' ops
ctrueden 6ec60e7
Document Fiji plugin equivalents of Ops
ctrueden 142cce7
Document deviations and limits of the new filter and color ops
ctrueden 23b3a0e
Document deviations and limits of the new morphology, labeling and im…
ctrueden badbebf
Document deviations and limits of the new segment and threshold ops
ctrueden d525bd2
Document the Directionality quirks kept for plugin parity
ctrueden 200e2b8
Export the labeling utils and util packages of scijava-ops-image
ctrueden 82d8107
Add About classes to the GPL and LGPL components
ctrueden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Fiji Plugin Equivalents | ||
|
|
||
| Many classic ImageJ and Fiji plugins have equivalent Ops. This page maps each plugin to its Ops; | ||
| the javadoc of each Op details its differences from the plugin. Ops marked *GPL* or *LGPL* live in the | ||
| `scijava-ops-image-gpl` or `scijava-ops-image-lgpl` components, since they derive from code under | ||
| those licenses; all other Ops are in `scijava-ops-image`. | ||
|
|
||
| "Same results" means the Op reproduces the plugin's output exactly on our test images; most Ops also | ||
| generalize the plugin to n-dimensional images and calibrated pixel sizes. | ||
|
|
||
| | Plugin | Ops | Notes | | ||
| |---|---|---| | ||
| | Auto Threshold | `threshold.<method>` | Same results, including Huang and Huang2. | | ||
| | Auto Local Threshold | `threshold.local<Method>` | Same results. | | ||
| | 3D ImageJ Suite: Canny edge 3D | `filter.derichePartialDerivative`, `filter.dericheGradientMagnitude`, `segment.cannyDericheEdges` | Normalized, separable Deriche filter; magnitudes differ by a constant factor. | | ||
| | 3D ImageJ Suite: 3D Spot Segmentation | `segment.spotsFromSeeds` (*GPL*) | Same results; no watershed option. | | ||
| | Anisotropic Diffusion 2D | — | Not ported; see `filter.peronaMalik` and `filter.coherenceEnhancingDiffusion`. | | ||
| | Bleach Correction | `image.bleachCorrect`, `image.bleachFit`, `image.histogramMatch` | | | ||
| | BioVoxxel Toolbox | `filter.pseudoFlatField`, `filter.flatFieldCorrect`, `filter.convolvedBackgroundSubtraction`, `filter.gaussianWeightedMedian`, `labeling.edgeCorrectedCount`, `labeling.clarkEvans`; `threshold.limitedMean`, `labeling.countContained` (*GPL*) | | | ||
| | CircleSkinner | `transform.houghCircle`, `segment.detectHoughCircles` | Votes on full rings rather than midpoint circles. | | ||
| | Coloc 2 | `coloc.pearsons`, `coloc.manders`, `coloc.costesThreshold`, `coloc.spearman`, `coloc.pValue` | Costes thresholds count a pixel equal to the threshold as below it. | | ||
| | Colour Deconvolution | `color.deconvolveStains` | Within one grey level. | | ||
| | Curvatures, Shape Index Map | `filter.hessianEigenvalues`, `filter.shapeIndex` | | | ||
| | Directionality | `features.directionalityHistogram` (*GPL*) | Same results for the Fourier method; the gradient method's half-bin bias is fixed. | | ||
| | Gaussian Stack Focuser | `transform.focusStack`, `transform.focusStackIndex` | | | ||
| | Graph Cut | `segment.graphCut` | Independent implementation of Boykov–Kolmogorov max-flow. | | ||
| | Helmholtz Analysis | `filter.helmholtzWavelength`, `filter.helmholtzOrientation` | Spatial instead of FFT band-pass; results differ slightly. | | ||
| | Interactive H-Watershed | `segment.hWatershed` | Same results on integer images. | | ||
| | Iterative Deconvolve 3D | `deconvolve.wiener`, `deconvolve.tikhonov`, `deconvolve.landweber` | Independent implementations. | | ||
| | Kalman Stack Filter | `filter.kalman` | Independent implementation of the documented algorithm. | | ||
| | Kuwahara Filter | `filter.kuwahara` | Same results away from the image border. | | ||
| | Linear Kuwahara | `filter.kuwaharaLinear` | Independent implementation. | | ||
| | KymographBuilder | `image.kymograph` | Samples the first row and column, which the plugin skips. | | ||
| | Level Sets | `segment.levelSet`, `segment.fastMarching` | Independent implementations (Chan–Vese, geodesic active contours). | | ||
| | Local Thickness | `morphology.localThickness` | Same results to 1e-5. | | ||
| | MorphoLibJ: morphological reconstruction, extrema, h-transforms, kill borders, fill holes | `morphology.reconstructBy*`, `morphology.regional*`, `morphology.extended*`, `morphology.h*`, `morphology.impose*`, `morphology.killBorders`, `morphology.fillHoles` | Same results. | | ||
| | MorphoLibJ: attribute filtering | `morphology.areaOpening`, `morphology.boxDiagonalOpening`, `morphology.attributeOpening` and closings | Same results. MorphoLibJ's "volume opening" is `morphology.areaOpening` on a 3D image. | | ||
| | MorphoLibJ: morphological segmentation | `segment.extendedMinimaWatershed`, `segment.compactWatershed` | Same results with watershed lines. | | ||
| | MorphoLibJ: distance transform watershed | `segment.distanceTransformWatershed` | Uses the exact Euclidean distance transform instead of chamfer. | | ||
| | MorphoLibJ: label utilities and label morphology | `labeling.*` (e.g. `removeBorderLabels`, `filterBySize`, `dilate`, `distanceMap`, `adjacency`) | Exact Euclidean distances instead of chamfer. | | ||
| | MorphoLibJ: geodesic distance, region analysis, label overlap | `morphology.geodesicDistanceMap`, `labeling.geodesicDiameter`, `labeling.inscribedBall`, `labeling.equivalentEllipsoid`, `labeling.maximumFeret`, `labeling.overlap.*` | | | ||
| | MorphoLibJ: intrinsic volumes (Analyze Regions) | `features.intrinsicVolumes.*` (*LGPL*) | Same results, except that interface area honors the pixel calibration. | | ||
| | OrientationJ | `filter.structureTensor`, `filter.orientation`, `filter.coherency` | | | ||
| | PHANTAST | `segment.phantast`, `filter.localCoefficientOfVariation` | Same results; two halo-correction bugs fixed. | | ||
| | PIV analyser | `image.piv` | | | ||
| | RadiomicsJ texture features | `features.glrlm.*`, `features.glszm.*`, `features.gldzm.*`, `features.ngtdm.*`, `features.ngldm.*` | Match the IBSI reference values. | | ||
| | RATS | `threshold.rats` | Independent implementation; results differ in detail. | | ||
| | Retinex | `filter.retinex` | Each scale is applied to the original image. | | ||
| | Ridge Detection | `segment.detectLines` (*GPL*) | Same results. | | ||
| | ROF Denoise | `filter.tvDenoise` | Chambolle's algorithm; borders differ. | | ||
| | SIOX Segmentation | `segment.siox` | Same results. | | ||
| | Skeletonize3D, AnalyzeSkeleton | `morphology.skeletonize`, `morphology.tagSkeleton`, `topology.skeletonGraph`, `topology.skeletonStatistics` (*GPL*) | Same results; fixes pruning after the root vertex is removed. | | ||
| | Statistical Region Merging | `segment.statisticalRegionMerging` | Same results on full-range 8-bit images. | | ||
| | Stitching (pairwise phase correlation) | `filter.phaseCorrelate` | Translation only. | | ||
| | Tubeness, Frangi Vesselness | `filter.tubeness`, `filter.frangiVesselness`, `filter.sheetness` | `filter.tubeness` differentiates in calibrated units, unlike the plugin. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to SciJava Ops Engine. | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| ### Fixed | ||
|
|
||
| - Ops with multi-dimensional array parameters (e.g. `double[][]`) could not | ||
| be called with their optional parameters omitted, or with converted | ||
| arguments. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
scijava-ops-engine/src/test/java/org/scijava/ops/engine/reduce/NestedArrayParameterTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| /*- | ||
| * #%L | ||
| * Java implementation of the SciJava Ops matching engine. | ||
| * %% | ||
| * Copyright (C) 2016 - 2025 SciJava developers. | ||
| * %% | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright notice, | ||
| * this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| * this list of conditions and the following disclaimer in the documentation | ||
| * and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | ||
| * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| * POSSIBILITY OF SUCH DAMAGE. | ||
| * #L% | ||
| */ | ||
|
|
||
| package org.scijava.ops.engine.reduce; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import java.util.function.BiFunction; | ||
|
|
||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.scijava.ops.engine.AbstractTestEnvironment; | ||
| import org.scijava.ops.engine.conversionLoss.impl.IdentityLossReporter; | ||
| import org.scijava.ops.engine.conversionLoss.impl.PrimitiveLossReporters; | ||
| import org.scijava.ops.engine.copy.CopyOpCollection; | ||
| import org.scijava.ops.engine.matcher.convert.IdentityCollection; | ||
| import org.scijava.ops.engine.matcher.convert.PrimitiveConverters; | ||
| import org.scijava.ops.engine.matcher.convert.UtilityConverters; | ||
| import org.scijava.ops.engine.matcher.impl.LossReporterWrapper; | ||
| import org.scijava.ops.spi.Nullable; | ||
| import org.scijava.ops.spi.OpCollection; | ||
| import org.scijava.ops.spi.OpMethod; | ||
|
|
||
| /** | ||
| * Tests ops with a multi-dimensional array parameter, whose reduced and | ||
| * converted wrappers need a generated class name derived from the parameter | ||
| * types ({@code double[][]} must give a valid identifier such as | ||
| * {@code double_Arr_Arr}). | ||
| * | ||
| * @author Curtis Rueden | ||
| * @author Claude Opus 5.5 | ||
| */ | ||
| public class NestedArrayParameterTest extends AbstractTestEnvironment | ||
| implements OpCollection | ||
| { | ||
|
|
||
| @BeforeAll | ||
| public static void addNeededOps() { | ||
| ops.register( // | ||
| new CopyOpCollection<>(), // | ||
| new IdentityCollection<>(), // | ||
| new IdentityLossReporter<>(), // | ||
| new LossReporterWrapper<>(), // | ||
| new PrimitiveConverters<>(), // | ||
| new PrimitiveLossReporters(), // | ||
| new UtilityConverters(), // | ||
| new NestedArrayParameterTest() // | ||
| ); | ||
| } | ||
|
|
||
| @OpMethod(names = "test.nestedArraySum", type = BiFunction.class) | ||
| public static Double nestedArraySum(final double[][] values, | ||
| @Nullable final Double scale) | ||
| { | ||
| double sum = 0; | ||
| for (final double[] row : values) | ||
| for (final double v : row) | ||
| sum += v; | ||
| return sum * (scale == null ? 1 : scale); | ||
| } | ||
|
|
||
| @OpMethod(names = "test.nestedArrayCount", type = BiFunction.class) | ||
| public static Double nestedArrayCount(final double[][][] values, | ||
| @Nullable final Double scale) | ||
| { | ||
| long count = 0; | ||
| for (final double[][] plane : values) | ||
| for (final double[] row : plane) | ||
| count += row.length; | ||
| return count * (scale == null ? 1 : scale); | ||
| } | ||
|
|
||
| private static final double[][] VALUES = { { 1, 2 }, { 3, 4 } }; | ||
|
|
||
| @Test | ||
| public void testAllArguments() { | ||
| final Double sum = ops.op("test.nestedArraySum").input(VALUES, 2.0) | ||
| .outType(Double.class).apply(); | ||
| assertEquals(20, sum, 0); | ||
| } | ||
|
|
||
| /** Omitting the optional parameter goes through a reduced wrapper. */ | ||
| @Test | ||
| public void testOptionalOmitted() { | ||
| final Double sum = ops.op("test.nestedArraySum").input(VALUES).outType( | ||
| Double.class).apply(); | ||
| assertEquals(10, sum, 0); | ||
| final Double count = ops.op("test.nestedArrayCount").input( | ||
| new double[2][3][4]).outType(Double.class).apply(); | ||
| assertEquals(24, count, 0); | ||
| } | ||
|
|
||
| /** An Integer scale goes through a converted wrapper. */ | ||
| @Test | ||
| public void testConverted() { | ||
| final Double sum = ops.op("test.nestedArraySum").input(VALUES, 3) | ||
| .outType(Double.class).apply(); | ||
| assertEquals(30, sum, 0); | ||
| final Integer rounded = ops.op("test.nestedArraySum").input(VALUES) | ||
| .outType(Integer.class).apply(); | ||
| assertEquals(10, rounded); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ctrueden is this something we're going to start doing for all of the modules in here now?