3838import net .imglib2 .view .Views ;
3939
4040import org .scijava .function .Computers ;
41+ import org .scijava .ops .api .OpMetadata ;
42+ import org .scijava .ops .api .RichOp ;
43+ import org .scijava .ops .api .features .BaseOpHints ;
4144
4245/**
4346 * Evaluates a {@link UnaryComputerOp} for each {@link Neighborhood} on the
@@ -88,7 +91,7 @@ public void compute(final RandomAccessibleInterval<I> in1, final Shape in2,
8891 * We also assume that the input and output have identical dimensions.
8992 *
9093 * @author Gabriel Selzer
91- *@implNote op names='map.neighborhood', priority='100.'
94+ * @implNote op names='map.neighborhood', priority='100.'
9295 */
9396class MapNeighborhoodAllRAI <I , O > implements
9497 Computers .Arity3 <RandomAccessibleInterval <I >, Shape , Computers .Arity1 <Iterable <I >, O >, RandomAccessibleInterval <O >>
@@ -104,17 +107,33 @@ class MapNeighborhoodAllRAI<I, O> implements
104107 */
105108 @ Override
106109 public void compute (final RandomAccessibleInterval <I > in1 , final Shape in2 ,
107- final Computers .Arity1 <Iterable <I >, O > centerAwareOp ,
110+ final Computers .Arity1 <Iterable <I >, O > op ,
108111 final RandomAccessibleInterval <O > out )
109112 {
110113 // generate a neighborhood image with the bounds of the input
111114 RandomAccessibleInterval <Neighborhood <I >> neighborhoodInput = Views
112115 .interval (in2 .neighborhoodsRandomAccessibleSafe (in1 ), in1 );
113116
117+ boolean restoreRecording = true ;
118+ if (op instanceof RichOp ) {
119+ OpMetadata metadata = ((RichOp ) op ).metadata ();
120+ if (metadata .hints ().contains (BaseOpHints .History .SKIP_RECORDING )) {
121+ restoreRecording = false ;
122+ } else {
123+ metadata .setHints (metadata .hints ().plus (BaseOpHints .History .SKIP_RECORDING ));
124+ }
125+ }
126+
114127 LoopBuilder .setImages (neighborhoodInput , out ).multiThreaded ()
115128 .forEachPixel ((neighborhood , outPixel ) -> {
116- centerAwareOp .compute (neighborhood , outPixel );
129+ op .compute (neighborhood , outPixel );
117130 });
131+
132+ if (restoreRecording && op instanceof RichOp ) {
133+ OpMetadata metadata = ((RichOp ) op ).metadata ();
134+
135+ metadata .setHints (metadata .hints ().minus ( BaseOpHints .History .SKIP_RECORDING ));
136+ }
118137 }
119138
120139}
0 commit comments