Greetings Jeremy,

does that mean that something is wrong with my macro?

At least your macro doesn't work for me with the "riceSeeds" test image while both of my macros do.

Thanks anyway

Herbie

:::::::::::::::::::::::::::::::::::::::::
Am 24.01.25 um 11:00 schrieb Jeremy Adler:
This  macro happily rotates the individual selections and makes them into a 
montage.
Note I reduced the image to 8 bit to simplify thresholding, but the method 
works on RGB images

run("8-bit");
setAutoThreshold("Huang dark no-reset");
run("Create Selection");
run("Fill", "slice");
run("Select None");
setThreshold(0,254);
UseImageID=getImageID();
roiManager("reset");
run("Analyze Particles...", "size=200-Infinity add");
//resetThreshold;
Nrois=roiManager("count");
for (i = 0; i <= Nrois-1; i++) {
selectImage(UseImageID);
roiManager("select", i);
run("Fit Rectangle");
run("Duplicate...", " ");
rename("blob"+i);
}
run("Images to Stack", "  title=blob fill=#ffffff use keep");
run("Make Montage...", "columns=1 rows=Nrois scale=1 border=4 use");

Jeremy
===============================================
                     B i o V i s   P l a t f o r m of  Uppsala University
                    Light & EM microscopy / FlowCytometry & Cell Sorting / 
Image Analysis
===============================================
Jeremy Adler   PhD - Senior research engineer
Light, Confocal Microscopy, Image Analysis
E-mail: [email protected]
0739 188170
www.uu.se/biovis

Dag Hammarskjölds v 20
751 85 UPPSALA, SWEDEN
http://biovis.uu.se/
===============================================



-----Original Message-----
From: Herbie <[email protected]>
Sent: Thursday, January 23, 2025 4:19 PM
To: [email protected]
Subject: Re: can't rotate pasted image

Thanks Kees,

this was of course a typo in my mail.

It doesn't change the problem!

Thanks

Herbie

:::::::::::::::::::::::::::::::::::::::::::::::::::
Am 23.01.25 um 14:56 schrieb Straatman, Kees (Dr.):
Hi Herbie,

It should be:

     run("Images to Stack","name=Seeds title=#");
     setBatchMode(false);
     exit();

Best wishes
Kees

Advanced Imaging Facility (RRID: SCR_020967) University of Leicester
http://www.le.ac.uk/advanced-imaging-facility


-----Original Message-----

Sent: 23 January 2025 12:56
Subject: Re: can't rotate pasted image

***CAUTION:*** This email was sent from an EXTERNAL source. Think before 
clicking links or opening attachments.

Dear Jeremy,
dear listers!

Attached please find my macro with the mechanism suggested by Jeremy!

Interestingly, I wasn't able to make it work properly with

     run("Images to Stack","name=Seeds title=#");
     setBatchMode(true);
     exit();

instead of

     setBatchMode("exit and display");
     run("Images to Stack","name=Seeds title=#");
     exit();

In the former case, all slices are magically doubled.

Regards

Herbie

:::::::::::::::::::::::::::::::::::::::::
Am 22.01.25 um 18:32 schrieb Jeremy Adler:
A slightly simpler variant on Herbie's macro.

Once you have a selection for single objects, use "Fit Rectangle" and then 
duplicate.
The duplicated part of the image is rotated.

Jeremy
===============================================
                       B i o V i s   P l a t f o r m of  Uppsala University
                      Light & EM microscopy / FlowCytometry & Cell
Sorting / Image Analysis ===============================================
Jeremy Adler   PhD - Senior research engineer
Light, Confocal Microscopy, Image Analysis
E-mail: [email protected]
0739 188170
http://www.u/
u.se%2Fbiovis&data=05%7C02%7Ckrs5%40leicester.ac.uk%7C7d25261c29dc48b
1
8c2808dd3bb43805%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C0%7C6387323
6
7428985559%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLj
A
uMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7
C
&sdata=MTWYJHWhjuVbAAOMqDOry6BILoCUiFF8UshMPKyge7o%3D&reserved=0

Dag Hammarskj lds v 20
751 85 UPPSALA, SWEDEN
http://biovi/
s.uu.se%2F&data=05%7C02%7Ckrs5%40leicester.ac.uk%7C7d25261c29dc48b18c
2
808dd3bb43805%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C0%7C6387323674
2
9002201%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuM
D
AwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&s
d
ata=VtIDLjWUxSP3ejVIlph0DKyAPvKIj471O3akzrmiKTk%3D&reserved=0
===============================================




-----Original Message-----
From: Herbie <[email protected]>
Sent: Wednesday, January 22, 2025 3:57 PM
To: [email protected]
Subject: Re: can't rotate pasted image

Slightly off-topic William!

Some years ago I was asked to write a macro that performs this task on rice 
seeds.

Attached please find the "revived" macro-code and a test-image.
The macro requires two ImageJ-plugins.

Good to hear you resolved the Java-problem.

Regards

Herbie

:::::::::::::::::::::::::::::::::::::::::
Am 22.01.25 um 13:04 schrieb William Rust:
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://image/
j.nih.gov%2Fij%2Flist.html&data=05%7C02%7Ckrs5%40leicester.ac.uk%7C7d
2
5261c29dc48b18c2808dd3bb43805%7Caebecd6a31d44b0195ce8274afe853d9%7C0%
7
C0%7C638732367429013911%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRyd
W
UsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3
D
%7C0%7C%7C%7C&sdata=fGmb56SidQ2M3blotMQMXae%2FL0AQ61Gd741Z%2FJTTkNU%3
D
&reserved=0

VARNING: Klicka inte p  l nkar och  ppna inte bilagor om du inte k nner igen 
avs ndaren och vet att inneh llet  r s kert.
CAUTION: Do not click on links or open attachments unless you recognise the 
sender and know the content is safe.









N r du har kontakt med oss p  Uppsala universitet med e-post s
inneb r det att vi behandlar dina personuppgifter. F r att l sa mer
om hur vi g r det kan du l sa h r:
http://www.u/
u.se%2Fom-uu%2Fdataskydd-personuppgifter%2F&data=05%7C02%7Ckrs5%40lei
c
ester.ac.uk%7C7d25261c29dc48b18c2808dd3bb43805%7Caebecd6a31d44b0195ce
8
274afe853d9%7C0%7C0%7C638732367429025618%7CUnknown%7CTWFpbGZsb3d8eyJF
b
XB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbC
I
sIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=yOiOKDxU48lVDTngBx8YZTVASURJz4lP
E
3zydSPMeGc%3D&reserved=0

E-mailing Uppsala University means that we will process your personal
data. For more information on how this is performed, please read here:
http://www.u/
u.se%2Fen%2Fabout-uu%2Fdata-protection-policy&data=05%7C02%7Ckrs5%40l
e
icester.ac.uk%7C7d25261c29dc48b18c2808dd3bb43805%7Caebecd6a31d44b0195
c
e8274afe853d9%7C0%7C0%7C638732367429037029%7CUnknown%7CTWFpbGZsb3d8ey
J
FbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFp
b
CIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=DBWFpxcnEekpQ5hj51o3NFDS3kDcnl
%
2BZBZ%2BmZ9Zk90M%3D&reserved=0

--
ImageJ mailing list:
http://image/
j.nih.gov%2Fij%2Flist.html&data=05%7C02%7Ckrs5%40leicester.ac.uk%7C7d
2
5261c29dc48b18c2808dd3bb43805%7Caebecd6a31d44b0195ce8274afe853d9%7C0%
7
C0%7C638732367429048204%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRyd
W
UsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3
D
%7C0%7C%7C%7C&sdata=nJBePGpd%2Bc9y40H79znRKqu9TzzXnLiFyNa3I8tieWg%3D&
r
eserved=0



--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

VARNING: Klicka inte på länkar och öppna inte bilagor om du inte känner igen 
avsändaren och vet att innehållet är säkert.
CAUTION: Do not click on links or open attachments unless you recognise the 
sender and know the content is safe.









När du har kontakt med oss på Uppsala universitet med e-post så innebär det att 
vi behandlar dina personuppgifter. För att läsa mer om hur vi gör det kan du 
läsa här: http://www.uu.se/om-uu/dataskydd-personuppgifter/

E-mailing Uppsala University means that we will process your personal data. For 
more information on how this is performed, please read here: 
http://www.uu.se/en/about-uu/data-protection-policy

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html



--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
//imagej-macro "seeds2stack" (Herbie G., 22. Jan. 2025)
/*
Requires two ImageJ-plugins "RGB_to_CMYK.class"
<https://imagej.net/ij/plugins/cmyk/index.html>
and "Angular_Deviation.class"
<https://www.gluender.de/Miscellanea/MiscTexts/UtilitiesText.html#Gl-2018-3>
*/
requires("1.54m");
setForegroundColor(255,255,255);
setBackgroundColor(0,0,0);
run("Remove Overlay");
ttl=getTitle();
setBatchMode(true);
run("RGB to CMYK");
setSlice(2);
setAutoThreshold("Intermodes dark no-reset");
run("Analyze Particles...","add slice");
close();
roiManager("Show All");
for ( i=0; i<RoiManager.size; i++ ) {
   roiManager("Select",i);
   run("Duplicate...","title=#"+(i+1));
   run("Clear Outside");
   run("Canvas Size...", "width=256 height=256 position=Center zero");
   run("Restore Selection");
   run("Duplicate...","ignore");
   run("8-bit");
   run("Fill","slice");
   run("Select None");
   run("Angular Deviation","noTable");
   phi=call("Angular_Deviation.angleReturn");
   close();
   phi=call("Angular_Deviation.angleReturn");
   ref=call("Angular_Deviation.referReturn");
   if (ref!="V") phi=90+phi;
   run("Select None");
   run("Rotate... ","angle=&phi grid=0 interpolation=Bilinear");
   selectImage(ttl);
}
run("Select None");
run("Images to Stack", "name=Seeds title=#");
setBatchMode(false);
exit();
//imagej-macro "seeds2stack" (Herbie G., 22. Jan. 2025)


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
//imagej-macro "seeds2stack" (Herbie G., 23. Jan. 2025)
//Appproach with"run("Fit Rectangle")" proposed by [email protected]
/*
Requires ImageJ-plugin "RGB_to_CMYK.class"
<https://imagej.net/ij/plugins/cmyk/index.html>
*/
requires("1.54m");
setBackgroundColor(0,0,0);
run("Remove Overlay");
ttl=getTitle();
setBatchMode(true);
run("Duplicate...","title=cpy");
run("RGB to CMYK");
setSlice(2);
setAutoThreshold("Intermodes dark no-reset");
run("Analyze Particles...","add slice");
close();
roiManager("Show All");
n=RoiManager.size;
roiManager("Select",Array.getSequence(n));
roiManager("Combine");
run("Clear Outside");
for ( i=0; i<n;i++ ) {
   roiManager("Select",i);
   run("Fit Rectangle");
   run("Duplicate...","title=#"+(i+1));
   run("Rotate 90 Degrees Right");
   run("Canvas Size...", "width=128 height=256 position=Center zero");
   selectImage("cpy");
}
close("cpy");
selectImage(ttl);
roiManager("Show All");
setBatchMode("exit and display");
run("Images to Stack","name=Seeds title=#");
//setBatchMode(false);
exit();
//imagej-macro "seeds2stack" (Herbie G., 23. Jan. 2025)


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

Reply via email to