Finding x value of line profile

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Finding x value of line profile

anusuya pal
Hello,

I need to find the x value that corresponds to the minimum intensity of a
line profile in an image. I am new in writing the codes. In the macro, I
need to 1st draw a line of the desired dimension and need to plot so that
it generates x and y correspondingly.

For example, I want to draw a line of dimension 669, 519, 1275, 507, then
in macro it shows
makeLine(669, 519, 1275, 507);
run("Plot Profile");

I found a code in one of the mailing lists for finding x value
corresponding to the maximum intensity. And here is the copy of it. In the
macro I pasted the code after run("Plot Profile");

profile1 = getProfile();

Array.getStatistics(profile1,min,max);

A = indexOfArray(profile1, max);

And the associated function....

//Returns the indices at which a value occurs within an array
function indexOfArray(array, value) {
    count=0;
    for (i=0; i<lengthOf(array); i++) {
        if (array[i]==value) {
            count++;
        }
    }
    if (count>0) {
        indices=newArray(count);
        count=0;
        for (i=0; i<lengthOf(array); i++) {
            if (array[i]==value) {
                indices[count]=i;
                count++;
            }
        }
        return indices;

print(indices);
    }

I think for my case, I need to change A = indexOfArray(profile1, max);  to
A = indexOfArray(profile1, min); rest remains same.

But it says an error as
Selection required in line 5
profile1=getProfile(<)>;

If I do profile1 = getProfile(669, 519, 1275, 507); instead of profile1 =
getProfile(); , it generates an error as

')' expected in line 5.
profile1 = getProfile(<669>, 519, 1275, 507);

Can anyone help me to get rid of this error?

Thanks
Anu

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Finding x value of line profile

Cardone, Giovanni
Hi Anu,

you get the error because at the time you try to get the profile the active window is the plot, which does not contain any selection, instead of your original image. If you remove the command run("Plot Profile"), your script should work as intended.
BTW, getProfile() does not accept input arguments. https://imagej.nih.gov/ij/developer/macro/functions.html is a good reference for the syntax of the functions available.

Giovanni

 

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of anusuya pal
Sent: Montag, 2. Oktober 2017 09:45
To: [hidden email]
Subject: Finding x value of line profile

Hello,

I need to find the x value that corresponds to the minimum intensity of a line profile in an image. I am new in writing the codes. In the macro, I need to 1st draw a line of the desired dimension and need to plot so that it generates x and y correspondingly.

For example, I want to draw a line of dimension 669, 519, 1275, 507, then in macro it shows makeLine(669, 519, 1275, 507); run("Plot Profile");

I found a code in one of the mailing lists for finding x value corresponding to the maximum intensity. And here is the copy of it. In the macro I pasted the code after run("Plot Profile");

profile1 = getProfile();

Array.getStatistics(profile1,min,max);

A = indexOfArray(profile1, max);

And the associated function....

//Returns the indices at which a value occurs within an array function indexOfArray(array, value) {
    count=0;
    for (i=0; i<lengthOf(array); i++) {
        if (array[i]==value) {
            count++;
        }
    }
    if (count>0) {
        indices=newArray(count);
        count=0;
        for (i=0; i<lengthOf(array); i++) {
            if (array[i]==value) {
                indices[count]=i;
                count++;
            }
        }
        return indices;

print(indices);
    }

I think for my case, I need to change A = indexOfArray(profile1, max);  to A = indexOfArray(profile1, min); rest remains same.

But it says an error as
Selection required in line 5
profile1=getProfile(<)>;

If I do profile1 = getProfile(669, 519, 1275, 507); instead of profile1 = getProfile(); , it generates an error as

')' expected in line 5.
profile1 = getProfile(<669>, 519, 1275, 507);

Can anyone help me to get rid of this error?

Thanks
Anu

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Finding x value of line profile

anusuya pal
Hello

Thanks for the link!
As per your suggestions, I removed the command (run"PlotProfile"). But now
the error is

Undefined variable in line 9.
<And> the associated function....

Thanks
Anu
On Monday, October 2, 2017, Cardone, Giovanni <[hidden email]>
wrote:

> Hi Anu,
>
> you get the error because at the time you try to get the profile the
> active window is the plot, which does not contain any selection, instead of
> your original image. If you remove the command run("Plot Profile"), your
> script should work as intended.
> BTW, getProfile() does not accept input arguments.
> https://imagej.nih.gov/ij/developer/macro/functions.html is a good
> reference for the syntax of the functions available.
>
> Giovanni
>
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email] <javascript:;>]
> On Behalf Of anusuya pal
> Sent: Montag, 2. Oktober 2017 09:45
> To: [hidden email] <javascript:;>
> Subject: Finding x value of line profile
>
> Hello,
>
> I need to find the x value that corresponds to the minimum intensity of a
> line profile in an image. I am new in writing the codes. In the macro, I
> need to 1st draw a line of the desired dimension and need to plot so that
> it generates x and y correspondingly.
>
> For example, I want to draw a line of dimension 669, 519, 1275, 507, then
> in macro it shows makeLine(669, 519, 1275, 507); run("Plot Profile");
>
> I found a code in one of the mailing lists for finding x value
> corresponding to the maximum intensity. And here is the copy of it. In the
> macro I pasted the code after run("Plot Profile");
>
> profile1 = getProfile();
>
> Array.getStatistics(profile1,min,max);
>
> A = indexOfArray(profile1, max);
>
> And the associated function....
>
> //Returns the indices at which a value occurs within an array function
> indexOfArray(array, value) {
>     count=0;
>     for (i=0; i<lengthOf(array); i++) {
>         if (array[i]==value) {
>             count++;
>         }
>     }
>     if (count>0) {
>         indices=newArray(count);
>         count=0;
>         for (i=0; i<lengthOf(array); i++) {
>             if (array[i]==value) {
>                 indices[count]=i;
>                 count++;
>             }
>         }
>         return indices;
>
> print(indices);
>     }
>
> I think for my case, I need to change A = indexOfArray(profile1, max);  to
> A = indexOfArray(profile1, min); rest remains same.
>
> But it says an error as
> Selection required in line 5
> profile1=getProfile(<)>;
>
> If I do profile1 = getProfile(669, 519, 1275, 507); instead of profile1 =
> getProfile(); , it generates an error as
>
> ')' expected in line 5.
> profile1 = getProfile(<669>, 519, 1275, 507);
>
> Can anyone help me to get rid of this error?
>
> Thanks
> Anu
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Finding x value of line profile

Cardone, Giovanni
Hi Anu,

I thought you were showing just pieces of your script. Below is a modified, working version of your script, theoretically doing what you asked.
If you want to understand better the macro language in ImageJ, I suggest you invest some time in reading some intro material, like this one
http://imagej.net/Introduction_into_Macro_Programming

Giovanni

============================================================

makeLine(669, 519, 1275, 507);
profile1 = getProfile();

Array.getStatistics(profile1,min,max);
A = indexOfArray(profile1, min);

Array.print(A);


//Returns the indices at which a value occurs within an array function
function indexOfArray(array, value) {
       
    count=0;
    for (i=0; i<lengthOf(array); i++) {
         if (array[i]==value) {
             count++;
         }
     }
     indices=newArray(count);
     if (count>0) {
         count=0;
         for (i=0; i<lengthOf(array); i++) {
             if (array[i]==value) {
                 indices[count]=i;
                 count++;
             }
         }
     }

     return indices;
}

============================================================

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of anusuya pal
Sent: Montag, 2. Oktober 2017 14:22
To: [hidden email]
Subject: Re: Finding x value of line profile

Hello

Thanks for the link!
As per your suggestions, I removed the command (run"PlotProfile"). But now the error is

Undefined variable in line 9.
<And> the associated function....

Thanks
Anu
On Monday, October 2, 2017, Cardone, Giovanni <[hidden email]>
wrote:

> Hi Anu,
>
> you get the error because at the time you try to get the profile the
> active window is the plot, which does not contain any selection,
> instead of your original image. If you remove the command run("Plot
> Profile"), your script should work as intended.
> BTW, getProfile() does not accept input arguments.
> https://imagej.nih.gov/ij/developer/macro/functions.html is a good
> reference for the syntax of the functions available.
>
> Giovanni
>
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]
> <javascript:;>] On Behalf Of anusuya pal
> Sent: Montag, 2. Oktober 2017 09:45
> To: [hidden email] <javascript:;>
> Subject: Finding x value of line profile
>
> Hello,
>
> I need to find the x value that corresponds to the minimum intensity
> of a line profile in an image. I am new in writing the codes. In the
> macro, I need to 1st draw a line of the desired dimension and need to
> plot so that it generates x and y correspondingly.
>
> For example, I want to draw a line of dimension 669, 519, 1275, 507,
> then in macro it shows makeLine(669, 519, 1275, 507); run("Plot
> Profile");
>
> I found a code in one of the mailing lists for finding x value
> corresponding to the maximum intensity. And here is the copy of it. In
> the macro I pasted the code after run("Plot Profile");
>
> profile1 = getProfile();
>
> Array.getStatistics(profile1,min,max);
>
> A = indexOfArray(profile1, max);
>
> And the associated function....
>
> //Returns the indices at which a value occurs within an array function
> indexOfArray(array, value) {
>     count=0;
>     for (i=0; i<lengthOf(array); i++) {
>         if (array[i]==value) {
>             count++;
>         }
>     }
>     if (count>0) {
>         indices=newArray(count);
>         count=0;
>         for (i=0; i<lengthOf(array); i++) {
>             if (array[i]==value) {
>                 indices[count]=i;
>                 count++;
>             }
>         }
>         return indices;
>
> print(indices);
>     }
>
> I think for my case, I need to change A = indexOfArray(profile1, max);  
> to A = indexOfArray(profile1, min); rest remains same.
>
> But it says an error as
> Selection required in line 5
> profile1=getProfile(<)>;
>
> If I do profile1 = getProfile(669, 519, 1275, 507); instead of
> profile1 = getProfile(); , it generates an error as
>
> ')' expected in line 5.
> profile1 = getProfile(<669>, 519, 1275, 507);
>
> Can anyone help me to get rid of this error?
>
> Thanks
> Anu
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Finding x value of line profile

anusuya pal
Hello,

Thanks for the link. I will learn how to write codes, otherwise, it is very
difficult sometimes. I think my sentences were misunderstood. Sorry for
that. What I wanted is *not* the x corresponding to the lowest y value, but
I want all x corresponding to the minimum values of y. Let me explain with
an example.

The sample data points are as follows
X      Y
0    86.3640
1    87.2075
2    86.8510
3    84.4647
4    86.4497
5    85.9173
6    86.6588
7    87.0576
8    86.2017
9    86.4907
10    89.2206
11    89.8715

I want to collect X=3, 5, 8 because, if you scan through Y values, you will
see at X=0 it starts increasing, at X=1, it was maximum, then started
falling and at X=3 it gives Y=minimum so, my 1st collected data point is
X=3, then at X=4, the corresponding Y is higher than that of X=3, and at
x=5 gives the minimum again and so on.

I can do manually just looking up the values, but it is very hard to do for
2000 points or so. So, I was thinking if someone already has codes for it,
or help me out of it!

Thanks
Anu




On Mon, Oct 2, 2017 at 8:54 AM, Cardone, Giovanni <[hidden email]>
wrote:

> Hi Anu,
>
> I thought you were showing just pieces of your script. Below is a
> modified, working version of your script, theoretically doing what you
> asked.
> If you want to understand better the macro language in ImageJ, I suggest
> you invest some time in reading some intro material, like this one
> http://imagej.net/Introduction_into_Macro_Programming
>
> Giovanni
>
> ============================================================
>
> makeLine(669, 519, 1275, 507);
> profile1 = getProfile();
>
> Array.getStatistics(profile1,min,max);
> A = indexOfArray(profile1, min);
>
> Array.print(A);
>
>
> //Returns the indices at which a value occurs within an array function
> function indexOfArray(array, value) {
>
>     count=0;
>     for (i=0; i<lengthOf(array); i++) {
>          if (array[i]==value) {
>              count++;
>          }
>      }
>      indices=newArray(count);
>      if (count>0) {
>          count=0;
>          for (i=0; i<lengthOf(array); i++) {
>              if (array[i]==value) {
>                  indices[count]=i;
>                  count++;
>              }
>          }
>      }
>
>      return indices;
> }
>
> ============================================================
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> anusuya pal
> Sent: Montag, 2. Oktober 2017 14:22
> To: [hidden email]
> Subject: Re: Finding x value of line profile
>
> Hello
>
> Thanks for the link!
> As per your suggestions, I removed the command (run"PlotProfile"). But now
> the error is
>
> Undefined variable in line 9.
> <And> the associated function....
>
> Thanks
> Anu
> On Monday, October 2, 2017, Cardone, Giovanni <[hidden email]>
> wrote:
>
> > Hi Anu,
> >
> > you get the error because at the time you try to get the profile the
> > active window is the plot, which does not contain any selection,
> > instead of your original image. If you remove the command run("Plot
> > Profile"), your script should work as intended.
> > BTW, getProfile() does not accept input arguments.
> > https://imagej.nih.gov/ij/developer/macro/functions.html is a good
> > reference for the syntax of the functions available.
> >
> > Giovanni
> >
> >
> >
> > -----Original Message-----
> > From: ImageJ Interest Group [mailto:[hidden email]
> > <javascript:;>] On Behalf Of anusuya pal
> > Sent: Montag, 2. Oktober 2017 09:45
> > To: [hidden email] <javascript:;>
> > Subject: Finding x value of line profile
> >
> > Hello,
> >
> > I need to find the x value that corresponds to the minimum intensity
> > of a line profile in an image. I am new in writing the codes. In the
> > macro, I need to 1st draw a line of the desired dimension and need to
> > plot so that it generates x and y correspondingly.
> >
> > For example, I want to draw a line of dimension 669, 519, 1275, 507,
> > then in macro it shows makeLine(669, 519, 1275, 507); run("Plot
> > Profile");
> >
> > I found a code in one of the mailing lists for finding x value
> > corresponding to the maximum intensity. And here is the copy of it. In
> > the macro I pasted the code after run("Plot Profile");
> >
> > profile1 = getProfile();
> >
> > Array.getStatistics(profile1,min,max);
> >
> > A = indexOfArray(profile1, max);
> >
> > And the associated function....
> >
> > //Returns the indices at which a value occurs within an array function
> > indexOfArray(array, value) {
> >     count=0;
> >     for (i=0; i<lengthOf(array); i++) {
> >         if (array[i]==value) {
> >             count++;
> >         }
> >     }
> >     if (count>0) {
> >         indices=newArray(count);
> >         count=0;
> >         for (i=0; i<lengthOf(array); i++) {
> >             if (array[i]==value) {
> >                 indices[count]=i;
> >                 count++;
> >             }
> >         }
> >         return indices;
> >
> > print(indices);
> >     }
> >
> > I think for my case, I need to change A = indexOfArray(profile1, max);
> > to A = indexOfArray(profile1, min); rest remains same.
> >
> > But it says an error as
> > Selection required in line 5
> > profile1=getProfile(<)>;
> >
> > If I do profile1 = getProfile(669, 519, 1275, 507); instead of
> > profile1 = getProfile(); , it generates an error as
> >
> > ')' expected in line 5.
> > profile1 = getProfile(<669>, 519, 1275, 507);
> >
> > Can anyone help me to get rid of this error?
> >
> > Thanks
> > Anu
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Finding x value of line profile

Herbie
Good day Anu,

here is an ImageJ macro that does what you want:

// begin
arry = newArray(86.3640,87.2075,86.8510,84.4647,86.4497,
85.9173,86.6588,87.0576,86.2017,86.4907,89.2206,89.8715);
arry = Array.findMinima( arry, 0);
Array.show( arry) ;
// end

Paste the code to an empty macro window (Plugins >> New >> Macro) and
run it.

Please read the explanations of the involved macro functions here:
<https://imagej.nih.gov/ij/developer/macro/functions.html>

(BTW, what you are looking for are the positions of the relative minima.)

Regards

Herbie

::::::::::::::::::::::::::::::::::::::::
Am 02.10.17 um 17:59 schrieb anusuya pal:

> Hello,
>
> Thanks for the link. I will learn how to write codes, otherwise, it is very
> difficult sometimes. I think my sentences were misunderstood. Sorry for
> that. What I wanted is *not* the x corresponding to the lowest y value, but
> I want all x corresponding to the minimum values of y. Let me explain with
> an example.
>
> The sample data points are as follows
> X      Y
> 0    86.3640
> 1    87.2075
> 2    86.8510
> 3    84.4647
> 4    86.4497
> 5    85.9173
> 6    86.6588
> 7    87.0576
> 8    86.2017
> 9    86.4907
> 10    89.2206
> 11    89.8715
>
> I want to collect X=3, 5, 8 because, if you scan through Y values, you will
> see at X=0 it starts increasing, at X=1, it was maximum, then started
> falling and at X=3 it gives Y=minimum so, my 1st collected data point is
> X=3, then at X=4, the corresponding Y is higher than that of X=3, and at
> x=5 gives the minimum again and so on.
>
> I can do manually just looking up the values, but it is very hard to do for
> 2000 points or so. So, I was thinking if someone already has codes for it,
> or help me out of it!
>
> Thanks
> Anu
>
>
>
>
> On Mon, Oct 2, 2017 at 8:54 AM, Cardone, Giovanni <[hidden email]>
> wrote:
>
>> Hi Anu,
>>
>> I thought you were showing just pieces of your script. Below is a
>> modified, working version of your script, theoretically doing what you
>> asked.
>> If you want to understand better the macro language in ImageJ, I suggest
>> you invest some time in reading some intro material, like this one
>> http://imagej.net/Introduction_into_Macro_Programming
>>
>> Giovanni
>>
>> ============================================================
>>
>> makeLine(669, 519, 1275, 507);
>> profile1 = getProfile();
>>
>> Array.getStatistics(profile1,min,max);
>> A = indexOfArray(profile1, min);
>>
>> Array.print(A);
>>
>>
>> //Returns the indices at which a value occurs within an array function
>> function indexOfArray(array, value) {
>>
>>      count=0;
>>      for (i=0; i<lengthOf(array); i++) {
>>           if (array[i]==value) {
>>               count++;
>>           }
>>       }
>>       indices=newArray(count);
>>       if (count>0) {
>>           count=0;
>>           for (i=0; i<lengthOf(array); i++) {
>>               if (array[i]==value) {
>>                   indices[count]=i;
>>                   count++;
>>               }
>>           }
>>       }
>>
>>       return indices;
>> }
>>
>> ============================================================
>>
>> -----Original Message-----
>> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
>> anusuya pal
>> Sent: Montag, 2. Oktober 2017 14:22
>> To: [hidden email]
>> Subject: Re: Finding x value of line profile
>>
>> Hello
>>
>> Thanks for the link!
>> As per your suggestions, I removed the command (run"PlotProfile"). But now
>> the error is
>>
>> Undefined variable in line 9.
>> <And> the associated function....
>>
>> Thanks
>> Anu
>> On Monday, October 2, 2017, Cardone, Giovanni <[hidden email]>
>> wrote:
>>
>>> Hi Anu,
>>>
>>> you get the error because at the time you try to get the profile the
>>> active window is the plot, which does not contain any selection,
>>> instead of your original image. If you remove the command run("Plot
>>> Profile"), your script should work as intended.
>>> BTW, getProfile() does not accept input arguments.
>>> https://imagej.nih.gov/ij/developer/macro/functions.html is a good
>>> reference for the syntax of the functions available.
>>>
>>> Giovanni
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: ImageJ Interest Group [mailto:[hidden email]
>>> <javascript:;>] On Behalf Of anusuya pal
>>> Sent: Montag, 2. Oktober 2017 09:45
>>> To: [hidden email] <javascript:;>
>>> Subject: Finding x value of line profile
>>>
>>> Hello,
>>>
>>> I need to find the x value that corresponds to the minimum intensity
>>> of a line profile in an image. I am new in writing the codes. In the
>>> macro, I need to 1st draw a line of the desired dimension and need to
>>> plot so that it generates x and y correspondingly.
>>>
>>> For example, I want to draw a line of dimension 669, 519, 1275, 507,
>>> then in macro it shows makeLine(669, 519, 1275, 507); run("Plot
>>> Profile");
>>>
>>> I found a code in one of the mailing lists for finding x value
>>> corresponding to the maximum intensity. And here is the copy of it. In
>>> the macro I pasted the code after run("Plot Profile");
>>>
>>> profile1 = getProfile();
>>>
>>> Array.getStatistics(profile1,min,max);
>>>
>>> A = indexOfArray(profile1, max);
>>>
>>> And the associated function....
>>>
>>> //Returns the indices at which a value occurs within an array function
>>> indexOfArray(array, value) {
>>>      count=0;
>>>      for (i=0; i<lengthOf(array); i++) {
>>>          if (array[i]==value) {
>>>              count++;
>>>          }
>>>      }
>>>      if (count>0) {
>>>          indices=newArray(count);
>>>          count=0;
>>>          for (i=0; i<lengthOf(array); i++) {
>>>              if (array[i]==value) {
>>>                  indices[count]=i;
>>>                  count++;
>>>              }
>>>          }
>>>          return indices;
>>>
>>> print(indices);
>>>      }
>>>
>>> I think for my case, I need to change A = indexOfArray(profile1, max);
>>> to A = indexOfArray(profile1, min); rest remains same.
>>>
>>> But it says an error as
>>> Selection required in line 5
>>> profile1=getProfile(<)>;
>>>
>>> If I do profile1 = getProfile(669, 519, 1275, 507); instead of
>>> profile1 = getProfile(); , it generates an error as
>>>
>>> ')' expected in line 5.
>>> profile1 = getProfile(<669>, 519, 1275, 507);
>>>
>>> Can anyone help me to get rid of this error?
>>>
>>> Thanks
>>> Anu
>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Finding x value of line profile

anusuya pal
Hello,

Thanks for the help!
Thanks for sending me the links for learning the macro language.

Anu

On Mon, Oct 2, 2017 at 2:46 PM, Herbie <[hidden email]> wrote:

> Good day Anu,
>
> here is an ImageJ macro that does what you want:
>
> // begin
> arry = newArray(86.3640,87.2075,86.8510,84.4647,86.4497,
> 85.9173,86.6588,87.0576,86.2017,86.4907,89.2206,89.8715);
> arry = Array.findMinima( arry, 0);
> Array.show( arry) ;
> // end
>
> Paste the code to an empty macro window (Plugins >> New >> Macro) and run
> it.
>
> Please read the explanations of the involved macro functions here:
> <https://imagej.nih.gov/ij/developer/macro/functions.html>
>
> (BTW, what you are looking for are the positions of the relative minima.)
>
> Regards
>
> Herbie
>
> ::::::::::::::::::::::::::::::::::::::::
> Am 02.10.17 um 17:59 schrieb anusuya pal:
>
>> Hello,
>>
>> Thanks for the link. I will learn how to write codes, otherwise, it is
>> very
>> difficult sometimes. I think my sentences were misunderstood. Sorry for
>> that. What I wanted is *not* the x corresponding to the lowest y value,
>> but
>>
>> I want all x corresponding to the minimum values of y. Let me explain with
>> an example.
>>
>> The sample data points are as follows
>> X      Y
>> 0    86.3640
>> 1    87.2075
>> 2    86.8510
>> 3    84.4647
>> 4    86.4497
>> 5    85.9173
>> 6    86.6588
>> 7    87.0576
>> 8    86.2017
>> 9    86.4907
>> 10    89.2206
>> 11    89.8715
>>
>> I want to collect X=3, 5, 8 because, if you scan through Y values, you
>> will
>> see at X=0 it starts increasing, at X=1, it was maximum, then started
>> falling and at X=3 it gives Y=minimum so, my 1st collected data point is
>> X=3, then at X=4, the corresponding Y is higher than that of X=3, and at
>> x=5 gives the minimum again and so on.
>>
>> I can do manually just looking up the values, but it is very hard to do
>> for
>> 2000 points or so. So, I was thinking if someone already has codes for it,
>> or help me out of it!
>>
>> Thanks
>> Anu
>>
>>
>>
>>
>> On Mon, Oct 2, 2017 at 8:54 AM, Cardone, Giovanni <[hidden email]
>> >
>> wrote:
>>
>> Hi Anu,
>>>
>>> I thought you were showing just pieces of your script. Below is a
>>> modified, working version of your script, theoretically doing what you
>>> asked.
>>> If you want to understand better the macro language in ImageJ, I suggest
>>> you invest some time in reading some intro material, like this one
>>> http://imagej.net/Introduction_into_Macro_Programming
>>>
>>> Giovanni
>>>
>>> ============================================================
>>>
>>> makeLine(669, 519, 1275, 507);
>>> profile1 = getProfile();
>>>
>>> Array.getStatistics(profile1,min,max);
>>> A = indexOfArray(profile1, min);
>>>
>>> Array.print(A);
>>>
>>>
>>> //Returns the indices at which a value occurs within an array function
>>> function indexOfArray(array, value) {
>>>
>>>      count=0;
>>>      for (i=0; i<lengthOf(array); i++) {
>>>           if (array[i]==value) {
>>>               count++;
>>>           }
>>>       }
>>>       indices=newArray(count);
>>>       if (count>0) {
>>>           count=0;
>>>           for (i=0; i<lengthOf(array); i++) {
>>>               if (array[i]==value) {
>>>                   indices[count]=i;
>>>                   count++;
>>>               }
>>>           }
>>>       }
>>>
>>>       return indices;
>>> }
>>>
>>> ============================================================
>>>
>>> -----Original Message-----
>>> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
>>> anusuya pal
>>> Sent: Montag, 2. Oktober 2017 14:22
>>> To: [hidden email]
>>> Subject: Re: Finding x value of line profile
>>>
>>> Hello
>>>
>>> Thanks for the link!
>>> As per your suggestions, I removed the command (run"PlotProfile"). But
>>> now
>>> the error is
>>>
>>> Undefined variable in line 9.
>>> <And> the associated function....
>>>
>>> Thanks
>>> Anu
>>> On Monday, October 2, 2017, Cardone, Giovanni <[hidden email]>
>>> wrote:
>>>
>>> Hi Anu,
>>>>
>>>> you get the error because at the time you try to get the profile the
>>>> active window is the plot, which does not contain any selection,
>>>> instead of your original image. If you remove the command run("Plot
>>>> Profile"), your script should work as intended.
>>>> BTW, getProfile() does not accept input arguments.
>>>> https://imagej.nih.gov/ij/developer/macro/functions.html is a good
>>>> reference for the syntax of the functions available.
>>>>
>>>> Giovanni
>>>>
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: ImageJ Interest Group [mailto:[hidden email]
>>>> <javascript:;>] On Behalf Of anusuya pal
>>>> Sent: Montag, 2. Oktober 2017 09:45
>>>> To: [hidden email] <javascript:;>
>>>> Subject: Finding x value of line profile
>>>>
>>>> Hello,
>>>>
>>>> I need to find the x value that corresponds to the minimum intensity
>>>> of a line profile in an image. I am new in writing the codes. In the
>>>> macro, I need to 1st draw a line of the desired dimension and need to
>>>> plot so that it generates x and y correspondingly.
>>>>
>>>> For example, I want to draw a line of dimension 669, 519, 1275, 507,
>>>> then in macro it shows makeLine(669, 519, 1275, 507); run("Plot
>>>> Profile");
>>>>
>>>> I found a code in one of the mailing lists for finding x value
>>>> corresponding to the maximum intensity. And here is the copy of it. In
>>>> the macro I pasted the code after run("Plot Profile");
>>>>
>>>> profile1 = getProfile();
>>>>
>>>> Array.getStatistics(profile1,min,max);
>>>>
>>>> A = indexOfArray(profile1, max);
>>>>
>>>> And the associated function....
>>>>
>>>> //Returns the indices at which a value occurs within an array function
>>>> indexOfArray(array, value) {
>>>>      count=0;
>>>>      for (i=0; i<lengthOf(array); i++) {
>>>>          if (array[i]==value) {
>>>>              count++;
>>>>          }
>>>>      }
>>>>      if (count>0) {
>>>>          indices=newArray(count);
>>>>          count=0;
>>>>          for (i=0; i<lengthOf(array); i++) {
>>>>              if (array[i]==value) {
>>>>                  indices[count]=i;
>>>>                  count++;
>>>>              }
>>>>          }
>>>>          return indices;
>>>>
>>>> print(indices);
>>>>      }
>>>>
>>>> I think for my case, I need to change A = indexOfArray(profile1, max);
>>>> to A = indexOfArray(profile1, min); rest remains same.
>>>>
>>>> But it says an error as
>>>> Selection required in line 5
>>>> profile1=getProfile(<)>;
>>>>
>>>> If I do profile1 = getProfile(669, 519, 1275, 507); instead of
>>>> profile1 = getProfile(); , it generates an error as
>>>>
>>>> ')' expected in line 5.
>>>> profile1 = getProfile(<669>, 519, 1275, 507);
>>>>
>>>> Can anyone help me to get rid of this error?
>>>>
>>>> Thanks
>>>> Anu
>>>>
>>>> --
>>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>> --
>>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html