Plot profile doesn't list pixel-values

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

Plot profile doesn't list pixel-values

chai_san
Dear all,
I have a very strange problem. While I can get an x-y plot of intensity (y) to position (x) when I call plot profile, when I look at the list (the 2 column array) there is only x and y coordinate listed. No mention of the pixel value. I have a work-around for it, but its quite painful. Essentially a macro that takes the xy coordinates from plot-profile and getvalue().

The details of my configuration:
ImageJ 1.44o
Platform: Mac OSX 10.5.8

Cheers,
Chaitanya
Reply | Threaded
Open this post in threaded view
|

Re: Plot profile doesn't list pixel-values

chai_san
This is my workaround:


// StackIntensityProfile
// Chaitanya Athale 2011-04-08
// Stores profile intensities along some coordinate in stack


macro "Stack intensity profile" {
    requires("1.33r");
    saveSettings();
    run("Clear Results");

   
    if (nSlices==1)
      exit("Stack required");
   
   

    setBatchMode(true);
    stack1 = getImageID;

    n = nSlices;
    //print("No. of slices", n);

    showMessageWithCancel("Select a line for profile");
    profile = getProfile();
    //print(""profile_size: ", profile.length);
    p = profile.length;
   


    for (s=1; s<n; s++) {
        //print line profile values
        for(i=0;i<p;i++){
              print("slice, ",s, ", L, ", i, ", I(t), ",profile[i]);
        }
        showProgress(s, n);
        //print("i=",s);
               
        //showMessageWithCancel("Do we proceed?");

        setSlice(s);
        run("Next Slice [>]");
       
    }
    setBatchMode(false);
    restoreSettings();
    setSlice(1);
}


Ideally I'd like to output it into the Result window, but needed this in a hurry.
Chaitanya.
Reply | Threaded
Open this post in threaded view
|

Re: Plot profile doesn't list pixel-values

BenTupper
In reply to this post by chai_san
Hi,


Can you provide a simple example of this?  When I try...

run("Blobs (25K)");
//setTool("line");
makeLine(49, 52, 171, 149);
run("Plot Profile");
saveAs("Text", "/Users/ben/profile.txt");


I get the following...

X Y
0 40.000000000
1 40.000000000
2 40.000000000
3 40.000000000
4 41.025642395
5 46.488494873
6 42.153846741
        .
        .
        .

The "X" is the relative distance along the line and Y is the  
intensity.  The getProfile() macro function "returns the intensity  
values as an array" according to the online docs (see ... http://rsb.info.nih.gov/ij/developer/macro/functions.html#G 
  )

If you would like to interpolate pixel locations along the lines you  
could follow what is done in the ImageProcessor getLine() method...

     public double[] getLine(double x1, double y1, double x2, double  
y2) {
         double dx = x2-x1;
         double dy = y2-y1;
         int n = (int)Math.round(Math.sqrt(dx*dx + dy*dy));
         double xinc = dx/n;
         double yinc = dy/n;
         n++;
         double[] data = new double[n];
         double rx = x1;
         double ry = y1;
         if (interpolate) {
             for (int i=0; i<n; i++) {
                 data[i] = getInterpolatedValue(rx, ry);
                 rx += xinc;
                 ry += yinc;
             }
         } else {
             for (int i=0; i<n; i++) {
                 data[i] = getPixelValue((int)(rx+0.5), (int)(ry+0.5));
                 rx += xinc;
                 ry += yinc;
             }
         }
         return data;
     }


Cheers,
Ben

On Apr 10, 2011, at 4:52 AM, chai_san wrote:

> Dear all,
> I have a very strange problem. While I can get an x-y plot of  
> intensity (y)
> to position (x) when I call plot profile, when I look at the list  
> (the 2
> column array) there is only x and y coordinate listed. No mention of  
> the
> pixel value. I have a work-around for it, but its quite painful.  
> Essentially
> a macro that takes the xy coordinates from plot-profile and  
> getvalue().
>
> The details of my configuration:
> ImageJ 1.44o
> Platform: Mac OSX 10.5.8
>
> Cheers,
> Chaitanya
>
> --
> View this message in context: http://imagej.588099.n2.nabble.com/Plot-profile-doesn-t-list-pixel-values-tp6258442p6258442.html
> Sent from the ImageJ mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Plot profile doesn't list pixel-values

chai_san
In reply to this post by chai_san
Thanks Ben! That fixes it.