// This macro demonstrates how to use the Process>Math>Macro... command to apply // custom formulas to each pixel in an image. // All built-in variables and functions of the IJ macro language can be used in // the specified formula // // 2010.March, Tiago Ferreira, Wayne Rasband, Ulf Dittmer msg = "This macro demonstrates the use of the Process>Math>Macro... command" +"\n \n"+ "This command performs image arithmetic using any custom expression. " +"\n"+ "It can be used to create fully-synthetic images or to perfom precise" +"\n"+ "pixel manipulations on pre-existing images." +"\n \n"+ "For more information have a look at" +"\n"+ " - ImageMath source code: " +"\n"+ " - Expression, Ulf Dittmer’s plugin that inspired this command:" +"\n"+ " " +"\n \n"; // Synthetic Grayscale images //1# Polar Moire polar = '255*(floor((a * 40.75 + 1) % 2))'; //2# Sine Grid sineGd = '255*(sin(0.2*x) * sin(0.1*y))'; //3# Gray Spiral spiral = '128*(sin(d/10+a*PI/180)+1)'; //4# Cone cone = '(d)*5'; // Synthetic Color images //1# Spiral wheel wheelR = '((a * 10.19 + d) % 32)*8'; wheelG = '((a * 40.74 + d) % 32)*8'; //'((a * 40.7+ d) % 16)*16'; wheelB = '((a * 20.37 + d) % 32)*8'; //'((a * 23 + d) % 16)*16'; sW = newArray(""+wheelR,""+wheelG,""+wheelB); //2# Color Spiral spiralR = '255*sin(d + a)'; spiralG = '255*sin(d + a + 4.2)'; spiralB = '255*sin(d + a + 2.1)'; sp = newArray(""+spiralR,""+spiralG,""+spiralB); //3# Fibonacci fbncciR = '255*(sin(log(d)*8 + a) * sin(a*8))'; fbncciG = '255*(sin(log(d)*8 + a - PI/2) * sin(a*8))'; fbncciB = '255*(sin(log(d)*8 + a + PI/2) * sin(a*8))'; fb = newArray(""+fbncciR,""+fbncciG,""+fbncciB); //4# Sine Tile sineTlR = '255*(cos(0.2*x) + sin(0.2*y))'; sineTlG = '255*(cos(0.4*x) + sin(0.4*y))'; sineTlB = '255*(cos(0.1*x) + sin(0.1*y))'; st = newArray(""+sineTlR,""+sineTlG,""+sineTlB); // Image Manipulations stBckg = "if(v<=104) v=0"; // Saturate Background invHlf = "if(x