Macro Control of IMAGE COMPARE TOOL . . .
2018-01-16-154048
All --
I have two images AA and BB that need to be ROTATED, TRANSLATED, and SCALED so that they are ALIGNED as well as possible.
I have tried using the ALIGNMENT TOOL but it does not seem to be as good a tool for the job as the IMAGE COMPARE TOOL.
Using the PREMIER MACRO RECORD TOOL, I generated the ROUTINE below while working with the IMAGE COMPARE TOOL to ROTATE, TRANSLATE, and SCALE the AA IMAGE (RED) to match the BB IMAGE (GRN).
QUESTIONS . . .
Q1) If the USER can manipulate the AA image using the MOUSE within the IMAGE COMPARE TOOL, how can the CODE extract the values for ROTATION, TRANSLATION, and SCALE that have been applied to AA to make it match BB from the IMAGE COMPARE TOOL?
Q2) If the USER has values for ROTATION, TRANSLATION, and SCALE, is there any problem feeding those to the IMAGE COMPARE TOOL via
Q3) What FUNCTIONS would allow the CODE to handle the work done between IMAGE 2 and IMAGE 4 below?
Q4) Is there a function that would allow the CODE to extract the AA IMAGE that has been ROTATED, TRANSLATED, and SCALED from the IMAGE COMPARE TOOL so that it could be saved as something like AA+ as a very close match to BB?
Thanks in advance.
-- Matt
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
ROUTINE
IMAGE 1 -- ORIGINAL CONFIGURATION with MONO versions of AA and BB and RGB versions of AA and BB for simplifying IMAGE COMPARE.
IMAGE 2 -- RESULT OF RUNNING NEWMACRO ROUTINE
IMAGE 3 -- MANUAL RELOCATION AND RESIZE OF WINDOWS WITHIN PREMIER
IMAGE 4 -- MANUAL CLOSE OF IMAGE COMPARE TOOL AND RELOCATION AND RESIZE OF COMPARE VIEW
All --
I have two images AA and BB that need to be ROTATED, TRANSLATED, and SCALED so that they are ALIGNED as well as possible.
I have tried using the ALIGNMENT TOOL but it does not seem to be as good a tool for the job as the IMAGE COMPARE TOOL.
Using the PREMIER MACRO RECORD TOOL, I generated the ROUTINE below while working with the IMAGE COMPARE TOOL to ROTATE, TRANSLATE, and SCALE the AA IMAGE (RED) to match the BB IMAGE (GRN).
QUESTIONS . . .
Q1) If the USER can manipulate the AA image using the MOUSE within the IMAGE COMPARE TOOL, how can the CODE extract the values for ROTATION, TRANSLATION, and SCALE that have been applied to AA to make it match BB from the IMAGE COMPARE TOOL?
Q2) If the USER has values for ROTATION, TRANSLATION, and SCALE, is there any problem feeding those to the IMAGE COMPARE TOOL via
With Process.CompareCommands.SetAngle(NewMacro) .Angle = -142.926926647043R .Run(doc1, image2) End With With Process.CompareCommands.SetPosition(NewMacro) .Center = New System.Drawing.PointF(902.8478F,632.179F) .Size = New System.Drawing.SizeF(1714F,1349F) .Run(doc1, image2) End With
Q3) What FUNCTIONS would allow the CODE to handle the work done between IMAGE 2 and IMAGE 4 below?
Q4) Is there a function that would allow the CODE to extract the AA IMAGE that has been ROTATED, TRANSLATED, and SCALED from the IMAGE COMPARE TOOL so that it could be saved as something like AA+ as a very close match to BB?
Thanks in advance.
-- Matt
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
ROUTINE
Public Function NewMacro() As SimpleScript NewMacro = New SimpleScript Dim doc1 Dim var1 = "BB_RGB", image1 Dim var2 = "AA_RGB", image2, window1 Dim var3 = "Image_Compare_View", doc2, image3 With Process.CompareCommands.[New](NewMacro) .Run(doc1) End With With Application.DocumentCommands.Activate(NewMacro) .Run(doc1, doc1) End With With Application.RibbonCommands.SelectRibbonTab(NewMacro) .TabName = "ImageCompare" .Run() End With With Adjust.ImageCommands.Define(NewMacro) .Run(var1, image1) End With With Process.CompareCommands.Add(NewMacro) .FilterInput = True .Run(doc1, image1) End With With Adjust.ImageCommands.Define(NewMacro) .Run(var2, image2) End With With Process.CompareCommands.Add(NewMacro) .FilterInput = True .Run(doc1, image2) End With With Process.CompareCommands.SelectImage(NewMacro) .Selected = True .Run(doc1, image2) End With With Process.CompareCommands.SetAngle(NewMacro) .Angle = -142.926926647043R .Run(doc1, image2) End With With Process.CompareCommands.SetPosition(NewMacro) .Center = New System.Drawing.PointF(902.8478F,632.179F) .Size = New System.Drawing.SizeF(1714F,1349F) .Run(doc1, image2) End With With Application.WindowCommands.Define(NewMacro) .Run(doc1, window1) End With With Application.WindowCommands.ZoomPanScroll(NewMacro) .AutoZoom = Window.ZoomPanScroll.AutoZoomMode.None .Zoom = 28.3547257876313R .Pan = 36 .Scroll = 0 .Run(window1) End With With Process.CompareCommands.SetPosition(NewMacro) .Center = New System.Drawing.PointF(903.4931F,623.2288F) .Size = New System.Drawing.SizeF(1656.282F,1303.415F) .Run(doc1, image2) End With With Application.RibbonCommands.SelectRibbonTab(NewMacro) .TabName = "Process" .Run() End With With Application.DocumentCommands.Activate(NewMacro) .Run(var3, doc2) End With With Process.CompareCommands.Apply(NewMacro) .Type = MediaCy.Addins.ImageCompare.ResultTypes.View .Cleanup = True .Run(doc1, image3) End With With Application.DocumentCommands.Activate(NewMacro) .Run(doc1, doc1) End With With Application.RibbonCommands.SelectRibbonTab(NewMacro) .TabName = "Process" .Run() End With With Process.CompareCommands.SelectImage(NewMacro) .Selected = False .Run(doc1, image2) End With With Application.DocumentCommands.Activate(NewMacro) .Run(doc2, doc2) End With End Function
IMAGE 1 -- ORIGINAL CONFIGURATION with MONO versions of AA and BB and RGB versions of AA and BB for simplifying IMAGE COMPARE.
IMAGE 2 -- RESULT OF RUNNING NEWMACRO ROUTINE
IMAGE 3 -- MANUAL RELOCATION AND RESIZE OF WINDOWS WITHIN PREMIER
IMAGE 4 -- MANUAL CLOSE OF IMAGE COMPARE TOOL AND RELOCATION AND RESIZE OF COMPARE VIEW
0
Answers
All --
Can CODE within the PREMIER WORKBENCH control the IMAGE COMPARE TOOL as queried above?
Thanks.
-- Matt
All you need is McImageCompareDocument. The ex returns the censer and angle of the first image.
To control images in Image Compare view use McImageCompareDocument.SetPosition/SetAngle, etc.
Thanks,
Nikita.
Nikita --
Thank you for the INFORMATION and CODE.
I'll be working on that project this PM and the only other thing I think I may need is to know if you have any suggestions to address
"Q3) What FUNCTIONS would allow the CODE to handle the work done between IMAGE 2 and IMAGE 4 below?
Q4) Is there a function that would allow the CODE to extract the AA IMAGE that has been ROTATED, TRANSLATED, and SCALED from the IMAGE COMPARE TOOL so that it could be saved as something like AA+ as a very close match to BB?"
The RECORD MACRO TOOL did not add anything to the CODE that helps me with these operations.
Thanks again.
-- Matt
Nikita --
I have attempted to use the INFORMATION and CODE you provided and I have mixed results.
The QUERY for the X, Y, and ANGLE works like a champ. Thanks.
The SET for the ANGLE (I have not tried X and Y yet) is not working properly.
Will you please look at my CODE and tell me where I have gone wrong.
ADDITIONAL INFORMATION . . .
After the TIF IMAGES are added into the IMAGE COMPARE by the CODE behind the SETUP COMPARE BUTTON, they are closed in PREMIER. I think this is what generated the ".tif0" entries when I do the RECORDING that generated the DIM STATEMENTS in UPDATE COMPARE IMAGE.
Your assistance with this will be greatly appreciated.
-- Matt
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
The UPDATE COMPARE VALUES below reads the X, Y, and ANGLE values properly from the RED (DIAG) IMAGE (the SECOND IMAGE loaded into IMAGE COMPARE) and updates the DIALOG BOX.
The UPDATE COMPARE IMAGE below is my attempt to set the ANGLE based on the value in the TEXTBOX but the result is that BOTH IMAGES in the IMAGE COMPARE are ROTATED.
This IMAGE shows the IMAGE COMPARE with the TREAT (GREEN) IMAGE added first and the DIAG (RED) IMAGE added second.
This IMAGE shows that the UPDATE COMPARE VALUES performs properly.
This IMAGE shows the results of running the UPDATE COMPARE IMAGE after the ANGLE TEXTBOX is set to 90.
The angle applied to all images in the view if "image2" is null or not found in the view. Just verify what this image exists in the view. You can use McImageCompareDocument.Info to get complete information about the Image Compare View including images, angles, positions.
Thanks,
Nikita.
Nikita --
Thank you for your response.
I will try to weave the information you have provided into the CODE.
I will update with the results ASAP.
Thanks again.
-- Matt
Nikita --
I tried to apply the information you gave me and I was not successful.
I went back to trying to RECORD and MODIFY and I have bumped into a similar issue.
The RECORDED CODE applies the TRANSLATION and ROTATION to both images within IMAGE COMPARE.
Please see the SCREEN CAPTURES and CODE below.
Is there a resolution for this?
Thanks.
-- Matt
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Here is an image that shows PREMIER after the SETUP COMPARE
Here is an image that shows PREMIER after recording NEW MACRO
Here is NEW MACRO
Public Function NewMacro() As SimpleScript NewMacro = New SimpleScript Dim doc1 Dim var1 = "DIAG_01_RGB_tif", image1 With Application.DocumentCommands.Active(NewMacro) .Run(doc1) End With With Adjust.ImageCommands.Define(NewMacro) .Run(var1, image1) End With With Process.CompareCommands.SelectImage(NewMacro) .Selected = True .Run(doc1, image1) End With With Process.CompareCommands.SetPosition(NewMacro) .Center = New System.Drawing.PointF(1100.03F,1179.746F) .Size = New System.Drawing.SizeF(1714F,1349F) .Run(doc1, image1) End With With Process.CompareCommands.SetAngle(NewMacro) .Angle = -27.6225073939496R .Run(doc1, image1) End With With Process.CompareCommands.SelectImage(NewMacro) .Selected = False .Run(doc1, image1) End With End Function
Here is an image that shows IMAGE COMPARE after performing the same SETUP COMPARE and then running NEW MACRO.
Thanks,
Nikita.
Here is the PRODUCT and VERSION information.
Nikita --
Thinking that the IMAGE COMPARE TOOL might have been confused by all of the TRIAL and ERROR that it has been subjected to, I:
** shut down and restarted PREMIER
** opened the two images manually
** loaded the two images into IMAGE COMPARE manually
** ran NEW MACRO
The result was the same . . . both layers ROTATED and TRANSLATED.
Any suggestions?
Thanks.
-- Matt
Try to update to 9.3.3, unload other projects and references, Try to run following macro and check what correct image is selected in the view:
Public Function NewMacro() As SimpleScript NewMacro = New SimpleScript Dim doc1 Dim var1 = "DIAG_01_RGB_tif", image1 With Application.DocumentCommands.Active(NewMacro) .Run(doc1) End With With Adjust.ImageCommands.Define(NewMacro) .Run(var1, image1) End With With Process.CompareCommands.SelectImage(NewMacro) .Selected = True .Run(doc1, image1) End With End Function
Nikita.
Nikita --
If I move the layers/images around manually before I run your NEW MACRO, the correct image is selected.
When I add the SET ANGLE to it, everything is turned though
When I put a msgbox in between the SELECT IMAGE and the SET ANGLE, the correct image is not selected.
I only have one project loaded and I am not sure what references could be unloaded.
Would it be possible to WEBEX to investigate this abnormal behavior?
Thanks.
-- Matt
Nikita --
Checking WWW.MEDIACY.COM, the latest PREMIER 3D seems to be the V9.3.2 I am running.
This is shown below.
Any further thoughts on a way to make the CODE control the IMAGE COMPARE?
Thanks.
-- Matt
I'll double check 9.3.3 patch for IPP 3D on website. The preferable way to check for updates is "Help/Check for Updates".
I'm not sure why the simple macro works differently on your system. Could you try the next steps:
1) cleanup user's identities: %AppData%, Roaming\Media Cybernetics folder,
2) cleanup program settings: %AppData% Local\Media_Cybernetics folder,
3) cleanup user's document folder
4) uninstall IPP 3D, #1, #2, #3, install IPP 3D
Thanks,
Nikita.
Nikita --
Thank you for your response.
I would like to avoid what seems like MAJOR SURGERY to resolve what seems like a MINOR ISSUE.
I will transfer the app to my other computer which has PREMIER 9.3.3 and try it there. If it works properly there, I will follow your suggestion.
If it doesn't work there, I'll let you know and we can make a plan to investigate this.
Thanks again.
-- Matt
Nikita --
I loaded the IMAGES into IMAGE COMPARE and ran the NEW MACRO CODE on PREMIER 9.2 and it worked.
If I used CODE to load the IMAGES into IMAGE COMPARE it did not work.
As mentioned before, the CODE to load the IMAGES into IMAGE COMPARE closes the ORIGINAL IMAGES.
When I load the IMAGES into IMAGE COMPARE and then close the IMAGES (leaving IMAGE COMPARE open) then NEW MACRO does not work.
This seems to be the same in PREMIER 9.2 and PREMIER 3D 9.3.2
Can you please check if your CODE works properly if you:
OPEN IMAGES
LOAD IMAGES INTO IMAGE COMPARE
CLOSE IMAGES (LEAVING IMAGE COMPARE OPEN)
RUN NEW MACRO
If this works on your computer then we have a mystery.
If this does not work on your computer, can you suggest a way to make this work because it does not seem that once the images are within IMAGE COMPARE that they should have to be open within PREMIER.
Thanks.
-- Matt
Right, you cannot close source images because command
With Adjust.ImageCommands.Define(NewMacro) .Run(var1, image1) End With
checks open images. It just return nothing if not found.There is no mystery in my test. As you can see in the screenshot the source images kept open.
Nikita.
Nikita --
Sorry that I did not make it clear that the ORIGINAL IMAGES were being closed.
I thought that
was connecting with the images within the IMAGE COMPARE WINDOW.
If the ORIGINAL IMAGES must remain open, I can deal with that.
I hope the information we have posted here is helpful to another PREMIER PROGRAMMER working with CODE to control the IMAGE COMPARE TOOL.
Thank you for helping resolving this mystery.
-- Matt