There is one thing in imglib2 where I regularly “shoot myself in the foot”, citing Tobias .
It is this pattern:
RandomAccessibleInterval< BitType > mask = Converters.convert( rai, ( i, o ) -> o.set( i.getRealDouble() > threshold ? true : false ), new BitType() ) ); mask.randomAccess().get().set( false ); // this line has no effect
Basically, modifying pixel values in an image that has been obtained through a converter has no effect.
The problem is that it also does not crash and is thus very hard to debug.
Is there any generic way of avoiding this?