Hi Kenneth, The overlay code has not changed recently. The latest ImageJ daily build (1.54m22) adds a Roi.setMinStrokeWidth(minStrokeWidth) macro function and Java method that you can use to specify a minimum stroke width.
Here is a macro that adds an overlay to a 46000x46000 (2 gigapixel) image,
using a stroke width of 10 and minimum stroke width of 0.25.
-wayne
size = 46000;
sides = 50;
color = "white";
strokeWidth = 10;
minStrokeWidth = 0.25;
scale = 0.9;
newImage("Untitled", "8-bit ramp", size, size, 1);
Overlay.remove;
setColor(color);
Roi.setMinStrokeWidth(minStrokeWidth);
center = size/2;
r = scale*center;
twoPi = 2*PI;
inc = twoPi/sides;
for (a1=0; a1<twoPi; a1+=inc) {
x1 = r*sin(a1) + center;
y1 = r*cos(a1) + center;
for (a2=a1; a2<twoPi; a2+=inc) {
x2 = r*sin(a2) + center;
y2 = r*cos(a2) + center;
makeLine(x1,y1,x2,y2);
Overlay.addSelection(color, strokeWidth);
}
}
> On Nov 5, 2024, at 8:10 PM, Kenneth Sloan <[email protected]> wrote:
>
> I’m debugging a new Java plugin. It’s based on a much older plugin, which
> has not changed in years). Both were working fine a week ago. Today, the
> new one stopped displaying the Overlay. After struggling for awhile, I
> decided to check the old one. It also fails.
>
> Has ImageJ Overlay code changed recently?
>
> [AHA - see below - image type and size appear to matter! Perhaps I have a
> workaround - but I’d like to avoid that, if possible.]
>
> I am running Sonoma 14.7 on my MacBook Pro laptop.
>
> Here is the relevant code, from the old (unchanged in years) code. What am I
> doing wrong, please?
>
> Full plugin is available as AVL_Area_Fraction on the CreativeComputation
> ImageJ Update Site.
>
> The new plugin is available as Point_Counter on the same site (it doesn’t use
> KeyPresses, which was my last problem, but may have other random bugs).
>
> AVL_Area_Fraction works perfectly, except that Overlays are not shown.
>
> AHA…one last thing. Overlays work (in the old plugin) with a smaller .bmp
> image (384x496, RGB) as input. They fail with a much larger .tif image
> (18936x5400, RGB).
>
> Provisionally - it looks like my problem is with the SIZE of the image. Is
> this known? Is there a workaround? If necessary, I could reduce the size of
> the displayed image and keep the full image hidden (I need the full
> resolution for other purposes).
>
> I can do this - but it’s enough work that I’d like confirmation that this is
> a known problem. If it’s an ImageJ bug, I’d rather see it fixed there. But,
> if necessary...
>
> // ipl, calibration, colors and stroke widths set globally
> private int sampleAt(double x, double y)
> throws InterruptedException
> {
> IJ.log("sampleAt("+x+", "+y+")");
> double r0 = 10.0;
> double r1 = 50.0;
> overlay = new Overlay();
> double xPix = calibration.getRawX(x);
> double yPix = calibration.getRawY(y);
> Roi plusX = new Line(xPix + r0, yPix , xPix + r1, yPix );
> Roi minusX = new Line(xPix - r0, yPix , xPix - r1, yPix );
> Roi plusY = new Line(xPix , yPix + r0, xPix , yPix + r1);
> Roi minusY = new Line(xPix , yPix - r0, xPix , yPix - r1);
>
> plusX.setStrokeWidth(cursorStrokeWidth);
> plusX.setStrokeColor(cursorColor);
> minusX.setStrokeWidth(cursorStrokeWidth);
> minusX.setStrokeColor(cursorColor);
> plusY.setStrokeWidth(cursorStrokeWidth);
> plusY.setStrokeColor(cursorColor);
> minusY.setStrokeWidth(cursorStrokeWidth);
> minusY.setStrokeColor(cursorColor);
>
> overlay.add(plusX);
> overlay.add(minusX);
> overlay.add(plusY);
> overlay.add(minusY);
>
> ipl.setOverlay(overlay);
> ipl.updateAndDraw();
> ...
> --
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
smime.p7s
Description: S/MIME cryptographic signature
