Is it possible to have small changes in the source code of imagej?

Make polygon section of imagej has limited 200 points. I just want to increase this limitation in the source code to around 5000. Is it possible?
and in general is it possible to make small changes in the source code of imagej and apply it to the software?

Hello Zeynab -

Yes, you can tweak the ImageJ source code. It’s easy! And fun!
(See below.)

First, an aside: I’m not sure exactly what you are
referring to with the polygon 200-point limit. I see
a 1000-point initial size at line 14 in PolygonRoi.java,
but this size gets increased, as needed. (See, for example,
lines 859 and 860.)

To your question:

It is possible to just tweak the code for one class without
the overhead of performing a build for the whole of ImageJ.

Using PolygonRoi as an example, here’s what I do:

First, locate the jar that contains Polygon.class. Because
PolygonRoi is in package ij.gui, I suspect (from having
poked around before) that it will be in the ij jar. So I
locate the file:

<path-to-fiji-install>/Fiji.app/jars/ij-1.52i.jar

(I am working with a recently auto-updated version of
stock Fiji.)

Then I unjar that jar into a working “unjar” directory,
and move the original PolygonRoi.class to a safe location.

Then I download the PolygonRoi.java source file, and make
whatever changes, e.g., changing line 14 to increase the
initial value of maxPoints:

	protected int maxPoints = 5000; // will be increased if necessary

I run javac to compile the modified Polygon.java file, using
for the compilation classpath:

<path-to-fiji-install>/Fiji.app/jars

I copy the resulting PolygonRoi.class file to my unjar
directory, rejar ij-1.52i.jar, and move the updated jar
file back to <path-to-fiji-install>/Fiji.app/jars.

When you launch ImageJ / Fiji, it will pick up your
modified PolygonRoi.class in your modifed ij-1.52i.jar.

This is less complicated than it sounds – it seems
like a lot because I gave all of the details.

Thanks, mm

2 Likes

I am new to java and have a question. What is relation between these two paragraphs?:
"Then I unjar that jar into a working “unjar” directory,
and move the original PolygonRoi.class to a safe location.

Then I download the PolygonRoi.java source file, and make
whatever changes, e.g., changing line 14 to increase the
initial value of maxPoints:"
I unjarred the ij-1.52i.jar file but I do not know what to do next.
I have eclipse.

Please try some Java tutorial somewhere…

The 200 point limit in the makePolygon() and makeLine() macro functions is removed in the ImageJ 1.52m daily builds. To upgrade, use the Help>Update ImageJ command and select “daily build” from the drop down menu.

Is it the same in fiji? I mean did they remove 200 point limitation in fiji as well?

Hello Zeynab -

Fiji is a distribution of ImageJ (basically bundled with various
plugins). Wayne has patched ImageJ to remove the 200-point
limit (assuming these are the limits you were referring to).

So, launch Fiji, and run Help > Update Imagej ... from
the Fiji / ImageJ menu bar. Follow Wayne’s instructions, and
when you relaunch Fiji, you should be running the patched
version, hopefully with your polygon-limit fixed.

(And thanks to Wayne for patching this issue for you.)

Thanks, mm

1 Like