[ImageJ-devel] Candidates images for the "about ImageJ" dialog

Johannes Schindelin schindelin at wisc.edu
Wed Oct 19 12:50:56 CDT 2011


Hi Gabriel,

On Wed, 19 Oct 2011, Gabriel Landini wrote:

> 5. There are lots of interesting and beautiful images for which it would 
>    be difficult or impossible to read any text overwritten on them, so 
>    an idea would be to use the images with an artificial darkening 
>    horizontal gradient or similar so the text is readable.

You mean something like this Beanshell, right?

-- snipsnap --
imp = IJ.getImage();
width = imp.getWidth();
height = imp.getHeight();

text = "ImageJ2\n"
	+ "Extensible and robust image processing\n"
	+ "at your fingertips";
ip = new ByteProcessor(width, height);
ip.setColor(java.awt.Color.WHITE);
ip.drawString(text, 10, 20);
ip.invert();

ip2 = ip.duplicate();
ip2.dilate();

stack = new ImagePlus("", ip2).getStack();
mask = new fiji.process3d.EDT().compute(stack).getProcessor();
for (j = 0; j < height; j++)
	for (i = 0; i < width; i++) {
		value = mask.getf(i, j);
		// transform smoothly so that 0 is still 0
		// but large values are 1, so we can multiply the
		// original image with said value
		if (value >= 20)
			value = 1;
		else
			value = Math.sin(value * Math.PI / 2 / 20);
		mask.setf(i, j, (float)value);
	}

// blending routine
blend(ip3) {
	for (j = 0; j < height; j++)
		for (i = 0; i < width; i++) {
			if (ip.getf(i, j) != 0 && ip2.getf(i, j) == 0)
				ip3.setf(i, j, 255);
			else
				ip3.setf(i, j, ip3.getf(i, j)
					* mask.getf(i, j));
		}
}

// blend in the text into the original image
ip3 = imp.getProcessor().duplicate();
if (ip3 instanceof ColorProcessor) {
	red = new byte[width * height];
	green = new byte[width * height];
	blue = new byte[width * height];
	ip3.getRGB(red, green, blue);
	blend(new ByteProcessor(width, height, red, null));
	blend(new ByteProcessor(width, height, green, null));
	blend(new ByteProcessor(width, height, blue, null));
	ip3.setRGB(red, green, blue);
}
else
	blend(ip3);

new ImagePlus("About ImageJ2", ip3).show();




More information about the ImageJ-devel mailing list