tophat-filter.ijm 650 Bytes
Newer Older
Christian Tischer's avatar
Christian Tischer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#@File image
#@Integer radius

// open
run("Close All");
open(image);
rename("input");

// erode
run("Morphological Filters", "operation=Erosion element=Disk radius="+radius);

// dilate
run("Morphological Filters", "operation=Dilation element=Disk radius="+radius);

// dilate(erode(input)) = opening(input)

// subtract opening from input
// (no need for floating point, because there cannot be negative values)
imageCalculator("Subtract create", "input","input-Erosion-Dilation");
rename("tophat");

// all in one command:   tophat = input - dilate(erode(input))
// run("Morphological Filters", "operation=[White Top Hat] element=Disk radius=15");