Measurement distances of multiple lines

Tags: #<Tag:0x00007fd547f69630> #<Tag:0x00007fd547f69298>



I‘ve been using Image SXM but I try also ImageJ so that my method is available also for non-Mac user. I want to transfer a makro but I‘m not familiar with the makro procedure (I‘m not a programmer and wont be one).

Until now, I worked with a makro in Image SXM. In the SXM makro I open the data window from the Plot Profile and the makro reads the values and gives me the aforementioned data. So I don‘t have to count or use Excel etc.
I didn‘t find an existing solution in ImageJ but I think that my topic isn‘t very exotic.

I uploaded an image, showing the fabric of a slate and the profil. The vertical running mica layers are > 0 and the other (mostly quartz) < 0 of the x-axis.
I want to measure over a given length (here 1 mm):
the number of the single mica layers
the total percentage of all mica layer

In the SXM makro I open the data window from the Plot Profile and the makro reads the values and gives me the aforementioned data. So I don‘t have to count or use Excel etc.
I didn‘t find an existing solution in ImageJ but I think that my topic isn‘t very exotic.

Thank you very much in advance for any solution.


This is the makro for IMAGE SXM:

{ global variables }
    v1,v2 :  real;
    i, n, m, l, p : integer;

{ This macro evaluates a data set, which contains x-Values and a parameter  
{ at that point. It searches for sections with equal algebraic signs at the 
{ sampling points and calculates their length. It also gives the overall    
{ length for positive and negative zones.                                   



procedure ExtractValuesFromString(str :string );
    tempStr: string;
    tempStr := str;
    Delete(tempStr, 13, 12);                     { remove second value fromstring  }
    v1 := StringToNum(tempStr);                  { extract first valuefrom string  }
    tempStr := str;
    Delete(tempStr, 1, 12);                      { remove first value fromstring   }
    v2 := StringToNum(tempStr);                  { extract second valuefrom string }


macro 'Line Spacing Measurement';
    i, n, m, l, p: integer;
    c, o, x, y: real;
    poz, neg : real; 
    strwin, strunz: string;
   						                   { note that 'pos' is a macrocommand, so }
                                           { can't have a variable with thisname   }

  for m := 1 to 700 do begin              { set allarrays to zero }
      rUser1[m] := 0;                     { distance between samplingpoints     (a) }
      rUser2[m] := 0;                     { algebraic sign at the samplingpoint (b) }
      rUser3[m] := 0;                     { sections with equal algebraicsigns  (z) }
      rUser4[m] := 0;                     { algebraic sign within a section    (zz) }

			                             { macros can access only a limited number ofarrays }
           			                     { so have to make do with these array names        }

{#3 The following determines the length of every section with equal sign aswell as }
{ the overall proportion of values < 0 and >= 0                                    }

{ Now a little trick to correctly determine the first length. To keep thecode      }
{ general the first length must be considered as only from the samplingpoint at    }
{ zero to half of the distance to its successor                                    }

{ v11_______v12_______v13_______..._______v1n }
{ a[1]__|__a[2]___|__a[3]___|__...___|___a[n] }

    n:=1; m:=1; c:=0; x:=0; y:=0;
    ResetGetStr;                          { make sure we are reading fromthe top   }
                                         { of the window                          }
    for i := 1 to 5 do begin
        strunz := GetStrFromWindow;        { read and ignore the lines inthe header }
    c := v1;
    rUser1[n] := 0;
    rUser3[m] := rUser1[n];

    if v2 >= 0 then 
        rUser2[n] := 1               { macros don't have boolean arrays,so use 0,1	}
        rUser2[n] := 0;

    rUser4[m] := rUser2[n];
    if rUser2[n] = 1 then
        x := x + rUser1[n]
        y := y + rUser1[n];

{ Now all further computing can be done within a loop...                           }
{ The length of the zone around a sampling point v1n (with equal sign) alongthe    }
{ line of slice is set to be half the distance to its predecessor plus halfthe     }
{ distance to its successor. For every section with equal sign the length issummed }
{ up. The sections are numbered. The overall lengths for respectively < 0(x) and   }
{ >= 0 (y) are summed up.                                                          }

    n := 2;
    strunz := GetStrFromWindow;

    while (v1 <> 0) or (v2 <> 0) do begin

        o := v1;
        rUser1[n-1] := rUser1[n-1] + (0.5*(o-c));
        rUser3[m] := rUser1[n-1] + rUser3[m];
        rUser1[n] := 0.5*(o-c);
        c := v1;
        if v2 >= 0 then 
            rUser2[n] := 1
            rUser2[n] := 0;
        if rUser2[n] <> rUser2[n-1] then 
            m := m+1;

				    if rUser2[n] <> rUser2[n-1] then begin
            if v2 >= 0 then 
                rUser4[m] := 1
                rUser4[m] := 0;
				    p := m;
	    			if rUser2[n] = 1 then
				        x := x + rUser1[n-1]
				        y := y + rUser1[n-1];
		      l := n;
        n := n+1;
        strunz := GetStrFromWindow;
			   end;  { while }

    if rUser2[l] <> rUser2[l-1] then 
        m := m+1;
    p := m;
    rUser3[m] := rUser1[l] + rUser3[m];
{#4 Make new window for results; Write number of section; '1' for positivesign,    }
{ '0' for negative sign; length of section                                         }
    NewTextWindow(concat(WindowTitle, ' Pos/Neg'));
    for m := 1 to p do
        writeln('section[', m:4,';', rUser4[m]:2,']', rUser3[m]:8:3);
{#5 Write overall length of slice, and overall length of positive / negative       }
{ in unit of length and percentage                                                 }
    poz := (x*100) / c+0.1; 
    neg := (y*100) / c+0.1;
    writeln('Length   [µm/%]:', c:8:2, 100:8:2);
    writeln('rigide  [µm/%]:', y:8:2, neg:8:2);
    writeln('mica [µm/%]:', x:8:2, poz:8:2);  

end;  { macro 'Line Spacing Measurement' }

Measurement number of lines and percentage over a given length

Welcome to the forum @mica!
(I’ve merged your repeated posts into a single one, as they were both on the same topic)

You could have a look at Find Peaks, which will detect, retrieve and count the maxima and minima of your profile plot. Alternatively, you could also look at Segment_Profile. Both are part of the BAR Update site.


I know but I posted a second one because I thought the first was to much or not clear enough. Thanks for the hint and I found "Find Peaks which is useful and I will now figure out whether the other macros will help.


After I installed and tried Segment_Profile one questions came up: I see that the line is segmented according to the threshold but I find now way to get the results/values. I didn’t find a documentation how to do it. is there one?

best wishes