I’m curious - how many other ImageJ operations have methods similar to “EndPaste” which make sure that the operation has finished before proceeding?
Is there a general “best practice” to avoid race conditions (other than waiting - which only improves things without providing a guarantee)? Is there information on which methods return control to a calling Java program before the operation is complete? —- Kenneth Sloan (von meinem iPhone13 gesendet) On Wed, Jan 22, 2025 at 09:27 Michael Schmid <[email protected]> wrote: > Hi William, > > after a paste operation, you should always have an endPaste. Before > that, the paste operation is not really done, e.g. the user can still > move the pasted image around by dragging it with the mouse or use > Edit>Paste Control... [1] to change the paste mode. > > Roi roi = getRoi(); > if (roi!=null) roi.endPaste(); > > Before endPaste, ImageProcessor.rotate will work on the previous image > contents (the one before pasting). > > A bit of background information: > Most ImageJ processing commands are implemented as a PlugInFilters. > Before running a PlugInFilter, ImageJ does an endPaste. Thus, if you use > IJ.run(newImp, "Rotate... ", "angle=15 interpolation=Bilinear"); > this problem won't occur. > > Michael > > > [1] https://imagej.net/ij/docs/guide/146-27.html#sub:Paste-Control... > ________________________________________________________________ > On 22.01.25 13:39, William Rust wrote: > > > I got it working 2 minutes after I made the post. Clearing the ROI fixed > it > > although you are probably right. I also started remembering that the ip > is > > immutable in the imp so I started updating that as well. In any case, > it's > > working now and I thank you for your help. > > > > wjr > > > >> > >> On Wed, Jan 22, 2025 at 07:05 William Rust <[email protected]> wrote: > >> > >> I'm writing code in java. What I am trying to do is take an image with > 20 > >> wheat kernels in a petri dish and put each kernel in its own image with > >> the > >> kernel rotated so all kernels are roughly vertical. Here's the code > >> snippet > >> where I am doing it. > >> > >> ImageProcessor newIp = new ColorProcessor(300, 300); > >> ImagePlus newImp = new ImagePlus("sub " + idx, newIp); > >> newIp.setColor(background); > >> newIp.fill(); > >> imp.copy(); > >> newImp.paste(); > >> newImp.getProcessor().rotate(angle[idx]); > >> newImp.updateAndDraw(); > >> newImp.show(); > >> > >> > >> Previously, I've cut the subimage out of the original image using the > >> bounding box from analyze particles. The weirdness occurs somewhere > >> between > >> the paste and the rotate. The pasting works whether I do the rotate or > >> not. > >> But when I paste, the rotate does not work. And, if I don't paste, the > >> rotate does work (I can tell this because the background is tilted after > >> a > >> rotate with no paste but not with rotate and paste). This snippet shows > >> one > >> of the things that I've tried, the updateAndDraw(), but nothing has > >> worked. > >> Any ideas on what I'm doing wrong? > >> > >> Thanks, > >> > >> wjr. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
