Table with maxima/peaks of multiple images

Hi everyone,
I am a beginner in ImgeJ/Fiji and have not much experience in programming.
I read and search a lot but I couldnt solve my problem.

My issue:
I have multiple of images (over 1000) and I want to plot for every image a profile to get the intensity of the grey value along a line in the images. The line is constant, for every image the same.
And I want a table for each plot profile with the corresponding values of the peak/maxima.

I have tried two ways but without success:

  1. I use this script https://imagej.nih.gov/ij/macros/StackProfilePlot.txt
    I get a profile plot for each image but without a table of the maxima.

  2. I use the plugin BAR to find peaks. I get a profile plot with corresponding values of maxima. But I cannot do it for multiple images. Just for one.

I hope you understand my problem and I hope someone know a solution or can give me a hint.

Thank you.

Hi,
you could use the Process>Batch>Macro function and apply the following macro to all of your images in a given folder:

makeLine(14, 210, 169, 19); // choose your line here
k=getProfile();
m=Array.findMaxima(k, 10); // adapt tolerance here
m=Array.sort(m);
v=newArray(m.length);
for(i=0;i<m.length;i++) v[i] = k[m[i]];
Table.setColumn(getTitle+"_index",m);
Table.setColumn(getTitle+"_value",v);

You’ll end up with a large table looking like this with two columns for each image listing the maxima positions and values along the selected line.

Jerome

Hi Jerome,
thank you for you help. It works!

I have just three questions:

  1. can I add a limit in the script so that just the maxima above a value will show?

  2. what do you mean with tolerance?

Thanks.

Best

2- Tolerance is the second parameter of the Array.findMaxima function. It is described here:
https://imagej.nih.gov/ij/developer/macro/functions.html#Array

1- It would then be easier to have your table in a more consistent format, for example using this batch macro instead, so you don’t have to do any post processing.

makeLine(14, 210, 169, 19); // choose your line here
k=getProfile();
m=Array.findMaxima(k, 10); // adapt tolerance here
m=Array.sort(m);
v=newArray(m.length);
for(i=0;i<m.length;i++) {
  v[i] = k[m[i]];
  if (v[i]>=100) { // adapt threshold here
    n=Table.size;
    Table.set("Label",n,getTitle);
    Table.set("MaxPosition",n,m[i]);
    Table.set("MaxValue",n,v[i]);
    Table.update;
  }
}

Hi Jerome,

sorry for my late response.
Your code works! Thank you!

Best
Pouyan

1 Like

Hey @jerome
I have open another topic ( Measuring thickness/width of the layer for multiple images - Image Analysis - Image.sc Forum).
I would be very grateful if you could take a look up.
Thanks.

Best Pouyan