input.get(j,y, pixel); for (int band = 0; band < numBands; band++) { total[band] += pixel[band]*v;
private void checkPixelOutside( int x , int y ) { if( !binary.isInBounds(x,y)) return; binary.get(x, y, data); if( data[0] == 0 ) { if( computeDistance(x,y) ) return; // If distances are similar or its a better fit for the 1 pixels, set value to 1 if( numOut <= 2 || Math.abs(distOut - distIn) < 40 || ( distIn < distOut && distIn < maxDistance) ) { changeValue(x,y,1); // } else { // System.out.println(" check outside no change: "+distIn+" "+distOut); } } }
public static void vertical(Kernel1D_S32 kernel, InterleavedU8 input, InterleavedI8 output ) { final int offset = kernel.getOffset(); final int width = input.getWidth(); final int height = input.getHeight(); final int numBands = input.getNumBands(); final int[] pixel = new int[ numBands ]; final int[] total = new int[ numBands ]; for (int y = 0; y < height; y++) { for( int x = 0; x < width; x++ ) { Arrays.fill(total,0); int weight = 0; int startY = y - offset; int endY = startY + kernel.getWidth(); if( startY < 0 ) startY = 0; if( endY > height ) endY = height; for( int i = startY; i < endY; i++ ) { int v = kernel.get(i-y+offset); input.get(x,i, pixel); for (int band = 0; band < numBands; band++) { total[band] += pixel[band]*v; } weight += v; } for (int band = 0; band < numBands; band++) { total[band] = (total[band]+weight/2)/weight; } output.set(x,y, total); } } }
public void process( BufferedImage image , Gaussian3D_F64 model ) { binary.reshape(image.getWidth(),image.getHeight()); colorRGB.reshape(image.getWidth(),image.getHeight()); ConvertBufferedImage.convertFrom(image, colorRGB, true); GaussianColorClassifier.classify(colorRGB,model,12,binary); int color = 0xe394bb; for( int y = 0; y < binary.height; y++ ) { for( int x = 0; x < binary.width; x++ ) { int[] data = new int[1]; binary.get(x,y, data); if( data[0] != 0 ) { image.setRGB(x,y,color); } } } ShowImages.showWindow(image,"Segmented"); }
input.get(j,i, pixel); int v = kernel.get(j-x+offset,i-y+offset); for (int band = 0; band < numBands; band++) {
private void changeValue( int x , int y , int value ) { changed.get(x,y,data); if( data[0] == 0 ) { changed.set(x,y,1); change.grow().set(x,y,value); } }
private void changeValue( int x , int y , int value ) { changed.get(x,y,data); if( data[0] == 0 ) { changed.set(x,y,1); change.grow().set(x,y,value); } }
private void examineChanges() { for( int i = 0; i < changeOld.size; i++ ) { ChangeInfo p = changeOld.get(i); computeDistance(p.x,p.y); binary.get(p.x,p.y, data); if( data[0] == 1 ) { if( distOut < distIn && distOut < maxDistance ) { changeValue(p.x,p.y,0); } } else { // If distances are similar or its a better fit for the 1 pixels, set value to 1 if( Math.abs(distOut - distIn) < 20 || ( distIn < distOut && distIn < maxDistance) ) { changeValue(p.x,p.y,1); } } } }
private void checkPixelOutside( int x , int y ) { if( !binary.isInBounds(x,y)) return; binary.get(x, y, data); if( data[0] == 0 ) { float v0 = band0.unsafe_get(x,y); float v1 = band1.unsafe_get(x,y); float v2 = band2.unsafe_get(x,y); for( Gaussian3D_F64 model : models ) { double chisq = GaussianColorClassifier.chisq(model.mean,model.covarianceInv,v0,v1,v2); if( chisq <= thresholdChiSq ) { changeValue(x, y, 1); break; } } } }
for( int y = rect.y0; y < rect.y1; y++ ) { for( int x = rect.x0; x < rect.x1; x++ ) { binary.get(x,y,data); if( data[0] == 0 ) { meanOut.band0 += band0.unsafe_get(x,y);