docs: protected void connectLeftRight(GrayS32 input, GrayS32 output) {
  		for( int y = 0; y < input.height; y++ ) {
  			int x = input.width-1;
  
  			int inputLabel = input.unsafe_get(x, y);
  			int outputLabel = output.unsafe_get(x, y);
  
  			if( outputLabel == -1 ) { // see if it needs to create a new output segment
  				outputLabel = regionMemberCount.size;
  				output.unsafe_set(x,y,outputLabel);
  				regionMemberCount.add(1);
  				mergeList.add(outputLabel);
  			}
  
  			// check right first
  			for( int i = 0; i < edges.length; i++ ) {
  
  				Point2D_I32 offset = edges[i];
  
  				// make sure it is inside the image
  				if( !input.isInBounds(x+offset.x,y+offset.y))
  					continue;
  
  				if( inputLabel == input.unsafe_get(x+offset.x,y+offset.y) ) {
  					int outputAdj = output.unsafe_get(x+offset.x,y+offset.y);
  					if( outputAdj == -1 ) {  // see if not assigned
  						regionMemberCount.data[outputLabel]++;
  						output.unsafe_set(x+offset.x,y+offset.y, outputLabel);
  					} else if( outputLabel != outputAdj ) { // see if assigned to different regions
  						markMerge(outputLabel,outputAdj);
  					} // do nothing, same input and output labels
  				}
  			}
  
  			// skip check of left of 4-connect
  			if( connectRule != ConnectRule.EIGHT )
  				continue;
  
  			x = 0;
  
  			inputLabel = input.unsafe_get(x, y);
  			outputLabel = output.unsafe_get(x, y);
  
  			if( outputLabel == -1 ) { // see if it needs to create a new output segment
  				outputLabel = regionMemberCount.size;
  				output.unsafe_set(x,y,outputLabel);
  				regionMemberCount.add(1);
  				mergeList.add(outputLabel);
  			}
  
  			for( int i = 0; i < edges.length; i++ ) {
  				Point2D_I32 offset = edges[i];
  
  				// make sure it is inside the image
  				if( !input.isInBounds(x+offset.x,y+offset.y))
  					continue;
  
  				if( inputLabel == input.unsafe_get(x+offset.x,y+offset.y) ) {
  					int outputAdj = output.unsafe_get(x+offset.x,y+offset.y);
  					if( outputAdj == -1 ) {  // see if not assigned
  						regionMemberCount.data[outputLabel]++;
  						output.unsafe_set(x+offset.x,y+offset.y, outputLabel);
  					} else if( outputLabel != outputAdj ) { // see if assigned to different regions
  						markMerge(outputLabel,outputAdj);
  					} // do nothing, same input and output labels
  				}
  			}
  		}
  	}