protected void connectInner(GrayS32 input, GrayS32 output) {

		int startX = connectRule == ConnectRule.EIGHT ? 1 : 0;

		for( int y = 0; y < input.height-1; y++ ) {
			int indexIn = input.startIndex + y*input.stride + startX;
			int indexOut = output.startIndex + y*output.stride + startX;

			for( int x = startX; x < input.width-1; x++ , indexIn++, indexOut++) {
				int inputLabel = input.data[indexIn];
				int outputLabel = output.data[indexOut];
				if( outputLabel == -1 ) { // see if it needs to create a new output segment
					output.data[indexOut] = outputLabel = regionMemberCount.size;
					regionMemberCount.add(1);
					mergeList.add(outputLabel);
				}

				for( int i = 0; i < edgesIn.length; i++ ) {
					if( inputLabel == input.data[indexIn+edgesIn[i]] ) {
						int outputAdj = output.data[indexOut+edgesOut[i]];
						if( outputAdj == -1 ) {  // see if not assigned
							regionMemberCount.data[outputLabel]++;
							output.data[indexOut+edgesOut[i]] = outputLabel;
						} else if( outputLabel != outputAdj ) { // see if assigned to different regions
							markMerge(outputLabel,outputAdj);
						} // do nothing, same input and output labels
					}
				}
			}
		}
	}
protected void connectInner ( GrayS32 input , GrayS32 output ) { int startX = connectRule == ConnectRule . EIGHT ? 1 : 0 ; for ( int y = 0 ; y < input . height - 1 ; y ++ ) { int indexIn = input . startIndex + y * input . stride + startX ; int indexOut = output . startIndex + y * output . stride + startX ; for ( int x = startX ; x < input . width - 1 ; x ++ , indexIn ++ , indexOut ++ ) { int inputLabel = input . data [ indexIn ] ; int outputLabel = output . data [ indexOut ] ; if ( outputLabel == - 1 ) { output . data [ indexOut ] = outputLabel = regionMemberCount . size ; regionMemberCount . add ( 1 ) ; mergeList . add ( outputLabel ) ; } for ( int i = 0 ; i < edgesIn . length ; i ++ ) { if ( inputLabel == input . data [ indexIn + edgesIn [ i ] ] ) { int outputAdj = output . data [ indexOut + edgesOut [ i ] ] ; if ( outputAdj == - 1 ) { regionMemberCount . data [ outputLabel ] ++ ; output . data [ indexOut + edgesOut [ i ] ] = outputLabel ; } else if ( outputLabel != outputAdj ) { markMerge ( outputLabel , outputAdj ) ; } } } } } }
Examines pixels inside the image without the need for bounds checking