Quantcast

Creating a histogram image (custom data)

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Creating a histogram image (custom data)

Tom Runia
Hello everybody,

I am trying to let my Java plugin for ImageJ output a histogram image.
The data is formatted as integer array which I want to convert to a
histogram. I have searched around how to create my own histogram and create
an image (png) of it, but I can't find how to do it. Maybe this question is
not really ImageJ related, but does anyone know how I can achieve this in
Java?

Thanks in advance!

Best,

Tom
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating a histogram image (custom data)

John Oreopoulos
Hi Tom,

Perhaps you could convert your array of data back into an image of arbitrary dimensions (ie: each pixel value is one number from the array), and then use ImageJ's image histogram function to create the histogram that you seek.

John Oreopoulos
Research Assistant
Spectral Applied Research
Richmond Hill, Ontario
Canada
www.spectral.ca


On 2012-01-16, at 5:07 AM, Tom Runia wrote:

> Hello everybody,
>
> I am trying to let my Java plugin for ImageJ output a histogram image.
> The data is formatted as integer array which I want to convert to a
> histogram. I have searched around how to create my own histogram and create
> an image (png) of it, but I can't find how to do it. Maybe this question is
> not really ImageJ related, but does anyone know how I can achieve this in
> Java?
>
> Thanks in advance!
>
> Best,
>
> Tom
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating a histogram image (custom data)

Unruh, Jay-2
In reply to this post by Tom Runia
Tom,

My library has 1D and 2D histogram creation and plotting functionality through the classes PlotHist and Plot2DHist as well as their associated window classes.  The jar library with source code is found at http://research.stowers-institute.org/imagejplugins/ under the downloads link.  If you are compiling from ImageJ, you may need to rename the library without an underscore to compile.

Jay
________________________________________
From: ImageJ Interest Group [[hidden email]] On Behalf Of Tom Runia [[hidden email]]
Sent: Monday, January 16, 2012 4:07 AM
To: [hidden email]
Subject: Creating a histogram image (custom data)

Hello everybody,

I am trying to let my Java plugin for ImageJ output a histogram image.
The data is formatted as integer array which I want to convert to a
histogram. I have searched around how to create my own histogram and create
an image (png) of it, but I can't find how to do it. Maybe this question is
not really ImageJ related, but does anyone know how I can achieve this in
Java?

Thanks in advance!

Best,

Tom
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating a histogram image (custom data)

Michael Schmid-3
In reply to this post by Tom Runia
Hi Tom,

the easiest is to see how ImageJ does it:
Type l (ell, not one) or ctrl-l, and enter the name of the command, 'histogram'. With 'Full information' you will see that it is ij.plugin.Histogram.

Then look it up in the source code, e.g.
  http://fiji.sc/cgi-bin/gitweb.cgi?p=imagej.git;a=blob;f=ij/plugin/Histogram.java

There you will see that the built-in command uses the HistogramWindow class.
  http://fiji.sc/cgi-bin/gitweb.cgi?p=imagej.git;a=blob;f=ij/gui/HistogramWindow.java

The constructor you might use is
  public HistogramWindow(String title, ImagePlus imp, ImageStatistics stats)
where imp should be an image of the same type (8-bit, 16-bit, etc) and color map as yours (if you have none, create one; it need not be shown) and the ImageStatistics are where you put your data.

  http://fiji.sc/cgi-bin/gitweb.cgi?p=imagej.git;a=blob;f=ij/process/ImageStatistics.java

ImageStatistics has all public fields, so you can easily create a new one and fill its histogram and pixelCount fields.

Hope this helps,

Michael
________________________________________________________________

On Jan 16, 2012, at 11:07, Tom Runia wrote:

> Hello everybody,
>
> I am trying to let my Java plugin for ImageJ output a histogram image.
> The data is formatted as integer array which I want to convert to a
> histogram. I have searched around how to create my own histogram and create
> an image (png) of it, but I can't find how to do it. Maybe this question is
> not really ImageJ related, but does anyone know how I can achieve this in
> Java?
>
> Thanks in advance!
>
> Best,
>
> Tom
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating a histogram image (custom data)

dscho
Hi,

On Mon, 16 Jan 2012, Michael Schmid wrote:

> the easiest is to see how ImageJ does it:
> Type l (ell, not one) or ctrl-l, and enter the name of the command, 'histogram'. With 'Full information' you will see that it is ij.plugin.Histogram.
>
> Then look it up in the source code, e.g.
>   http://fiji.sc/cgi-bin/gitweb.cgi?p=imagej.git;a=blob;f=ij/plugin/Histogram.java

If you're already using Fiji (as suggested by the URL... ;-) you could
also use Plugins>Scripting>Open Source for Menu Item and then select
Analyze>Show Histogram.

Ciao,
Johannes
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating a histogram image (custom data)

Tom Runia
Thanks for all the clever solutions!

When I searched a little more I found the Java package JFreeChart:
http://www.jfree.org/jfreechart/
This library does exactly what I want. I can recommended it to everybody,
it is very easy to use and the graphs look good (see:
http://tweakers.net/ext/f/8n7KEFNpXy1hsQLaAH3AWoIS/full.png)

The way of creating a histogram using ImageJ should also work, but I found
this way a little bit nicer.

Best,

Tom


2012/1/16 Johannes Schindelin <[hidden email]>

> Hi,
>
> On Mon, 16 Jan 2012, Michael Schmid wrote:
>
> > the easiest is to see how ImageJ does it:
> > Type l (ell, not one) or ctrl-l, and enter the name of the command,
> 'histogram'. With 'Full information' you will see that it is
> ij.plugin.Histogram.
> >
> > Then look it up in the source code, e.g.
> >
> http://fiji.sc/cgi-bin/gitweb.cgi?p=imagej.git;a=blob;f=ij/plugin/Histogram.java
>
> If you're already using Fiji (as suggested by the URL... ;-) you could
> also use Plugins>Scripting>Open Source for Menu Item and then select
> Analyze>Show Histogram.
>
> Ciao,
> Johannes
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating a histogram image (custom data)

Jan Eglinger-3
Hi Tom,

On 17.01.2012 10:40 AM, Tom Runia wrote:
> When I searched a little more I found the Java package JFreeChart:
> http://www.jfree.org/jfreechart/
> This library does exactly what I want. I can recommended it to everybody,
> it is very easy to use and the graphs look good (see:
> http://tweakers.net/ext/f/8n7KEFNpXy1hsQLaAH3AWoIS/full.png)

JFreeChart is already included in Fiji, since several plugins use it, e.g.

http://fiji.sc/Directionality
http://fiji.sc/TrackMate
http://fiji.sc/TrakEM2
http://fiji.sc/Simple_Neurite_Tracer

That makes it easy to draw graphs even using JavaScript scripting.

Jan
Loading...