Skip to main content

[JAI] Histogram

7 replies [Last post]
Anonymous

Hi,

Java 2 SDK, SE v1.4.2_07
Java Advanced Imaging 1.1.2_01 For JDK
JAI Image I/O Tools 1.0_01 for JDK

I'm new to JAI and I hope someone can shed a light in the problem I'm having.

I'm using the dcm4che dicom library to show a dicom image and I'm
using JAI to analyse the image. I managed to get the mean out of the
image, whitout a problem, but now I'm trying to get the histogram out
of it, but to no avail:

The following is my code:

ParameterBlock pb = new ParameterBlock();
pb.addSource(image);
pb.add(null);
pb.add(1);
pb.add(1);

PlanarImage op = JAI.create("histogram", pb);
Histogram hist = (Histogram) op.getProperty("histogram");

for (int i=0; i

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Brian Burkhalter

Tom,

Aren't DICOM data mostly more than 8 bits per pixel?

By default the range of the "Histogram" operation is [0,256)

http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja...

If you have more than 8 bits per pixel perhaps all your samples are >= 256?

Brian

On Thu, 26 May 2005, Tom Deprez wrote:

> Hi,
>
> Java 2 SDK, SE v1.4.2_07
> Java Advanced Imaging 1.1.2_01 For JDK
> JAI Image I/O Tools 1.0_01 for JDK
>
> I'm new to JAI and I hope someone can shed a light in the problem I'm having.
>
> I'm using the dcm4che dicom library to show a dicom image and I'm
> using JAI to analyse the image. I managed to get the mean out of the
> image, whitout a problem, but now I'm trying to get the histogram out
> of it, but to no avail:
>
> The following is my code:
>
> ParameterBlock pb = new ParameterBlock();
> pb.addSource(image);
> pb.add(null);
> pb.add(1);
> pb.add(1);
>
> PlanarImage op = JAI.create("histogram", pb);
> Histogram hist = (Histogram) op.getProperty("histogram");
>
> for (int i=0; i > System.out.println(hist.getBinSize(0,i));
> }
>
> Now, I think this is all that is needed, to get the hist out of it.
> (From examples on the web, I read you aso need to create a Histogram
> object, with the number of bins, etc, but these methods didn't work
> either (and adding the histogram object to the ParameterBlock gave
> exceptions, because I'm using Jai 1.1 (and not 1.0)
>
> But the above code just does nothing, the hist object doesn't contain
> any values in the bins (ie all zero's) , and getMean(),
> getStandardDeviation return null...
>
> Does anybody knows why this is happening? I don't even get an error message.
>
> Thanks in advance,
> Tom.

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Tom Deprez

Yes, the image on which I'm testing is 12 bit.
Perhaps very stupid question, but how do I get a histogram other than default?

On 5/26/05, Brian Burkhalter wrote:
> Tom,
>
> Aren't DICOM data mostly more than 8 bits per pixel?
>
> By default the range of the "Histogram" operation is [0,256)
>
> http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja...
>
> If you have more than 8 bits per pixel perhaps all your samples are >= 256?
>
> Brian
>
> On Thu, 26 May 2005, Tom Deprez wrote:
>
> > Hi,
> >
> > Java 2 SDK, SE v1.4.2_07
> > Java Advanced Imaging 1.1.2_01 For JDK
> > JAI Image I/O Tools 1.0_01 for JDK
> >
> > I'm new to JAI and I hope someone can shed a light in the problem I'm having.
> >
> > I'm using the dcm4che dicom library to show a dicom image and I'm
> > using JAI to analyse the image. I managed to get the mean out of the
> > image, whitout a problem, but now I'm trying to get the histogram out
> > of it, but to no avail:
> >
> > The following is my code:
> >
> > ParameterBlock pb = new ParameterBlock();
> > pb.addSource(image);
> > pb.add(null);
> > pb.add(1);
> > pb.add(1);
> >
> > PlanarImage op = JAI.create("histogram", pb);
> > Histogram hist = (Histogram) op.getProperty("histogram");
> >
> > for (int i=0; i > > System.out.println(hist.getBinSize(0,i));
> > }
> >
> > Now, I think this is all that is needed, to get the hist out of it.
> > (From examples on the web, I read you aso need to create a Histogram
> > object, with the number of bins, etc, but these methods didn't work
> > either (and adding the histogram object to the ParameterBlock gave
> > exceptions, because I'm using Jai 1.1 (and not 1.0)
> >
> > But the above code just does nothing, the hist object doesn't contain
> > any values in the bins (ie all zero's) , and getMean(),
> > getStandardDeviation return null...
> >
> > Does anybody knows why this is happening? I don't even get an error message.
> >
> > Thanks in advance,
> > Tom.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Brian Burkhalter

Set the params described here to what you want:

http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja...

Brian

On Thu, 26 May 2005, Tom Deprez wrote:

> Yes, the image on which I'm testing is 12 bit.
> Perhaps very stupid question, but how do I get a histogram other than default?
>
>
>
> On 5/26/05, Brian Burkhalter wrote:
> > Tom,
> >
> > Aren't DICOM data mostly more than 8 bits per pixel?
> >
> > By default the range of the "Histogram" operation is [0,256)
> >
> > http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja...
> >
> > If you have more than 8 bits per pixel perhaps all your samples are >= 256?
> >
> > Brian
> >
> > On Thu, 26 May 2005, Tom Deprez wrote:
> >
> > > Hi,
> > >
> > > Java 2 SDK, SE v1.4.2_07
> > > Java Advanced Imaging 1.1.2_01 For JDK
> > > JAI Image I/O Tools 1.0_01 for JDK
> > >
> > > I'm new to JAI and I hope someone can shed a light in the problem I'm having.
> > >
> > > I'm using the dcm4che dicom library to show a dicom image and I'm
> > > using JAI to analyse the image. I managed to get the mean out of the
> > > image, whitout a problem, but now I'm trying to get the histogram out
> > > of it, but to no avail:
> > >
> > > The following is my code:
> > >
> > > ParameterBlock pb = new ParameterBlock();
> > > pb.addSource(image);
> > > pb.add(null);
> > > pb.add(1);
> > > pb.add(1);
> > >
> > > PlanarImage op = JAI.create("histogram", pb);
> > > Histogram hist = (Histogram) op.getProperty("histogram");
> > >
> > > for (int i=0; i > > > System.out.println(hist.getBinSize(0,i));
> > > }
> > >
> > > Now, I think this is all that is needed, to get the hist out of it.
> > > (From examples on the web, I read you aso need to create a Histogram
> > > object, with the number of bins, etc, but these methods didn't work
> > > either (and adding the histogram object to the ParameterBlock gave
> > > exceptions, because I'm using Jai 1.1 (and not 1.0)
> > >
> > > But the above code just does nothing, the hist object doesn't contain
> > > any values in the bins (ie all zero's) , and getMean(),
> > > getStandardDeviation return null...
> > >
> > > Does anybody knows why this is happening? I don't even get an error message.
> > >
> > > Thanks in advance,
> > > Tom.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> > For additional commands, e-mail: interest-help@jai.dev.java.net
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

----------------
Brian Burkhalter
Advanced Development, Graphics and Media
Software Chief Technology Office
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Paquette, Dan

Do you mean to say

getNumBins(0) in your for loop instead of getBins(0)??

getBins(0) returns and int[] (an array of all the bin values!)

-----Original Message-----
From: Tom Deprez [mailto:tdeprez@gmail.com]
Sent: Thursday, May 26, 2005 2:38 PM
To: interest@jai.dev.java.net
Subject: [JAI] Histogram

Hi,

Java 2 SDK, SE v1.4.2_07
Java Advanced Imaging 1.1.2_01 For JDK
JAI Image I/O Tools 1.0_01 for JDK

I'm new to JAI and I hope someone can shed a light in the problem I'm
having.

I'm using the dcm4che dicom library to show a dicom image and I'm using
JAI to analyse the image. I managed to get the mean out of the image,
whitout a problem, but now I'm trying to get the histogram out of it,
but to no avail:

The following is my code:

ParameterBlock pb = new ParameterBlock();
pb.addSource(image);
pb.add(null);
pb.add(1);
pb.add(1);

PlanarImage op = JAI.create("histogram", pb);
Histogram hist = (Histogram) op.getProperty("histogram");

for (int i=0; i System.out.println(hist.getBinSize(0,i));
}

Now, I think this is all that is needed, to get the hist out of it.
(From examples on the web, I read you aso need to create a Histogram
object, with the number of bins, etc, but these methods didn't work
either (and adding the histogram object to the ParameterBlock gave
exceptions, because I'm using Jai 1.1 (and not 1.0)

But the above code just does nothing, the hist object doesn't contain
any values in the bins (ie all zero's) , and getMean(),
getStandardDeviation return null...

Does anybody knows why this is happening? I don't even get an error
message.

Thanks in advance,
Tom.

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Tom Deprez

Yes, I mean getNumBins(0). Sorry for the typo

On 5/26/05, Paquette, Dan wrote:
> Do you mean to say
>
> getNumBins(0) in your for loop instead of getBins(0)??
>
> getBins(0) returns and int[] (an array of all the bin values!)
>
> -----Original Message-----
> From: Tom Deprez [mailto:tdeprez@gmail.com]
> Sent: Thursday, May 26, 2005 2:38 PM
> To: interest@jai.dev.java.net
> Subject: [JAI] Histogram
>
>
> Hi,
>
> Java 2 SDK, SE v1.4.2_07
> Java Advanced Imaging 1.1.2_01 For JDK
> JAI Image I/O Tools 1.0_01 for JDK
>
> I'm new to JAI and I hope someone can shed a light in the problem I'm
> having.
>
> I'm using the dcm4che dicom library to show a dicom image and I'm using
> JAI to analyse the image. I managed to get the mean out of the image,
> whitout a problem, but now I'm trying to get the histogram out of it,
> but to no avail:
>
> The following is my code:
>
> ParameterBlock pb = new ParameterBlock();
> pb.addSource(image);
> pb.add(null);
> pb.add(1);
> pb.add(1);
>
> PlanarImage op = JAI.create("histogram", pb);
> Histogram hist = (Histogram) op.getProperty("histogram");
>
> for (int i=0; i > System.out.println(hist.getBinSize(0,i));
> }
>
> Now, I think this is all that is needed, to get the hist out of it.
> (From examples on the web, I read you aso need to create a Histogram
> object, with the number of bins, etc, but these methods didn't work
> either (and adding the histogram object to the ParameterBlock gave
> exceptions, because I'm using Jai 1.1 (and not 1.0)
>
> But the above code just does nothing, the hist object doesn't contain
> any values in the bins (ie all zero's) , and getMean(),
> getStandardDeviation return null...
>
> Does anybody knows why this is happening? I don't even get an error
> message.
>
> Thanks in advance,
> Tom.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Tom Deprez

urgh...

thanks for all the advice! I must make myself very stupid on this
list. The whole thing works with the following:

int[] bins = {4096}
double[] low = {0.0D}
double[] high = {4096.0D}

ParameterBlock pb = new ParameterBlock();
pb.addSource(image);
pb.add(null);
pb.add(1);
pb.add(1);
pb.add(bins);
pb.add(low);
pb.add(high);

Again, thanks for the advice

On 5/26/05, Tom Deprez
wrote:
> Yes, I mean getNumBins(0). Sorry for the typo
>
> On 5/26/05, Paquette, Dan wrote:
> > Do you mean to say
> >
> > getNumBins(0) in your for loop instead of getBins(0)??
> >
> > getBins(0) returns and int[] (an array of all the bin values!)
> >
> > -----Original Message-----
> > From: Tom Deprez [mailto:tdeprez@gmail.com]
> > Sent: Thursday, May 26, 2005 2:38 PM
> > To: interest@jai.dev.java.net
> > Subject: [JAI] Histogram
> >
> >
> > Hi,
> >
> > Java 2 SDK, SE v1.4.2_07
> > Java Advanced Imaging 1.1.2_01 For JDK
> > JAI Image I/O Tools 1.0_01 for JDK
> >
> > I'm new to JAI and I hope someone can shed a light in the problem I'm
> > having.
> >
> > I'm using the dcm4che dicom library to show a dicom image and I'm using
> > JAI to analyse the image. I managed to get the mean out of the image,
> > whitout a problem, but now I'm trying to get the histogram out of it,
> > but to no avail:
> >
> > The following is my code:
> >
> > ParameterBlock pb = new ParameterBlock();
> > pb.addSource(image);
> > pb.add(null);
> > pb.add(1);
> > pb.add(1);
> >
> > PlanarImage op = JAI.create("histogram", pb);
> > Histogram hist = (Histogram) op.getProperty("histogram");
> >
> > for (int i=0; i > > System.out.println(hist.getBinSize(0,i));
> > }
> >
> > Now, I think this is all that is needed, to get the hist out of it.
> > (From examples on the web, I read you aso need to create a Histogram
> > object, with the number of bins, etc, but these methods didn't work
> > either (and adding the histogram object to the ParameterBlock gave
> > exceptions, because I'm using Jai 1.1 (and not 1.0)
> >
> > But the above code just does nothing, the hist object doesn't contain
> > any values in the bins (ie all zero's) , and getMean(),
> > getStandardDeviation return null...
> >
> > Does anybody knows why this is happening? I don't even get an error
> > message.
> >
> > Thanks in advance,
> > Tom.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> > For additional commands, e-mail: interest-help@jai.dev.java.net
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> > For additional commands, e-mail: interest-help@jai.dev.java.net
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Brian Burkhalter

No problem.

All intrinsic JAI operations are specified by the classes in
javax.media.jai.operator which implement javax.media.jai.OperationDescriptor.

Brian

On Thu, 26 May 2005, Tom Deprez wrote:

> urgh...
>
> thanks for all the advice! I must make myself very stupid on this
> list. The whole thing works with the following:
>
> int[] bins = {4096}
> double[] low = {0.0D}
> double[] high = {4096.0D}
>
> ParameterBlock pb = new ParameterBlock();
> pb.addSource(image);
> pb.add(null);
> pb.add(1);
> pb.add(1);
> pb.add(bins);
> pb.add(low);
> pb.add(high);
>
> Again, thanks for the advice
>
>
> On 5/26/05, Tom Deprez
wrote:
> > Yes, I mean getNumBins(0). Sorry for the typo
> >
> > On 5/26/05, Paquette, Dan wrote:
> > > Do you mean to say
> > >
> > > getNumBins(0) in your for loop instead of getBins(0)??
> > >
> > > getBins(0) returns and int[] (an array of all the bin values!)
> > >
> > > -----Original Message-----
> > > From: Tom Deprez [mailto:tdeprez@gmail.com]
> > > Sent: Thursday, May 26, 2005 2:38 PM
> > > To: interest@jai.dev.java.net
> > > Subject: [JAI] Histogram
> > >
> > >
> > > Hi,
> > >
> > > Java 2 SDK, SE v1.4.2_07
> > > Java Advanced Imaging 1.1.2_01 For JDK
> > > JAI Image I/O Tools 1.0_01 for JDK
> > >
> > > I'm new to JAI and I hope someone can shed a light in the problem I'm
> > > having.
> > >
> > > I'm using the dcm4che dicom library to show a dicom image and I'm using
> > > JAI to analyse the image. I managed to get the mean out of the image,
> > > whitout a problem, but now I'm trying to get the histogram out of it,
> > > but to no avail:
> > >
> > > The following is my code:
> > >
> > > ParameterBlock pb = new ParameterBlock();
> > > pb.addSource(image);
> > > pb.add(null);
> > > pb.add(1);
> > > pb.add(1);
> > >
> > > PlanarImage op = JAI.create("histogram", pb);
> > > Histogram hist = (Histogram) op.getProperty("histogram");
> > >
> > > for (int i=0; i > > > System.out.println(hist.getBinSize(0,i));
> > > }
> > >
> > > Now, I think this is all that is needed, to get the hist out of it.
> > > (From examples on the web, I read you aso need to create a Histogram
> > > object, with the number of bins, etc, but these methods didn't work
> > > either (and adding the histogram object to the ParameterBlock gave
> > > exceptions, because I'm using Jai 1.1 (and not 1.0)
> > >
> > > But the above code just does nothing, the hist object doesn't contain
> > > any values in the bins (ie all zero's) , and getMean(),
> > > getStandardDeviation return null...
> > >
> > > Does anybody knows why this is happening? I don't even get an error
> > > message.
> > >
> > > Thanks in advance,
> > > Tom.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> > > For additional commands, e-mail: interest-help@jai.dev.java.net
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> > > For additional commands, e-mail: interest-help@jai.dev.java.net
> > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

----------------
Brian Burkhalter
Advanced Development, Graphics and Media
Software Chief Technology Office
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net