Need help to create macro

i need help to create macro to do the following

  1. Read the original RGB image % depicted in Fig
  2. Get the Green channel image % depicted in Fig
  3. Convert the gray channel into binary image, use erode, dilate, and the median filter (with
    radius 1);% depicted in Fig.
  4. Use the Analyzing function to detectthestructuresusing the conditions AR>1.3,
    Circularity<0.1, Solidity<0.4.
  5. Get the coordinates of the capsule X2,Y2;% depicted in Fig.
  6. Convex Hull % depicted in Fig.
  7. Fit Ellipse. The corpuscle center coordinates (X0, Y0) are detected according to the ellipse
    coordinates % depicted in Fig.
  8. Optimize the functions, clear outside, inverts and fills holes.
  9. Run the glomerulus detection function to detect the glomerulus (green boundaries) and its
    coordinates (X1, Y1);% depicted in Fig.
  10. Detect the capsule coordinate function which is external boundary of capsule (red –
    X_capsule, Y_capsule) and which are boundaries of glomerulus (green);
    % depicted in Fig.
  11. Determine the glomerulus diameter and capsule`s thickness according to external boundary
    of capsule (X_capsule, Y_capsule), glomerulus boundaries (X1, Y1) and
    corpusculum center (X0, Y0) coordinates.% depicted in Fig.
  12. Consider A is a point on the corpuscles geometric center,
    C is a point on the Bowman’s capsules external perimeter,
    Bi and Bj are points on the glomerulus’s perimeter,
  13. Define T as the capsule’s thickness array,
    R as the glomerulus’s radius array.
  14. Let £ be the total number of points on the Bowman’s capsule external perimeter,
    Ξ is the total number of points on the glomerulus’s perimeter.
  15. Generate initial zero valued arrays for T and R.
  16. while C<£ and B<Ξ
  17. for C=1: £ % points on the outer perimeter
  18. for B=1:Ξ % points on the inner perimeter
    Determine the distance 𝐴𝐶 (from point “A” to point “C”)
    Determine the distance 𝐴𝐵i (from point “A” to point “Bi”)
    Measure the distance 𝐶𝐵i
    Calculate the sum of 𝐴𝐵I and 𝐶𝐵i
  19. if 𝐴𝐵i +𝐶𝐵i>𝐴𝐶
    T=T; R=R
  20. else if 𝐴𝐵i +𝐶𝐵i = 𝐴𝐶
    10.set Bj= Bi %means points A, Bj and C belong to 𝐴𝐶
    11.T= T + CBj %means: CBj is added to the wall’s thickness values)
  21. R= R+ ABj% means: ABj is added to the glomerulus’s radius values)
  22. end else
  23. end if
  24. end for B
  25. end for C
  26. end while
    Total Bowman’scapsule thickness= mean(T);
    Glomerulus’s radius = mean®;
    Glomerulus’s diameter=2* glomerulus’s radius

@salemsalem

It seems you know more-or-less the steps of what you need/want to do… To start scripting this as a macro - I’d just start recording the process using the Macro Recorder. This page in general is a good place to start… You can then ‘create’ your script … and start editing it in the Script Editor. Other helpful tips for scripting in ImageJ can be found here.

Hope this helps get you started!

eta