-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add Op discovery annotations to ImgLib2-algorithm #94
base: master
Are you sure you want to change the base?
Conversation
A running list of
|
4811d07
to
1765d54
Compare
@ctrueden @tpietzsch I've fully updated this PR such that it now uses (the unreleased) SciJava Ops Indexer. I can now automatically discover all annotated static methods in an environment containing both a local build of imglib2-algorithm and a local build of the SciJava Incubator. The PR will not build until we release the SciJava Ops Indexer, so I've left it as a draft, but bringing this work up-to-date made me excited for the possibilities of SciJava Ops! |
1765d54
to
411339f
Compare
@tpietzsch In this PR we are discussing the minimum Java version to index libraries with Ops. I'm wondering if there is a need to keep |
@hinerm I don't think there is anything that would break with higher Java versions. As soon as Fiji finally moves to Java 21, (all of) ImgLib2 will too. |
678df37
to
66cd368
Compare
66cd368
to
08265eb
Compare
08265eb
to
53a2a06
Compare
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.
@@ -105,7 +105,8 @@ public final class MserTree< T extends Type< T > > implements ComponentForest< M | |||
* {@link #buildMserTree(RandomAccessibleInterval, RealType, long, long, double, double, ImgFactory, boolean)} | |||
* using an {@link ArrayImgFactory} or {@link CellImgFactory} depending on | |||
* input image size. | |||
* |
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.
Opinions on whether these should be Ops? I'm not totally sure what they're used for...
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.
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.
And I guess this article is relevant.
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.
While we are figuring this stuff out, we should improve the javadoc. Every algorithm should cite the paper(s) it is about in its class javadoc. A "component tree" in the context of the componenttree
packages is explained in papers like this one; without that context, it is difficult to understand what all this code is for.
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.
Concepts of level sets, mathematical morphology, and connected component analysis are very related. We have CCA currently in labeling
, but other morphology operators in morphology
. What about level sets? FWIW, I checked scikit-image for comparison, and use of level sets mostly takes place in skimage.segmentation.morphsnakes
.
@@ -74,6 +74,7 @@ public final class PixelListComponentTree< T extends Type< T > > implements Comp | |||
* using an {@link ArrayImgFactory} or {@link CellImgFactory} depending on | |||
* input image size. | |||
* | |||
* @implNote op name='create.pixelListComponentTree',type=Function | |||
* @param input |
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.
Like above, should these be ops?
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.
Can we use a sub-namespace of create
here? create.componentTree.pixelList
, create.componentTree.mser
, and so on? It would match the package naming. In general, looking at the Java package naming is a good starting point for naming suggestions.
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.
Actually... are these really "create" Ops? I think of create
as merely allocating and returning an object instance, not doing any computation around an image. So this PixelListComponentTree
shouldn't be a create
Op at all, since it accepts an existing image as input. morphology.componentTree.pixelList
maybe? I don't know this space of image algorithms well enough to feel qualified to suggest anything. We could use @tpietzsch's input here, since he wrote these classes. And/or just read the papers about these things.
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.
It actually seems to be like the tree best belongs to the features
namespace, as it is my understanding that component trees themselves have distilled down a 2D function into a tree, where the position is lost. This seems more like feature extraction than morphology.
src/main/java/net/imglib2/algorithm/edge/SubpixelEdgelDetection.java
Outdated
Show resolved
Hide resolved
src/main/java/net/imglib2/algorithm/localextrema/LocalExtrema.java
Outdated
Show resolved
Hide resolved
src/main/java/net/imglib2/algorithm/morphology/StructuringElements.java
Outdated
Show resolved
Hide resolved
src/main/java/net/imglib2/algorithm/util/ParallelizeOverBlocks.java
Outdated
Show resolved
Hide resolved
@@ -56,6 +56,8 @@ public class Kernel1D | |||
* @param halfKernel | |||
* the upper half (starting at the center pixel) of the symmetric | |||
* convolution kernel. | |||
* @return a {@link Kernel1D} used for one dimensional convolutions | |||
* @implNote op name='create.kernel1DSymmetric' |
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.
Should these be Ops? What is the right name?
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.
Would it make sense to group all the kernel creation ops into create.kernel.
sub-namespace? E.g. create.kernel.symmetric1D
? Or maybe create.kernel1D.symmetric
since these all return Kernel1D
objects. Not sure...
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.
OK, I expressed some opinions. Hope it helps.
src/main/java/net/imglib2/algorithm/morphology/StructuringElements.java
Outdated
Show resolved
Hide resolved
@@ -122,6 +122,7 @@ public static enum DISTANCE_TYPE | |||
* should be squared, too). | |||
* @param <T> | |||
* {@link RealType} input | |||
* @implNote op name='image.distanceTransform', type=Inplace1 |
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.
This can be morphology.distanceTransform
.
@@ -105,7 +105,8 @@ public final class MserTree< T extends Type< T > > implements ComponentForest< M | |||
* {@link #buildMserTree(RandomAccessibleInterval, RealType, long, long, double, double, ImgFactory, boolean)} | |||
* using an {@link ArrayImgFactory} or {@link CellImgFactory} depending on | |||
* input image size. | |||
* |
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.
And I guess this article is relevant.
@@ -105,7 +105,8 @@ public final class MserTree< T extends Type< T > > implements ComponentForest< M | |||
* {@link #buildMserTree(RandomAccessibleInterval, RealType, long, long, double, double, ImgFactory, boolean)} | |||
* using an {@link ArrayImgFactory} or {@link CellImgFactory} depending on | |||
* input image size. | |||
* |
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.
While we are figuring this stuff out, we should improve the javadoc. Every algorithm should cite the paper(s) it is about in its class javadoc. A "component tree" in the context of the componenttree
packages is explained in papers like this one; without that context, it is difficult to understand what all this code is for.
@@ -105,7 +105,8 @@ public final class MserTree< T extends Type< T > > implements ComponentForest< M | |||
* {@link #buildMserTree(RandomAccessibleInterval, RealType, long, long, double, double, ImgFactory, boolean)} | |||
* using an {@link ArrayImgFactory} or {@link CellImgFactory} depending on | |||
* input image size. | |||
* |
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.
Concepts of level sets, mathematical morphology, and connected component analysis are very related. We have CCA currently in labeling
, but other morphology operators in morphology
. What about level sets? FWIW, I checked scikit-image for comparison, and use of level sets mostly takes place in skimage.segmentation.morphsnakes
.
src/main/java/net/imglib2/algorithm/morphology/StructuringElements.java
Outdated
Show resolved
Hide resolved
src/main/java/net/imglib2/algorithm/morphology/StructuringElements.java
Outdated
Show resolved
Hide resolved
src/main/java/net/imglib2/algorithm/morphology/StructuringElements.java
Outdated
Show resolved
Hide resolved
@@ -78,7 +78,8 @@ public class TopHat | |||
* decomposition. Each shape is processed in order as given in the list. If | |||
* the list is empty, the source image is returned. | |||
* <p> | |||
* | |||
* | |||
* @implNote op names='morphology.topHat, morphology.whiteTopHat', type=Function |
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.
Let's drop the morphology.topHat
alias, in favor of whiteTopHat
always, for symmetry with blackTopHat
. That's what scikit-image does.
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.
Heh, SciJava Ops Image currently only uses morphology.topHat
. I agree that symmetry would be good, but I'm also tempted to leave in the aliases. Maybe we can deprecate that soon?
These are TBD and are not currently used by anyone, so we can re-opify them later!
Should probably be all lowercase
These Ops are not used, and there is ambiguity about how they might be used so let's punt on the decision to opify
a6393d0
to
4836d65
Compare
This PR uses therapi-runtime-javadoc to declare all static functionality in imglib2-alrogithm as Ops. See this test for how these Ops can be called, and the module
imglib/imglib2-algorithm-optest
for an example of the structure required to call these annotated methods as Ops.A new dependency on
therapi-runtime-javadoc-scribe
is added to the maven compiler plugin. For now, this was added to the imglib2-algorithm POM. Oncepom-scijava-base
15.0.0 is propagated to imglib2-algorithm, we can remove almost everything added to this POM by this PR.The only line needed once we depend on that version of
pom-scijava-base
is this line, which is responsible for informing therapi-runtime-javadoc-scribe of the set of packages it should process. This line must be changed once we bump the version, as the property used is under a different name.Using
therapi-runtime-javadoc-scribe
, JSON files are generated for each file containing javadoc in each package specified bytherapi.packages
Open questions:
"class.method_name"
, which might match well with how these methods would be called from a static context...org.scijava.function.Computer
s with their output parameter in a position that is not the last one; for these, I have added another method with a different parameter ordering. Other methods do not conform to Op types, such as theHessianMatrix
methods. We could easily write a newFunctionalInterface
for these guys, but they wouldn't have the support ofOpBuilder
, adaptation, etc.TODO: