Comments (14)
I guess this does the trick?!
Yes! Works like classical methods from the Collections framework, but returns instance to "this".
Isn't that some kind of builder pattern?
To be honest, I do not really know... Returning an instance to this is typical from the Builder pattern, but the builder approaches I have seen often use two different classes: one for the builder, another one for the main class. Here, there is no "build()" method at the end.
Or maybe the MorphometricFeatures2D class can be seen as a builder for a ResultsTable!
from morpholibj.
Hi!
a small follow-up, I have just pushed the refactoring of the AnalyzeRegions3D plugin to use a new MorphometricFeatures3D based on the same principle that the 2D equivalent.
Everything seems to work fine: same behaviour as before, and it is now possible to choose features programmatically.
I am just not totally satisfied with management of options, but this will be for a future enhancement.
On the roadmap is also the refactoring of the dialogs for analysis of regions. This may take some time however.
from morpholibj.
Hi @tischi,
I do not think this is possible. When using an ImageJ plugin, one has to rely on the "run" method.
One way could be to split the implementation, such that the plugin class only manages the GUI. I plan to refactor the Analyze regions plugins in a near future, so maybe I can also add this feature, if it is possible and not too hard.
from morpholibj.
Thanks! A very easy fix would be to make the boolean variables public
. What do you think?
from morpholibj.
Hi,
yes, you're right, this could be a quick fix! I try to have a look soon!
from morpholibj.
@dlegland any progress on this front? :-)
from morpholibj.
Hi,
not much at the moment,
but I plan to check this when I come back from holidays. hopefully end of august or beginning of september...
best,
David
from morpholibj.
Hi,
I just pushed a commit that updates the AnayzeRegions plugins.
It introduces an inner class "Features", that contains public boolean fields for selecting the features to compute. Example:
// creates a new Features instance to select the features to compute.
AnalyzeRegions.Features features = new AnalyzeRegions.Features();
features.setAll(false);
features.area = true;
features.perimeter = true;
features.centroid = true;
// compute the features, and returns the corresponding table
ResultsTable table = AnalyzeRegions.process(imagePlus, features);
table.show("Morphometry");
Feedback welcome!
from morpholibj.
Proposition from @oburri: use a Builder type approach.
ResultsTable table = AnalyzeRegions.create( imagePlus )
.getArea()
.getPerimeter()
.getCentroid()
.compute();
from morpholibj.
In case you're interested in this kind of Builder Pattern refactoring, I'd be happy to help, as I do love MorphoLibJ
from morpholibj.
I finally arrived at a new refactoring of the AnalyzeRegions class!
The main thing is that the computation part is now managed by the "MorphometricFeartures2D" class (within inra.ijpb.analyze.regions2d package). I was trying with builder type approach, but finally used a collection features (instances of the inner "Feature" enum). A typical call can be as follow:
ResultsTable table = new MorphometricFeatures2D()
.add(Feature.AREA)
.add(Feature.PERIMETER)
.add(Feature.CENTROID)
.computeTable(imagePlus);
An alternative with adequate static imports:
ResultsTable table = new MorphometricFeatures2D(AREA, PERIMETER, CENTROID)
.computeTable(imagePlus);
The AnalyzeRegions have been updated to call the MorphometricFeatures2D class. The AnalyzeRegions.Features class have been deprecated, and the code was adapted to use the MorphometricFeatures2D class. It seems to work as previously.
I would lije to have a more generic approach, that would allow to add new user-defined features without having to change code in MorphoLibJ, but I could not yet find a simple enough solution...
from morpholibj.
- Thank you very much! Looks beautiful!
- What happens if one does this:
ResultsTable table = new MorphometricFeatures2D().computeTable(imagePlus);
does one get all or none? - Will that also work in 3D with the same API?
- finally used a collection features (instances of the inner "Feature" enum). I am intrigued, could you post a link to the code?
from morpholibj.
Thank you very much! Looks beautiful!
Thank you! I hope this will be more scriptable than the AnalyzeRegions plugin, and that this will not be too complicated to maintain by introducing new features...
What happens if one does this: ResultsTable table = new MorphometricFeatures2D().computeTable(imagePlus); does one get all or none?
One get an empty table. Only the region label is provided.
Will that also work in 3D with the same API?
Yes! working on it... nearly ready, I just would like to enhance unit tests and general checks.
finally used a collection features (instances of the inner "Feature" enum). I am intrigued, could you post a link to the code?
Sure! the main class is MorphometricFeatures2D.java. It encapsulates an enum class MorphometricFeatures2D.Feature. This enumeration lists the different features that can be computed with the AnalyzeRegions plugin. Then, the computeTable method populates the results table from an ImagePlus containing a 2D label map.
In practice, most of the computations are performed within specialized feature analyzers (like Centroid, EquivalentEllipse...). The MorphometricFeatures2D.computeTable method calls them is the appropriate way (to manage dependencies), then populates the table from the various results.
from morpholibj.
I see!
public MorphometricFeatures2D add(Feature f)
{
features.add(f);
return this;
}
I guess this does the trick?! Isn't that some kind of builder pattern?
from morpholibj.
Related Issues (20)
- MorphoLibJ as a dependency versions conflict HOT 21
- croplabel() , set pixel/voxel size and origin of the cropped image HOT 3
- MorphoLibJ is on bioconda HOT 1
- measurements should contain an additional column with image calibration unit
- Fill holes in labels HOT 4
- Erode labels HOT 4
- Suggestion for Intensity Measurements and Analyze Regions commands HOT 1
- orientation features in 2D have different ranges
- enhance analysis of timelapse images HOT 2
- closing close to image boundary HOT 2
- plugin “Draw Table Values” should be scriptable
- Issue with the ‘Label Edition’ plugin
- Label Morphological Filter: Erosion Operation for touching labels HOT 7
- Remove Border Labels does not work on Virtual stacks
- MorpholibJ Draw Table Value plugin error HOT 1
- Using Distance Transform Watershed without a GUI / UI HOT 6
- "Fill Label Holes" plugin results in full-white image when applied to binary image
- Typo in MorphologicalSegmentation.java HOT 1
- Error when applying opening/closing with an ellipsoid structuring element HOT 4
- add "skeleton geodesic diameter" to "Analyze Regions" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from morpholibj.