Dear ImageJ community,
I need some help developing some ImageJ code. I'm looking for two pieces of code that that would allow the following: 1. I'd like to scan a circular ROI about a circle centred on the image canvas. 2. I'd like to rotate a ROI not about the centre of the ROI, but about the centre of the image canvas by a specified angular amount. At the end of the day, I think all I need for #1 is a list of co-ordinates for the circular ROI running about the circle where I can specify the angular resolution between each coordinate set (ideally about 0.005 deg). For #2, my instincts say this is a linear algebra problem, but I'm not sure how that would be done in ImageJ or even if it can be done in ImageJ. Any ideas? Sincerely, John Oreopoulos -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Okay,
I've figured out how to do #1 using the Edit->Selection->Rotate command, so now all I need is some help with help #2. John On 2015-10-23, at 5:20 PM, John Oreopoulos wrote: > Dear ImageJ community, > > I need some help developing some ImageJ code. > > I'm looking for two pieces of code that that would allow the following: > > 1. I'd like to scan a circular ROI about a circle centred on the image canvas. > > 2. I'd like to rotate a ROI not about the centre of the ROI, but about the centre of the image canvas by a specified angular amount. > > At the end of the day, I think all I need for #1 is a list of co-ordinates for the circular ROI running about the circle where I can specify the angular resolution between each coordinate set (ideally about 0.005 deg). > For #2, my instincts say this is a linear algebra problem, but I'm not sure how that would be done in ImageJ or even if it can be done in ImageJ. > > Any ideas? > > Sincerely, > > John Oreopoulos > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by John Oreopoulos
I think this is the answer to 1.
var width = 640; var height = 640; var amp = 200; var ROIradius = 90; var anglestep = 0.1; macro "move something in a circle [q]" { requires("1.50"); newImage("ROI moved in circle", "8-bit ramp", width, height, 1); xc = width / 2; yc = height / 2; for (theta=0; theta < 2 * PI; theta = theta + anglestep) { x = xc + amp * sin(theta); y = yc + amp * cos(theta); makeOval(x-ROIradius, y-ROIradius, ROIradius*2, ROIradius*2); wait(250); // so you can see it } } _________________________________________ Michael Cammer, Optical Microscopy Specialist http://ocs.med.nyu.edu/microscopy http://microscopynotes.com/ Cell: (914) 309-3270 ________________________________________ From: ImageJ Interest Group [[hidden email]] on behalf of John Oreopoulos [[hidden email]] Sent: Friday, October 23, 2015 5:20 PM To: [hidden email] Subject: Circular ROI scanning and rotating an ROI about the image canvas centre Dear ImageJ community, I need some help developing some ImageJ code. I'm looking for two pieces of code that that would allow the following: 1. I'd like to scan a circular ROI about a circle centred on the image canvas. 2. I'd like to rotate a ROI not about the centre of the ROI, but about the centre of the image canvas by a specified angular amount. At the end of the day, I think all I need for #1 is a list of co-ordinates for the circular ROI running about the circle where I can specify the angular resolution between each coordinate set (ideally about 0.005 deg). For #2, my instincts say this is a linear algebra problem, but I'm not sure how that would be done in ImageJ or even if it can be done in ImageJ. Any ideas? Sincerely, John Oreopoulos -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html ------------------------------------------------------------ This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email. ================================= -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
>2. I'd like to rotate a ROI not about the centre of the ROI, but about the centre of the image canvas by a specified angular amount.
If you've already got a selection of points created.... This should rotate them around a point. // Pick angle for rotation; If using degrees... convert to radians theta = 45; theta = theta * PI/180; // Pick point for rotation // Center of image? xCenter = getWidth/2; yCenter = getHeight/2; // First point in selection? getSelectionCoordinates(xCoordinates, yCoordinates); xCenter = xCoordinates[0]; yCenter = yCoordinates[0]; rotateSelectionAroundPoint(xCenter, yCenter, theta); function rotateSelectionAroundPoint(xCenter, yCenter, theta) { // Read selection points getSelectionCoordinates(xCoordinates, yCoordinates); xNew = newArray(xCoordinates.length); yNew = newArray(xCoordinates.length); for (i=0; i < xCoordinates.length; i++) { xNew[i] = xCenter + (xCoordinates[i]-xCenter)*cos(theta) - (yCoordinates[i]-yCenter)*sin(theta); yNew[i] = yCenter + (xCoordinates[i]-xCenter)*sin(theta) + (yCoordinates[i]-yCenter)*cos(theta); } makeSelection("polyline",xNew, yNew); } -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Cammer, Michael Sent: Saturday, October 24, 2015 2:07 PM To: [hidden email] Subject: Re: Circular ROI scanning and rotating an ROI about the image canvas centre I think this is the answer to 1. var width = 640; var height = 640; var amp = 200; var ROIradius = 90; var anglestep = 0.1; macro "move something in a circle [q]" { requires("1.50"); newImage("ROI moved in circle", "8-bit ramp", width, height, 1); xc = width / 2; yc = height / 2; for (theta=0; theta < 2 * PI; theta = theta + anglestep) { x = xc + amp * sin(theta); y = yc + amp * cos(theta); makeOval(x-ROIradius, y-ROIradius, ROIradius*2, ROIradius*2); wait(250); // so you can see it } } _________________________________________ Michael Cammer, Optical Microscopy Specialist http://ocs.med.nyu.edu/microscopy http://microscopynotes.com/ Cell: (914) 309-3270 ________________________________________ From: ImageJ Interest Group [[hidden email]] on behalf of John Oreopoulos [[hidden email]] Sent: Friday, October 23, 2015 5:20 PM To: [hidden email] Subject: Circular ROI scanning and rotating an ROI about the image canvas centre Dear ImageJ community, I need some help developing some ImageJ code. I'm looking for two pieces of code that that would allow the following: 1. I'd like to scan a circular ROI about a circle centred on the image canvas. 2. I'd like to rotate a ROI not about the centre of the ROI, but about the centre of the image canvas by a specified angular amount. At the end of the day, I think all I need for #1 is a list of co-ordinates for the circular ROI running about the circle where I can specify the angular resolution between each coordinate set (ideally about 0.005 deg). For #2, my instincts say this is a linear algebra problem, but I'm not sure how that would be done in ImageJ or even if it can be done in ImageJ. Any ideas? Sincerely, John Oreopoulos -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html ------------------------------------------------------------ This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email. ================================= -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |