Buggy code:
public class UCMOp < L extends Comparable < L > , T extends RealType < T > > implements BinaryOperation < Labeling < L > , RandomAccessibleInterval < T > , RandomAccessibleInterval < FloatType > > { private final int maxNumFaces ; private final double maxFacePercent ; private final int minBoundaryWeight ; private final String boundaryLabel ; public UCMOp ( final int paramMaxNumFaces , final double paramMaxFacePercent , final int paramMinBoundaryWeight , final String paramBoundaryLabel ) { } @ Override public RandomAccessibleInterval < FloatType > compute ( final Labeling < L > labeling , final RandomAccessibleInterval < T > inImg , final RandomAccessibleInterval < FloatType > result ) { if ( ( ( labeling . numDimensions ( ) ) != ( inImg . numDimensions ( ) ) ) && ( ( inImg . numDimensions ( ) ) != ( result . numDimensions ( ) ) ) ) { throw new IllegalArgumentException ( "Dimensions<seq2seq4repair_space>do<seq2seq4repair_space>not<seq2seq4repair_space>match." ) ; } if ( ( labeling . numDimensions ( ) ) != 2 ) { throw new IllegalArgumentException ( "Only<seq2seq4repair_space>two<seq2seq4repair_space>dimension<seq2seq4repair_space>are<seq2seq4repair_space>supported." ) ; } final HashMap < String , UCMFace > faces = new HashMap < String , UCMFace > ( ) ; final ArrayList < UCMBoundary > boundaries = new ArrayList < UCMBoundary > ( ) ; final RandomAccess < FloatType > resultAccess = result . randomAccess ( ) ; final RandomAccess < T > imgAccess = inImg . randomAccess ( ) ; for ( L label : labeling . getLabels ( ) ) { faces . put ( label . toString ( ) , new UCMFace ( label . toString ( ) ) ) ; } final Cursor < LabelingType < L > > labCur = labeling . localizingCursor ( ) ; <START_BUG> final RandomAccess < LabelingType < L > > labAccess = Views . extendValue ( labeling , null ) . randomAccess ( ) ; <END_BUG> final long [ ] [ ] strucElement = AbstractRegionGrowing . get8ConStructuringElement ( labeling . numDimensions ( ) ) ; final long [ ] [ ] ring16 = ring16dim2 ( ) ; if ( ( labeling . numDimensions ( ) ) != 2 ) { posRing ( ring16 , labeling . numDimensions ( ) , 2 ) ; } HashSet < String > tempLabels = null ; while ( labCur . hasNext ( ) ) { labCur . fwd ( ) ; if ( labCur . get ( ) . getLabeling ( ) . get ( 0 ) . toString ( ) . equals ( boundaryLabel ) ) { tempLabels = new HashSet < String > ( ) ; for ( int s = 0 ; s < ( strucElement . length ) ; s ++ ) { for ( int d = 0 ; d < ( labeling . numDimensions ( ) ) ; d ++ ) { labAccess . setPosition ( ( ( labCur . getLongPosition ( d ) ) + ( strucElement [ s ] [ d ] ) ) , d ) ; if ( ( labAccess . get ( ) ) != null ) { L label = labAccess . get ( ) . getLabeling ( ) . get ( 0 ) ; if ( ! ( label . toString ( ) . equals ( boundaryLabel ) ) ) { tempLabels . add ( label . toString ( ) ) ; } } } } if ( ( tempLabels . size ( ) ) < 2 ) { for ( int s = 0 ; s < ( ring16 . length ) ; s ++ ) { for ( int d = 0 ; d < ( labeling . numDimensions ( ) ) ; d ++ ) { try { labAccess . setPosition ( ( ( labCur . getLongPosition ( d ) ) + ( ring16 [ s ] [ d ] ) ) , d ) ; } catch ( Exception e ) { continue ; } if ( ( labAccess . get ( ) ) != null ) { String label = labAccess . get ( ) . getLabeling ( ) . get ( 0 ) . toString ( ) ; if ( ! ( label . toString ( ) . equals ( boundaryLabel ) ) ) { tempLabels . add ( label ) ; } } } } } HashMap < String , UCMBoundary > tempBoundaryMap = null ; UCMBoundary tempBoundary = null ; for ( String firstLabel : tempLabels ) { tempBoundaryMap = faces . get ( firstLabel ) . getBoundaries ( ) ; for ( String secondLabel : tempLabels ) { if ( ( firstLabel . compareTo ( secondLabel ) ) >= 0 ) { continue ; } int [ ] pos = new int [ labCur . numDimensions ( ) ] ; labCur . localize ( pos ) ; tempBoundary = tempBoundaryMap . get ( secondLabel ) ; if ( tempBoundary == null ) { UCMFace faceA = faces . get ( firstLabel ) ; UCMFace faceB = faces . get ( secondLabel ) ; tempBoundary = new UCMBoundary ( ) ; tempBoundary . getFaces ( ) . add ( faceA ) ; tempBoundary . getFaces ( ) . add ( faceB ) ; boundaries . add ( tempBoundary ) ; faceA . addBoundary ( secondLabel , tempBoundary ) ; faceB . addBoundary ( firstLabel , tempBoundary ) ; } try { imgAccess . setPosition ( pos ) ; tempBoundary . addPixel ( pos , imgAccess . get ( ) . getRealDouble ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } } } } Collections . sort ( boundaries ) ; final double maxFacesSize = faces . size ( ) ; double facesWished = maxNumFaces ; if ( facesWished < 1 ) { facesWished = 1 ; } double calcedMaxFacePercent = ( maxFacePercent ) // 100 ; if ( calcedMaxFacePercent < 0.01 ) { calcedMaxFacePercent = 0.01 ; } boolean drawAllowed = false ;

Fix:
final RandomAccess < LabelingType < L > > labAccess = Views . extendBorder ( labeling ) . randomAccess ( ) ;