Saving large no. of points

Hello,

One of my macros generates a multi-point selection with ~ 105,000 points in it, but when I try to save it, it throws following error:

Non-polygonal selections with more than 65k points cannot be saved.

A quick search lead me to RoiEncoder.java, where this limit is set:
https://imagej.nih.gov/ij/developer/source/ij/io/RoiEncoder.java.html

I was wondering if this limit could be removed in ImageJ, or is there another way to save a multi-point which contains a large no. of points?

Thanks!
Ved

~ 105,000 point selections is quite a lot …

Did you reflect if this is really necessary and reasonable?

The limit was raised only about 2 years ago and you should perhaps inform Wayne about your desire.

Regards

Herbie

@anon96376101 Thanks for your reply!

I’m analyzing ROIs from tumor sections. Each ROI is around 3x3 mm^2, which contains thousands of cells. My first macro generates a multi-point, representing these cells, and then I run a second macro which makes use of this multi-point for subsequent analysis.

With the 65k limit, I’ll have to think about, if I can split the multi-point into two smaller multi-points and modify the code in my second macro to work with two multi-point selections instead of one.

Would be great though if @Wayne could increase this limit!

What puzzles me is that I am able to generate and add to ROI Manager a multi-point with more than 65k points without any error, but I can not save it to my disk?

Thanks,
Ved

Ved,

if one of your ROIs contains already thousands of cells how big are your images?

Is this reasonable?
Why not consider smaller images and ROIs?

[…] but I can not save it to my disk

I faintly remember that the limit applies to the saved point selections.
I think it was a discussion on the ImageJ-list so perhaps you try a corresponding search.

Regards

Herbie

Hi Herbie,

My images are quite large (~ 15 x 15 mm^2), which I open in another program and save the smaller ROIs as tiff files, which I am analyzing in ImageJ with my macros.

To be honest, I was not sure in the beginning if I’d be able to work with and analyze such large ROIs (~ 10,000 x 10,000 pixels) in ImageJ, but it worked and I was able to analyze my ROIs with the aid of two macros I wrote, until now when I crossed the 65k limit.

Ved

The latest ImageJ daily build (1.52j35) can save and reopen point selections that have more than 65,535 points. Here is JavaScript code that creates a point selection with 105,000 points:

  size = 700;
  n = 105000;
  x = new Array(n);
  y = new Array(n);
  ran = new Random()
  for (i=0; i<n; i++) {
     x[i] = size/2+ran.nextGaussian()*size/7;
     y[i] = size/2+ran.nextGaussian()*size/7;
  }
  points = new PointRoi(x, y, "tiny dot");
  img = IJ.createImage("tmp", "16-bit", size, size, 1);
  img.setRoi(points);
  img.show();
1 Like

Hi Wayne,

Is the limit of setRoi “int” max number?

hwada

Point selections with up to Integer.MAX_VALUE (2,147,483,647) points can now be saved and reopened.

Thank you for your reply.
I understood this point.

hwada

Thanks Wayne! My macro is working fine now.

Ved