// This macro demonstrates how to add NaNs to an image, // how to count the number of NaNs in an image and how // to use Process>Noise>Remove NaNs to replace each // NaN with the neighborhood median pixel value. requires("1.45e"); open("http://imagej.nih.gov/ij/images/Dot_Blot.jpg"); run("32-bit"); getRawStatistics(n1); for (i=0; i<10000; i++) putPixel(random*getWidth, random*getHeight, NaN); getRawStatistics(n2); print("before:", n1-n2, "NaNs"); run("Remove NaNs...", "radius=3"); getRawStatistics(n3); print("after:", n1-n3, "NaNs");