/* ImageJ Macro "Directional Filter Window" Authors: Roberto Sotto-Maior Fortes de Oliveira,Vera Maria Peters,Robert Willer Farinazzo Vitral Address: Universidade Federal de Juiz de Fora - Brazil Email: R.Sotto-Maior (roberto at aparelho dot com) This Macro generates a filter window image to be used in Fourier Domain Directional Filtering applications. The filter image size, the angles band theta1 and theta2, and the alfa coefficient should be informed in the dialog Window. The angle parameters should be entered in degrees. This code produces a 32 bit image Directional Filter Window with equal height and width dimensions. Reference: Chaudhuri S,et al.A Fourier domain directional filtering method for analysis of collagen alignment in ligaments. IEEE Trans. Biomed. Eng.1987 Jul;34(7):509-18. Acknowledgement: The support from FAPEMIG (Fundacao de Amparo a Pesquisa de Minas Gerais) is gratefully acknowledged. History: 2009/6/18:version 0.1 - First version 2009/11/5:version 0.2 - The first version was replaced to a corrected code that generate filters of fixed value bandwidth(PI/2). 2009/11/12: version 1.0 Now the code work as suggested by Chaudhuri et al.(1987). Its is necessary to enter the bandwidth limits (theta1,theta2) angles with theta1 < theta2. The bandwidth is now calculated by the code. The angle signal convention is the same used by the atan2 macro function. */ macro "Directional Filter Window" { Dialog.create("Directional Filter Window"); Dialog.addNumber("Filter image size (pixel):", 512); Dialog.addNumber("Theta1 (degree):", 45); Dialog.addNumber("Theta2 (degree):", 135); Dialog.addNumber("Alpha Coefficient:", 1); Dialog.show(); size = Dialog.getNumber(); theta1 = Dialog.getNumber(); theta2 = Dialog.getNumber(); alpha = Dialog.getNumber(); theta1 *= PI/180; theta2 *= PI/180; theta0 = (theta2+theta1)/2; bandwidth = theta2-theta1; if (theta1 >= theta2) exit("You entered theta1 > theta2. Please enter theta1 < theta2."); if (abs(bandwidth) >= PI) exit("The bandwidth [theta2 - theta1] should be < 180."); M=size; N=size; setBatchMode(true); newImage("Directional Filter Window", "32-bit Black", M, N, 1); for (y=0; y=0){ if ((theta >= theta1) && (theta <= theta2)){ setPixel(x,y,w); setPixel(x-2*dx,y-2*dy,w); setPixel(M/2,N/2,0); } } if ((theta1<0) && (theta2>0)){ if ((theta >= theta1) && (theta <= theta2)) { setPixel(x,y,w); setPixel(x-2*dx,y,w); setPixel(M/2,N/2,0); } } if ((theta1<=0) && (theta2<=0)){ if ((theta >= theta1) && (theta <= theta2)) { setPixel(x,y,w); setPixel(x-2*dx,y-2*dy,w); setPixel(M/2,N/2,0); } } } } setBatchMode(false); }