Array question?

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

Array question?

Sasmita Rath
Dear ImageJ group,
Is there a maximum limit for an array in imageJ macro?I want to save 24832000 many pixel values (i.e.my array length is 24832000 ) in an array.When I do that I get an error message saying "java.lang.OutOfMemoryError: Java heap space ".

Thank you.
Sasmita
Reply | Threaded
Open this post in threaded view
|

Re: Array question?

Wayne Rasband
> Dear ImageJ group,
> Is there a maximum limit for an array in imageJ macro?I want to save
> 24832000 many pixel values (i.e.my array length is 24832000 ) in an
> array.When I do that I get an error message saying
> "java.lang.OutOfMemoryError: Java heap space ".

You don't want to create a 24,832,000 element array in the ImageJ macro
language. Each element requires 36 bytes, so a 24,832,000 element array
would require 852MB! In a plugin, a 24,832,000 element byte array would
require only 24MB. Plus you would be able to access the elements at
least 100 times faster.

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Array question?

Sasmita Rath
Dear Wayne,
So I did as follows.
ImageJ>Plugins>New>

I creat a new plugin and run it. My pugin program is as follows:


a=newArray (24832000);
z=0;
for(k=0;k<388;k++) {

run("Text Image... ", "open=[C:\\Documents and Settings\\Desktop\\20080423-152704--58C-255x-985ms\\" +1000+k + ".dat]");
for(i=0;i<512;i++) //width
                {for(j=0; j<125; j++)

                                                                        //height
                                {
      y=getPixel(i,j);
                                a[z]=y;
                                print(a[z]);
                                z=z+1; }
                                        }
close();
}

But I get the  error message.saying java out of space ..............
Please help.
Sasmita

----- Original Message -----
From: "Wayne Rasband" <[hidden email]>
To: [hidden email]
Sent: Tuesday, June 17, 2008 4:30:05 PM GMT -06:00 US/Canada Central
Subject: Re: Array question?

> Dear ImageJ group,
> Is there a maximum limit for an array in imageJ macro?I want to save
> 24832000 many pixel values (i.e.my array length is 24832000 ) in an
> array.When I do that I get an error message saying
> "java.lang.OutOfMemoryError: Java heap space ".

You don't want to create a 24,832,000 element array in the ImageJ macro
language. Each element requires 36 bytes, so a 24,832,000 element array
would require 852MB! In a plugin, a 24,832,000 element byte array would
require only 24MB. Plus you would be able to access the elements at
least 100 times faster.

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Array question?

Gabriel Landini
On Tuesday 17 June 2008, Sasmita Rath wrote:
> So I did as follows.
> ImageJ>Plugins>New>
>
> I creat a new plugin and run it. My pugin program is as follows:

I believe that you created a new macro, not a plugin.
Plugins are written in the Java language. What you wrote below is in the macro
language. They are different things. You will have to learn the Java language
before writing a plugin.
Here is a start:
http://reds.eivd.ch/form_de_base/SBI/labo5-parrots/ijtutorial.pdf


> a=newArray (24832000);
> z=0;
> for(k=0;k<388;k++) {
>
> run("Text Image... ", "open=[C:\\Documents and
> Settings\\Desktop\\20080423-152704--58C-255x-985ms\\" +1000+k + ".dat]");
> for(i=0;i<512;i++) //width
> {for(j=0; j<125; j++)
>
> //height
> {
>       y=getPixel(i,j);
> a[z]=y;
> print(a[z]);
> z=z+1; }
> }
> close();
> }
>