-
Notifications
You must be signed in to change notification settings - Fork 42
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
Port kernels #48
Port kernels #48
Conversation
@bnorthan if you could add to the commit message a note about the relicensing and that it was actually Jean-Yves Tinevez' code, that would be awesome! 👍 from me! |
Thanks @tinevez. It was definitely "ported" (copy, paste, refactor as needed, test) so I'll add a note about the relicensing. That is very helpful short term. ( Long term @dscho mentioned we should consider an ops-based gpl repository for deconvolution. I think this is a good idea. Perhaps it should be a little more general. Maybe an ops repository geared towards advanced image processing algorithms with gpl license?? ). |
cfa6674
to
77888f5
Compare
Renamed 'FromNumDimensions' to 'NDD'. NDD stands for N-dimensional-dynamic. That means the kernel size is determined from the other inputs (for example sigma and calibrations). The reason for the distinction is that in the future there might be a different interface that takes the kernel size explicitly. Let me know if this makes sense. And how does the rest of it look?? Thanks. |
Oh, I forgot to say that I only pointed out things that are not brilliant ;-) 👍 from my side! |
@bnorthan: Is this good to merge? Or is there further work that needs to happen first? |
It's almost there but I fixed something and added a test. I'll let you On Fri, Sep 19, 2014 at 3:05 PM, Curtis Rueden notifications@github.com
|
77888f5
to
be7d537
Compare
Hi Curtis - I think this should be reviewed by @dietzc when he gets back home and gets a chance (given his experience with knime filters). A couple of things have just come to mind: a) this is an extension of create so there will be many variations of source (create from Img, create from ImgPlus, create from Type) and parameters (create from given dimensions, calculate dimension from parameters (such as sigma)). I've only implemented one case. So your plans regarding "converting" ops will be relevant here for other cases. b) there are a few other subtle issues. For example the Gaussian code was originally written for doubles and integer types would have to be handled a bit differently. |
dd30600
to
d06768b
Compare
I changed things a bit to be compatible with the latest work done at the Hackathon. a) interfaces now added via the Ops.list file. b) CreateLog/GaussKernel should really extend a createimg class. I did not see a very simple AbstractCreateImg (create from type and factory then dimensions and values are determined by derived classes) so I added one. Let me know if this makes sense. |
f244b92
to
8547159
Compare
@dietzc Any comments? |
I like it, as it is really thin and straightforward implemented. I added some comments to the commit. Here are some additionally notes:
Hope this helps! |
Thanks for the feedback @dietzc I should have time to make the updates later this week or early next. |
Log is the Laplacian of Gaussian kernel, a high pass kernel used for edge and blob detection.
6e923dd
to
a02646c
Compare
Hi Christian - I am changing the interface to support different sigmas for each dimension but I am getting an error when trying to pass in a double[] Parameter to the op. It appears to me that it is looking for a 2D double array for the last parameter ([D [D@49d5e6da). Or perhaps I am not understanding the error message?? Have you guys had any problems passing arrays to ops? I expected the op service to match the "CreateGaussianKernel" op. But for some reason it is reporting that op as {!INVALID}. What does that mean?? That the signature did not match?? Or something else is wrong with the op?? gausskernel(net.imglib2.img.array.ArrayImgFactory net.imglib2.img.array.ArrayImgFactory@321236f4, net.imglib2.type.numeric.real.FloatType 0.0, java.lang.Integer 2, [D [D@49d5e6da) |
it seems that you have to pass two arrays? one for the sigmas and one for the calibration?! |
a02646c
to
4bad4a7
Compare
@dietzc, @ctrueden Hi Christian - actually it wasn't that... the calibration is an optional parameter. It was something else stupid I did in the AbstractCreateKernel class. So ignore the question I had, everything is good now. Thanks for your feedback. I implemented the changes you suggested I just need to look things over a couple of more times. I'll let you know when it's finalized. |
a6c5c82
to
c8fa174
Compare
Suggested changes made and tested except for this part.
Still thinking about the best way to do this. Are you aware of any examples using default factory and type to create an image?? |
The script did not work even with my changes because I only added 'AbstractCreateDefaultImg'. If I add a new create class that derives from 'AbstractCreateDefaultImg' it works. I called it DefaultCreateDefaultImg. I can change the name if you have a suggestion. It uses FloatType and PlanarFactory for defaults if nothing is specified. I can change this too. Any opinion on what should the defaults be?? This class is here. |
Thanks @bnorthan I would (always) prefer to use one thing which I just discovered: https://github.com/imagej/imagej-ops/blob/port_kernels/src/main/java/net/imagej/ops/create/AbstractCreateImg.java be unifided with @ctrueden any suggestions? |
@dietzc you will have to consider the case where |
AbstractCreateImg is an abstract class that creates an image from a type and factory. The logic to determine the size and values of the image is implemented in the derived classes. For example CreateImgDefault (which has been modified to derive from AbstractCreateImg) creates an empty image from given dimensions.
Added the CreateLogKernel class. Creates a Laplacian of Gaussian kernel that can be used for blob detection. Ported from: fiji.plugin.trackmate.detection.DetectionUtilities. Permission granted by Jean-Yves Tinevez to change license from GPL.
Creates a Gaussian Kernel. Ported from: org.knime.knip.core.algorithm.convolvers.filter.linear.Gaussian
Changed this class to inherit from AbstractCreateImg. The class will inherit the outType and the factory as optional parameters. So images can now be created passing only the dimensions.
KernelTest tests that the kernels run and asserts that the generated kernel is the correct width.
@dietzc good idea, I merged the classes as you suggested. I did not use ArrayImgFactory as the default though. There could be problems with very large images. Of course planar will have problems too if the images are very large and you would need a cell image. So it seems that eventually something is needed like "SmartImgFactory" that creates the right type based on size and available memory... but I don't see that anything like that currently exists in imglib2. |
My suggestion for default would be to use a heuristic. If the requested image size is small enough, use |
The previous default createimg implementation used DoubleType, and at the moment, various code paths only work for that case. In particular, the README example needs a DoubleType image. Just so that we can get the PR #48 merged right now, let's continue using DoubleType for the very short term. In the longer term, it will become paramount to better differentiate between different types of Img objects at runtime, to avoid mismatched ops and ClassCastExceptions. See issue #95.
We had to switch the |
👍 |
I've been working on porting kernel generation. At this point still looking for feedback on the design.
So far I've ported the Gaussian kernel and the Log kernel from pre-existing sources (knime and trackmate). Both of these follow the same pattern.
a) the number of dimensions is defined.
b) the radius (or sigma) is defined as a double
c) the size of each dimensions in pixels is determined by the radius
I've tried for a class hierchy that will handle these implementations but is flexible as to future variations.