list histogram values without GUI

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

list histogram values without GUI

federica viti
Hi guys,
you helped me last time and I hope I'll be lucky also this time..

I am working with ImageJ 1.38 without GUI.
I want to extract data from the histogram of a surface plot.
I tried with the code suggested on line..something like that (the input is
the saved Surface Plot):

row = 0;
getHistogram(values, counts, 256);
  for (i=0; i<256; i++) {
      setResult("Count", row, counts[i]);
      row++;
}
updateResults();
selectWindow("Results");
directory="/my/dir";
name="myResults";
txtPath = directory+name+".txt";
save(txtPath);

It works, but actually the list of values that I obtain is different from
the one that I have in the GUI mode.
In the latter mode I apply the 'Histogram' function to the Surface Plot and
then I can visualize histogram data clicking on the 'List' option on the
histogram window.
I'm wondering if I can access to the same list of value, maybe running the
'List' command in NO GUI mode, so that I can obtain in a programmatic way
(only running my macro) the list of histogram values that I'm interested
into.

Hope I've been clear..

Thank you,
Federica
Reply | Threaded
Open this post in threaded view
|

Re: list histogram values without GUI

Michael Schmid
Hi Federica,

your macro seems to work well - the only difference I see is
the numbering of the rows:
ImageJ starts numbering the rows in the "Results" window with 1,
not 0, so everything is shifted by one.

To avoid this, you could add a column for the value:

   getHistogram(values, counts, 256);
   for (row=0; row<256; row++) {
       setResult("Value", row, row);
       setResult("Count", row, counts[row]);
   }
   updateResults();

When saving and reading the results, ignore the first column.

By the way, when testing the macro one easy way to get fooled
is first running Analyze>Histogram, then running the macro for
comparison. This will create a histogram of the "Histogram"
window, not of the original window. So make sure that the
correct foreground image is selected when running the macro.

Michael
________________________________________________________________

On 29 Apr 2008, at 14:22, federica viti wrote:

> Hi guys,
> you helped me last time and I hope I'll be lucky also this time..
>
> I am working with ImageJ 1.38 without GUI.
> I want to extract data from the histogram of a surface plot.
> I tried with the code suggested on line..something like that (the  
> input is
> the saved Surface Plot):
>
> row = 0;
> getHistogram(values, counts, 256);
>   for (i=0; i<256; i++) {
>       setResult("Count", row, counts[i]);
>       row++;
> }
> updateResults();
> selectWindow("Results");
> directory="/my/dir";
> name="myResults";
> txtPath = directory+name+".txt";
> save(txtPath);
>
> It works, but actually the list of values that I obtain is  
> different from
> the one that I have in the GUI mode.
> In the latter mode I apply the 'Histogram' function to the Surface  
> Plot and
> then I can visualize histogram data clicking on the 'List' option  
> on the
> histogram window.
> I'm wondering if I can access to the same list of value, maybe  
> running the
> 'List' command in NO GUI mode, so that I can obtain in a  
> programmatic way
> (only running my macro) the list of histogram values that I'm  
> interested
> into.
>
> Hope I've been clear..
>
> Thank you,
> Federica
Reply | Threaded
Open this post in threaded view
|

Re: list histogram values without GUI

federica viti
Thank you very much guys!
You are right: actually I found out that the differences I saw in the 2
outputs (through GUI and through macro) have nothing to do with histogram
routine.
They dipend on the previous passage, the plot surface definition (which is
the input for my histogram analysis).
Concerning that, I'm using the following parameters:
"Polygon=100 shade draw smooth"
but the 'draw' parameter refers to 'Draw Wireframe' (which I'm not
interested in), while I can't find around how to indicate 'Draw Axis'.
That implied the difference between the 2 outputs, the one with Draw
Wireframe option set (within the macro) and the one with Draw Axis (manually
chosen thruogh GUI).
Sorry for the mistake, and.. have you go t something to suggest me for
indicating the use of axis in the macro?
Thanks
Federica



On Tue, Apr 29, 2008 at 6:25 PM, Michael Schmid <[hidden email]>
wrote:

> Hi Federica,
>
> your macro seems to work well - the only difference I see is
> the numbering of the rows:
> ImageJ starts numbering the rows in the "Results" window with 1,
> not 0, so everything is shifted by one.
>
> To avoid this, you could add a column for the value:
>
>  getHistogram(values, counts, 256);
>  for (row=0; row<256; row++) {
>      setResult("Value", row, row);
>      setResult("Count", row, counts[row]);
>  }
>  updateResults();
>
> When saving and reading the results, ignore the first column.
>
> By the way, when testing the macro one easy way to get fooled
> is first running Analyze>Histogram, then running the macro for
> comparison. This will create a histogram of the "Histogram"
> window, not of the original window. So make sure that the
> correct foreground image is selected when running the macro.
>
> Michael
> ________________________________________________________________
>
>
> On 29 Apr 2008, at 14:22, federica viti wrote:
>
>  Hi guys,
> > you helped me last time and I hope I'll be lucky also this time..
> >
> > I am working with ImageJ 1.38 without GUI.
> > I want to extract data from the histogram of a surface plot.
> > I tried with the code suggested on line..something like that (the input
> > is
> > the saved Surface Plot):
> >
> > row = 0;
> > getHistogram(values, counts, 256);
> >  for (i=0; i<256; i++) {
> >      setResult("Count", row, counts[i]);
> >      row++;
> > }
> > updateResults();
> > selectWindow("Results");
> > directory="/my/dir";
> > name="myResults";
> > txtPath = directory+name+".txt";
> > save(txtPath);
> >
> > It works, but actually the list of values that I obtain is different
> > from
> > the one that I have in the GUI mode.
> > In the latter mode I apply the 'Histogram' function to the Surface Plot
> > and
> > then I can visualize histogram data clicking on the 'List' option on the
> > histogram window.
> > I'm wondering if I can access to the same list of value, maybe running
> > the
> > 'List' command in NO GUI mode, so that I can obtain in a programmatic
> > way
> > (only running my macro) the list of histogram values that I'm interested
> > into.
> >
> > Hope I've been clear..
> >
> > Thank you,
> > Federica
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: list histogram values without GUI

federica viti
In reply to this post by Michael Schmid
Hi everyone!
Sorry if I persist in asking the same thing but, until now, I couldn't find
a suitable solution.
I'm using ImageJ 1.38 without GUI, writing macros, and I need the Surface
Plot tool. I run it in the macro with the following parameters:
"Polygon=100 shade draw smooth"
but the 'draw' parameter refers to 'Draw Wireframe' (which I'm not
interested in), while I want to indicate 'Draw Axis'.
Have you got something to suggest me for indicating the use of axis in the
macro?
Thanks
Federica
Reply | Threaded
Open this post in threaded view
|

Re: list histogram values without GUI

Wayne Rasband
> Hi everyone!
> Sorry if I persist in asking the same thing but, until now, I couldn't
> find
> a suitable solution.
> I'm using ImageJ 1.38 without GUI, writing macros, and I need the
> Surface
> Plot tool. I run it in the macro with the following parameters:
> "Polygon=100 shade draw smooth"
> but the 'draw' parameter refers to 'Draw Wireframe' (which I'm not
> interested in), while I want to indicate 'Draw Axis'.
> Have you got something to suggest me for indicating the use of axis in
> the
> macro?

This bug is fixed in the v1.41b daily build. It changes the "Draw
Wireframe" and "Draw Axis" labels in the Analyze>Surface Plot dialog to
"Draw_Wireframe" and "Draw_Axis" so that macros calls use unique
'draw_wireframe' and 'draw_axis' parameters.

-wayne