@Override public double unsafe_getD(int x, int y) { return image.unsafe_get(x,y); }
@Override public float unsafe_getF(int x, int y) { return image.unsafe_get(x,y); }
private void _transform(GrayS32 derivX , GrayS32 derivY , GrayU8 binary ) { // apply the transform to the entire image for( int y = 0; y < binary.height; y++ ) { int start = binary.startIndex + y*binary.stride; int end = start + binary.width; for( int index = start; index < end; index++ ) { if( binary.data[index] != 0 ) { int x = index-start; parameterize(x,y,derivX.unsafe_get(x,y),derivY.unsafe_get(x,y)); } } } } }
for (int y = 0; y < segments.height; y++) { for (int x = 0; x < segments.width; x++) { int index = segments.unsafe_get(x, y); if (index == 0) output.setRGB(x, y, 0xFF0000); for (int y = 0; y < segments.height; y++) { for (int x = 0; x < segments.width; x++) { int index = segments.unsafe_get(x, y); if (index == 0) { for (int i = -radius; i <= radius; i++) {
for (int y = 0; y < segments.height; y++) { for (int x = 0; x < segments.width; x++) { int index = segments.unsafe_get(x, y); if (index == 0) output.setRGB(x, y, 0xFF0000); for (int y = 0; y < segments.height; y++) { for (int x = 0; x < segments.width; x++) { int index = segments.unsafe_get(x, y); if (index == 0) { for (int i = -radius; i <= radius; i++) {
/** * Draws each region using the provided color * @param pixelToRegion Conversion from pixel to region * @param segmentColor Color of each region * @param output Storage for output image. Can be null. * @return Output image. */ public static BufferedImage regionsColor( GrayS32 pixelToRegion , FastQueue<float[]> segmentColor , BufferedImage output ) { if( output == null ) output = new BufferedImage(pixelToRegion.width,pixelToRegion.height,BufferedImage.TYPE_INT_RGB); for( int y = 0; y < pixelToRegion.height; y++ ) { for( int x = 0; x < pixelToRegion.width; x++ ) { int index = pixelToRegion.unsafe_get(x,y); float []cv = segmentColor.get(index); int r,g,b; if( cv.length == 3 ) { r = (int)cv[0]; g = (int)cv[1]; b = (int)cv[2]; } else { r = g = b = (int)cv[0]; } int rgb = r << 16 | g << 8 | b; output.setRGB(x, y, rgb); } } return output; }
/** * Draws each region using the provided color * @param pixelToRegion Conversion from pixel to region * @param segmentColor Color of each region * @param output Storage for output image. Can be null. * @return Output image. */ public static BufferedImage regionsColor( GrayS32 pixelToRegion , FastQueue<float[]> segmentColor , BufferedImage output ) { if( output == null ) output = new BufferedImage(pixelToRegion.width,pixelToRegion.height,BufferedImage.TYPE_INT_RGB); for( int y = 0; y < pixelToRegion.height; y++ ) { for( int x = 0; x < pixelToRegion.width; x++ ) { int index = pixelToRegion.unsafe_get(x,y); float []cv = segmentColor.get(index); int r,g,b; if( cv.length == 3 ) { r = (int)cv[0]; g = (int)cv[1]; b = (int)cv[2]; } else { r = g = b = (int)cv[0]; } int rgb = r << 16 | g << 8 | b; output.setRGB(x, y, rgb); } } return output; }
/** * Examines pixels along the bottom border */ protected void connectBottom(GrayS32 input, GrayS32 output) { for( int x = 0; x < input.width-1; x++ ) { int y = input.height-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); } // for 4 and 8 connect the check is only +1 x and 0 y if( inputLabel == input.unsafe_get(x+1,y) ) { int outputAdj = output.unsafe_get(x+1,y); if( outputAdj == -1 ) { // see if not assigned regionMemberCount.data[outputLabel]++; output.unsafe_set(x+1,y, outputLabel); } else if( outputLabel != outputAdj ) { // see if assigned to different regions markMerge(outputLabel,outputAdj); } // do nothing, same input and output labels } } } }
int x = input.width-1; int inputLabel = input.unsafe_get(x, y); int outputLabel = output.unsafe_get(x, 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]++; inputLabel = input.unsafe_get(x, y); outputLabel = output.unsafe_get(x, 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]++;
for( int y = 0; y < pixelToRegion.height; y++ ) { for( int x = 0; x < pixelToRegion.width; x++ ) { int index = pixelToRegion.unsafe_get(x,y); float []cv = segmentColor.get(index);
for( int y = 0; y < pixelToRegion.height; y++ ) { for( int x = 0; x < pixelToRegion.width; x++ ) { int index = pixelToRegion.unsafe_get(x,y); float []cv = segmentColor.get(index);
int candidateId = pixelToRegion.unsafe_get(x,y);