Can the CENTER OF ROTATION be set / changed within Adjust.ImageCommands.Rotate?
All --
Can the CENTER OF ROTATION be set / changed within the Adjust.ImageCommands.Rotate command?
If I have the XY location that I would like to use as the CENTER OF ROTATION and I have the ANGLE, is there a way to format the Adjust.ImageCommands.Rotate command to operate on an arbitrary point?
My work with the Adjust.ImageCommands.Rotate command indicates it performs the rotate based on the CENTER OF THE IMAGE.
I would like to rotate an image around a CENTER OF ROTATION that is with the ORIGINAL IMAGE but that is probably not the CENTER OF THE IMAGE.
I have looked at
-- Matt

Can the CENTER OF ROTATION be set / changed within the Adjust.ImageCommands.Rotate command?
If I have the XY location that I would like to use as the CENTER OF ROTATION and I have the ANGLE, is there a way to format the Adjust.ImageCommands.Rotate command to operate on an arbitrary point?
My work with the Adjust.ImageCommands.Rotate command indicates it performs the rotate based on the CENTER OF THE IMAGE.
I would like to rotate an image around a CENTER OF ROTATION that is with the ORIGINAL IMAGE but that is probably not the CENTER OF THE IMAGE.
I have looked at
Image-Pro Premier Automation Help
Automation
Reference ► MediaCy.Commands.Image ► Rotate
but I don't see anything that looks like a way to set / change the CENTER OF ROTATION.
The SCREEN CAPTURE below illustrates this question with:
** A as the ORIGINAL IMAGE
** B as the current result of performing a 32 deg CCW ROTATION of A
** C as the desired result with the center of the OBJECT in the CENTER OF THE IMAGE without losing any pixels from A.
Each of these images (all displayed at ZOOM = 80%) has:
** A LINE through the center axis of the object (giving us the OBJECT ANGLE and the OBJECT CENTER)
** A POINT at that CENTER OF THE IMAGE
Right now it takes several operations to make the OBJECT be VERTICAL and CENTERED. I'm hoping that Adjust.ImageCommands.Rotate can be called in a way that will make this happen in one operation.
Thanks.
but I don't see anything that looks like a way to set / change the CENTER OF ROTATION.
The SCREEN CAPTURE below illustrates this question with:
** A as the ORIGINAL IMAGE
** B as the current result of performing a 32 deg CCW ROTATION of A
** C as the desired result with the center of the OBJECT in the CENTER OF THE IMAGE without losing any pixels from A.
Each of these images (all displayed at ZOOM = 80%) has:
** A LINE through the center axis of the object (giving us the OBJECT ANGLE and the OBJECT CENTER)
** A POINT at that CENTER OF THE IMAGE
Right now it takes several operations to make the OBJECT be VERTICAL and CENTERED. I'm hoping that Adjust.ImageCommands.Rotate can be called in a way that will make this happen in one operation.
Thanks.
-- Matt

0
Best Answers
-
The center of rotation is the center of the ROI (or the ROI bounding rectangle if the ROI is irregular or has multiple regions). Thus, if you place a symmetrical ROI about your desired center of rotation, you will get that location as the center of the new, rotated image.
This will work so long as you are willing to lose part of the original image (as in your example, where I assume that you are only interested in the ROI surrounding the card).
If you need to keep the whole image, but rotate it about some point other than the image center, then you have no choice but to do essentially what you have done in your example. That is, you can rotate the image but then as a second step you need to create a larger image and paste the rotated image into it where you want it to end up (McImage.Geometry.Paste will do the job for you).
0 -
Also, instead of creating a new image and Paste, as Craig described, you can expand the image in given direction using the Canvas function.
Regards,
Yuri0
Answers
-
Craig and Yuri --
Thank you for your responses.
I think the combination will solve the problem.
Thanks again.
-- Matt
0 -
Craig and Yuri --
After working with the information you provided, I have generated CODE (see below) that accomplishes the task I need.
Here is a SCREEN CAPTURE with A, B, and C images and the data that was extracted from them.
I have attached a copy of "A +.JPG" so anyone interested can work with this example. The DOTS can be found with a BRIGHT THRESHOLD.
Some code CODE to LOCK (SYNC) ZOOM and then UNLOCK EVERYTHING would be helpful.
The LOCK and UNLOCK code that I generated with the MACRO RECORDER had an issue. It did not seem to just LOCK the ZOOM and it errored when the UNLOCK was executed. That is why the UNLOCK statements are commented. I see LOCKSELECTED but I haven't investigated using it. Perhaps someone could suggest a resolution to that issue.
I hope this information is helpful to PREMIER PROGRAMMERS.
Thanks.
-- Matt
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-Public Sub TestTranslateAndRotate() TranslateAndRotate (25, 47, 21.98) End Sub Private Sub TranslateAndRotate (Param_TranslateX As Double, Param_TranslateY As Double, Param_RotationAngle As Double) 'Declare local variables Dim docA, imageA, windowA Dim docB, imageB Dim docC, imageC Dim docD, imageD 'Connect with the original image A With Application.DocumentCommands.ActiveImage(Nothing) .Run(imageA) End With With Application.DocumentCommands.Activate(Nothing) .Run(imageA, docA) End With 'Delete any rois that may be active in image A With Select.RoiCommands.DeleteAll(Nothing) .Run(docA) End With 'Determine the dimensions for image B (translated but not rotated) Dim MyNewW, MyNewH As Integer MyNewW = ThisApplication.ActiveImage.Width + Param_TranslateX * 2 MyNewH = ThisApplication.ActiveImage.Height + Param_TranslateY * 2 'Call CANVAS to create image B with enough space to move the CENTER OF OBJECT to CENTER OF IMAGE without losing any pixels With Adjust.ImageCommands.Canvas(Nothing) .Anchor = Image.CanvasAnchor.BottomRight .Size = New System.Drawing.Size(MyNewW,MyNewH) .Background = System.Drawing.Color.FromArgb(CType(0, Byte),CType(0, Byte),CType(0, Byte)) .AverageBackground = False .Visible = True .Run(docA, imageB) End With 'Connect with image B With Application.DocumentCommands.ActiveImage(Nothing) .Run(imageB) End With With Application.DocumentCommands.Activate(Nothing) .Run(imageB, docB) End With 'Call ROTATE With Adjust.ImageCommands.Rotate(Nothing) .Orient = Image.OrientType.RotateAngle .Angle = -1 * Param_RotationAngle .Clip = MediaCy.IQL.Operations.mcWarpClip.mcwcNoClip ' .Clip = MediaCy.IQL.Operations.mcWarpClip.mcwcNoBoundsTransform .Visible = True .Run(docB, imageC) End With 'Connect with image C With Application.DocumentCommands.ActiveImage(Nothing) .Run(imageC) End With With Application.DocumentCommands.Activate(Nothing) .Run(imageC, docC) End With 'Activate the images in the appropriate sequence With Application.DocumentCommands.Activate(Nothing) .Run(imageC, docC) End With With Application.DocumentCommands.Activate(Nothing) .Run(imageB, docB) End With With Application.DocumentCommands.Activate(Nothing) .Run(imageA, docA) End With 'Align the images A, B, C With Application.WindowCommands.Align(Nothing) .MRU = True .Columns = 3 .Rows = 1 .Run() End With 'Lock (link) all windows together to adjust the ZOOM With Application.WindowCommands.LockAll(Nothing) .Run() End With 'Connect with imageA With Application.WindowCommands.Define(Nothing) .Run(docA, windowA) End With 'Set the ZOOM for A (B and C) to .8 With View.ImageViewCommands.Options(Nothing) .View.Magnification = 0.8R .View.AutoZoomMode = MediaCy.IQL.Display.Viewer.mcAutoZoomMode.mazmNone .View.Pan = 1 .Run(windowA) End With ' 'Unlock (unlink) all windows ' With Application.WindowCommands.unlock(Nothing) ' .Run() ' End With End Sub
0 -
All --
There is a problem with theTranslateAndRotate
I posted earlier.
In that version, the CENTER OF ROTATION needs to be in the QUADRANT of the IMAGE that is ABOVE and LEFT of the CENTER OF THE IMAGE so that the.Anchor = Image.CanvasAnchor.BottomRight
is the correct option.
To deal with CENTER OF ROTATION point in the other QUADRANTS of the IMAGE I have revisedTranslateAndRotate
to use.Anchor = Image.CanvasAnchor.TopLeft
when appropriate.
.Anchor = Image.CanvasAnchor.TopRight
.Anchor = Image.CanvasAnchor.BottomLeft
.Anchor = Image.CanvasAnchor.BottomRight
The revised version ofTranslateAndRotate
is below.
This version of the routine also tests PREMIER and arranges the images in a manner appropriate to the MDI (MULTIPLE DOCUMENT INTERFACE) MODE vs the DOCKING MODE.
I hope this information is helpful.
-- Matt
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-Private Sub TranslateAndRotate (Param_TranslateX As Double, Param_TranslateY As Double, Param_RotationAngle As Double) 'Declare local variables Dim docA, imageA, windowA Dim docB, imageB Dim docC, imageC 'Connect with the original image A With Application.DocumentCommands.ActiveImage(Nothing) .Run(imageA) End With With Application.DocumentCommands.Activate(Nothing) .Run(imageA, docA) End With With Application.WindowCommands.Define(Nothing) .Run(docA, windowA) End With 'Adjust the size if image A With View.ImageViewCommands.Options(Nothing) .View.Magnification = 2R .View.AutoZoomMode = MediaCy.IQL.Display.Viewer.mcAutoZoomMode.mazmBestFit .Run(windowA) End With 'Perform a TILE to place A in the upper left corner Application.MDICommands.TileVertically(Nothing).Run() 'Delete any rois that may be active in image A With Select.RoiCommands.DeleteAll(Nothing) .Run(docA) End With 'Determine the dimensions for image B (translated but not rotated) Dim MyNewW, MyNewH As Integer MyNewW = ThisApplication.ActiveImage.Width + Abs(Param_TranslateX) * 2 MyNewH = ThisApplication.ActiveImage.Height + Abs(Param_TranslateY) * 2 'Call CANVAS to create image B with enough space to move the CENTER OF OBJECT to CENTER OF IMAGE without losing any pixels If (Param_TranslateX > 0 And Param_TranslateY > 0) _ Then With Adjust.ImageCommands.Canvas(Nothing) .Anchor = Image.CanvasAnchor.BottomRight .Size = New System.Drawing.Size(MyNewW,MyNewH) .Background = System.Drawing.Color.FromArgb(CType(0, Byte),CType(0, Byte),CType(0, Byte)) .AverageBackground = False .Visible = True .Run(docA, imageB) End With End If If (Param_TranslateX > 0 And Param_TranslateY < 0) _ Then With Adjust.ImageCommands.Canvas(Nothing) .Anchor = Image.CanvasAnchor.TopRight .Size = New System.Drawing.Size(MyNewW,MyNewH) .Background = System.Drawing.Color.FromArgb(CType(0, Byte),CType(0, Byte),CType(0, Byte)) .AverageBackground = False .Visible = True .Run(docA, imageB) End With End If If (Param_TranslateX < 0 And Param_TranslateY < 0) _ Then With Adjust.ImageCommands.Canvas(Nothing) .Anchor = Image.CanvasAnchor.TopLeft .Size = New System.Drawing.Size(MyNewW,MyNewH) .Background = System.Drawing.Color.FromArgb(CType(0, Byte),CType(0, Byte),CType(0, Byte)) .AverageBackground = False .Visible = True .Run(docA, imageB) End With End If If (Param_TranslateX < 0 And Param_TranslateY > 0) _ Then With Adjust.ImageCommands.Canvas(Nothing) .Anchor = Image.CanvasAnchor.BottomLeft .Size = New System.Drawing.Size(MyNewW,MyNewH) .Background = System.Drawing.Color.FromArgb(CType(0, Byte),CType(0, Byte),CType(0, Byte)) .AverageBackground = False .Visible = True .Run(docA, imageB) End With End If 'Connect with image B With Application.DocumentCommands.ActiveImage(Nothing) .Run(imageB) End With With Application.DocumentCommands.Activate(Nothing) .Run(imageB, docB) End With 'Call ROTATE With Adjust.ImageCommands.Rotate(Nothing) .Orient = Image.OrientType.RotateAngle .Angle = -1 * Param_RotationAngle .Clip = MediaCy.IQL.Operations.mcWarpClip.mcwcNoClip ' .Clip = MediaCy.IQL.Operations.mcWarpClip.mcwcNoBoundsTransform .Visible = True .Run(docB, imageC) End With 'Connect with image C With Application.DocumentCommands.ActiveImage(Nothing) .Run(imageC) End With With Application.DocumentCommands.Activate(Nothing) .Run(imageC, docC) End With 'Activate the images in the appropriate sequence and close the With Application.DocumentCommands.Activate(Nothing) .Run(imageC, docC) End With With Application.DocumentCommands.Activate(Nothing) .Run(imageB, docB) End With 'Close B without prompting the user ThisApplication.ActiveImage.Modified = False ThisApplication.ActiveImage.Close() With Application.DocumentCommands.Activate(Nothing) .Run(imageA, docA) End With 'Arrange the open images A, C If ThisApplication.MDISupport = True _ Then 'MDI MODE Application.MDICommands.TileVertically(Nothing).Run() Else 'DOCKING MODE With Application.WindowCommands.Align(Nothing) .MRU = True .Columns = 3 .Rows = 1 .Run() End With End If 'Lock (link) all windows together to adjust the ZOOM With Application.WindowCommands.LockAll(Nothing) .Run() End With 'Set the ZOOM for A (B and C) to .8 With View.ImageViewCommands.Options(Nothing) .View.Magnification = 0.8R .View.AutoZoomMode = MediaCy.IQL.Display.Viewer.mcAutoZoomMode.mazmNone .View.Pan = 1 .Run(windowA) End With ' 'Unlock (unlink) all windows ' With Application.WindowCommands.unlock(Nothing) ' .Run() ' End With End Sub
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions