File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
src/main/java/net/imglib2/algorithm/math/abstractions Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 11package net .imglib2 .algorithm .math .abstractions ;
22
3+ import java .util .HashSet ;
34import java .util .Iterator ;
45import java .util .LinkedList ;
6+ import java .util .Set ;
57
68import net .imglib2 .RandomAccessibleInterval ;
79import net .imglib2 .algorithm .math .ImgSource ;
@@ -76,4 +78,36 @@ else if ( o instanceof IFunction )
7678 // Make it fail
7779 return null ;
7880 }
81+
82+ static public final Set < RandomAccessibleInterval < ? > > findImg ( final IFunction f )
83+ {
84+ final Set < RandomAccessibleInterval < ? > > images = new HashSet <>();
85+ final LinkedList < IFunction > ops = new LinkedList <>();
86+ ops .add ( f );
87+
88+ // Iterate into the nested operations
89+ while ( ! ops .isEmpty () )
90+ {
91+ final IFunction op = ops .removeFirst ();
92+
93+ if ( op instanceof ImgSource )
94+ images .add ( ( ( ImgSource < ? > )op ).getRandomAccessibleInterval () );
95+ else if ( op instanceof IUnaryFunction )
96+ {
97+ ops .addLast ( ( ( IUnaryFunction )op ).getFirst () );
98+
99+ if ( op instanceof IBinaryFunction )
100+ {
101+ ops .addLast ( ( ( IBinaryFunction )op ).getSecond () );
102+
103+ if ( op instanceof ITrinaryFunction )
104+ {
105+ ops .addLast ( ( ( ITrinaryFunction )op ).getThird () );
106+ }
107+ }
108+ }
109+ }
110+
111+ return images ;
112+ }
79113}
You can’t perform that action at this time.
0 commit comments