public void drawColorBar(Graphics g, int x, int y, int width, int height) { if (mapSize == 0) return; ColorProcessor cp = new ColorProcessor(width, height); double scale = 256.0/mapSize; for (int i = 0; i<256; i++) { int index = (int)(i/scale); cp.setColor(new Color(rLUT[index]&0xff,gLUT[index]&0xff,bLUT[index]&0xff)); cp.moveTo(i,0); cp.lineTo(i,height); } g.drawImage(cp.createImage(),x,y,null); g.setColor(Color.black); g.drawRect(x, y, width, height); }
public void drawColorBar(Graphics g, int x, int y, int width, int height) { if (mapSize == 0) return; ColorProcessor cp = new ColorProcessor(width, height); double scale = 256.0/mapSize; for (int i = 0; i<256; i++) { int index = (int)(i/scale); cp.setColor(new Color(rLUT[index]&0xff,gLUT[index]&0xff,bLUT[index]&0xff)); cp.moveTo(i,0); cp.lineTo(i,height); } g.drawImage(cp.createImage(),x,y,null); g.setColor(Color.black); g.drawRect(x, y, width, height); }
void visualizePoints( final List< List< PointMatch > > inliers) { final ColorProcessor ip = new ColorProcessor(nlt.getWidth(), nlt.getHeight()); ip.setColor(Color.red); ip.setLineWidth(5); for (int i=0; i < inliers.size(); i++){ for (int j=0; j < inliers.get(i).size(); j++){ final double[] tmp1 = inliers.get(i).get(j).getP1().getW(); final double[] tmp2 = inliers.get(i).get(j).getP2().getL(); ip.setColor(Color.red); ip.drawDot((int) tmp2[0], (int) tmp2[1]); ip.setColor(Color.blue); ip.drawDot((int) tmp1[0], (int) tmp1[1]); } } final ImagePlus points = new ImagePlus("Corresponding Points after correction", ip); points.show(); }
/** * Paint all {@link Spring Springs} into a {@link ColorProcessor}. */ public void illustrateSprings( final ColorProcessor ip, final double scale, final double maxStretch, final double offsetX, final double offsetY ) { for ( final Vertex vertex : vertices ) { final double[] v1 = vertex.getW(); for ( final Vertex v : vertex.getConnectedVertices() ) { final Spring spring = vertex.getSpring( v ); //final double stretch = mpicbg.util.Util.pow( Math.min( 1.0f, Math.abs( Point.distance( vertex, v ) - spring.getLength() ) / maxStretch ), 2 ); final double stretch = Math.min( 1.0, Math.abs( Point.distance( vertex, v ) - spring.getLength() ) / maxStretch ); final double r = Math.min( 1, stretch * 2 ); final double g = Math.min( 1, 2 - stretch * 2 ); ip.setColor( new Color( ( float )r, ( float )g, 0 ) ); final double[] v2 = v.getW(); ip.drawLine( mpicbg.util.Util.round( scale * v1[ 0 ] + offsetX ), mpicbg.util.Util.round( scale * v1[ 1 ] + offsetY ), mpicbg.util.Util.round( scale * v2[ 0 ] + offsetX ), mpicbg.util.Util.round( scale * v2[ 1 ] + offsetY ) ); } } }
/** * Paint all {@link Spring Springs} into a {@link ColorProcessor}. */ public void illustrateSprings( final ColorProcessor ip, final double scale, final double maxStretch, final double offsetX, final double offsetY ) { for ( final Vertex vertex : vertices ) { final double[] v1 = vertex.getW(); for ( final Vertex v : vertex.getConnectedVertices() ) { final Spring spring = vertex.getSpring( v ); //final double stretch = mpicbg.util.Util.pow( Math.min( 1.0f, Math.abs( Point.distance( vertex, v ) - spring.getLength() ) / maxStretch ), 2 ); final double stretch = Math.min( 1.0, Math.abs( Point.distance( vertex, v ) - spring.getLength() ) / maxStretch ); final double r = Math.min( 1, stretch * 2 ); final double g = Math.min( 1, 2 - stretch * 2 ); ip.setColor( new Color( ( float )r, ( float )g, 0 ) ); final double[] v2 = v.getW(); ip.drawLine( mpicbg.util.Util.round( scale * v1[ 0 ] + offsetX ), mpicbg.util.Util.round( scale * v1[ 1 ] + offsetY ), mpicbg.util.Util.round( scale * v2[ 0 ] + offsetX ), mpicbg.util.Util.round( scale * v2[ 1 ] + offsetY ) ); } } }
/** * Paint all {@link Spring}s into a {@link ColorProcessor}. */ public void illustrateSprings( final ColorProcessor ip, final double scale, final double maxStretch ) { for ( final Vertex vertex : vertices ) { final double[] v1 = vertex.getW(); for ( final Vertex v : vertex.getConnectedVertices() ) { final Spring spring = vertex.getSpring( v ); //final double stretch = mpicbg.util.Util.pow( Math.min( 1.0f, Math.abs( Point.distance( vertex, v ) - spring.getLength() ) / maxStretch ), 2 ); final double stretch = Math.min( 1.0, Math.abs( Point.distance( vertex, v ) - spring.getLength() ) / maxStretch ); final double r = Math.min( 1, stretch * 2 ); final double g = Math.min( 1, 2 - stretch * 2 ); ip.setColor( new Color( ( float )r, ( float )g, 0 ) ); final double[] v2 = v.getW(); ip.drawLine( mpicbg.util.Util.round( scale * v1[ 0 ] ), mpicbg.util.Util.round( scale * v1[ 1 ] ), mpicbg.util.Util.round( scale * v2[ 0 ] ), mpicbg.util.Util.round( scale * v2[ 1 ] ) ); } } }
/** * Paint all {@link Spring}s into a {@link ColorProcessor}. */ public void illustrateSprings( final ColorProcessor ip, final double scale, final double maxStretch ) { for ( final Vertex vertex : vertices ) { final double[] v1 = vertex.getW(); for ( final Vertex v : vertex.getConnectedVertices() ) { final Spring spring = vertex.getSpring( v ); //final double stretch = mpicbg.util.Util.pow( Math.min( 1.0f, Math.abs( Point.distance( vertex, v ) - spring.getLength() ) / maxStretch ), 2 ); final double stretch = Math.min( 1.0, Math.abs( Point.distance( vertex, v ) - spring.getLength() ) / maxStretch ); final double r = Math.min( 1, stretch * 2 ); final double g = Math.min( 1, 2 - stretch * 2 ); ip.setColor( new Color( ( float )r, ( float )g, 0 ) ); final double[] v2 = v.getW(); ip.drawLine( mpicbg.util.Util.round( scale * v1[ 0 ] ), mpicbg.util.Util.round( scale * v1[ 1 ] ), mpicbg.util.Util.round( scale * v2[ 0 ] ), mpicbg.util.Util.round( scale * v2[ 1 ] ) ); } } }
protected void discoverEnvironment() { if (! firstTime) { firstTime = true; imp = WindowManager.getCurrentImage(); int width = 100; int height = 100; if (imp instanceof ImagePlus && imp.getStackSize() > 1) { this.imp = imp; hasVolume = true; imp.setSlice(imp.getStackSize()/2); ImageStack stack = imp.getStack(); width = stack.getWidth(); height = stack.getHeight(); } ColorProcessor cp = new ColorProcessor(width, height, new int[width*height]); cp.setColor(new Color(0xffffff)); cp.fill(); setProcessor("2D Optical flow", cp); show(); } } /**
final ByteProcessor empty = new ByteProcessor(width+2*border, height+2*border); quiver.setLineWidth(1); quiver.setColor(Color.green);
cp.setColor(new Color(0xffffff)); cp.fill(); impViewer = new ImagePlus("VJViewerCanvas", cp); new ImageWindow(impViewer, new VJViewerCanvas(impViewer));