public void mouseDragged(MouseEvent e) { // compute coordinates in the original image int x = (int)(e.getX()/scale); int y = (int)(e.getY()/scale); if( !selected.isInBounds(x,y) ) return; int drawRadius = ((Number) spinnerRadius.getValue()).intValue(); // mark pixels near the selected point ImageRectangle r = new ImageRectangle(x-drawRadius,y-drawRadius,x+drawRadius+1,y+drawRadius+1); BoofMiscOps.boundRectangleInside(selected,r); ImageMiscOps.fillRectangle(selected, (byte)1,r.x0,r.y0,r.x1-r.x0,r.y1-r.y0); // visualize these changes synchronized ( work ) { int color = 0x22FF45; for( int i = r.y0;i < r.y1; i++ ) { for( int j = r.x0; j < r.x1; j++ ) { work.setRGB(j,i,color); } } } repaint((int)(r.x0*scale),(int)(r.y0*scale),(int)((r.x1-r.x0)*scale),(int)((r.y1-r.y0)*scale)); }
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); } } }
/** * Returns the value of the specified band in the specified pixel. * * @param x pixel coordinate. * @param y pixel coordinate. * @param band which color band in the pixel * @return an intensity value. */ @Override public int getBand(int x, int y, int band) { if (!isInBounds(x, y)) throw new ImageAccessException("Requested pixel is out of bounds."); if (band < 0 || band >= numBands) throw new ImageAccessException("Invalid band requested."); return data[getIndex(x, y, band)] & 0xFF; }
if( input.isInBounds(x,y)) { int index = input.getIndex(x,y,1); valueU = input.data[index]&0xFF;
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; } } } }