Home Image-Pro Automation (Macros, Apps, Reports)

Controlling the ROTATION and TRANSLATION of an IMAGE using the MOUSE . . .

All --

A recent application generated QUESTIONS / DISCUSSIONS titled

    Options within IMAGE COMPARE . . .

and

    Manipulating and Querying the PASTE OVERLAY using SOFTWARE . . .

Those discussions resolved the issues within that application.

A new application needs:

** ROTATION and TRANSLATION controlled by the MOUSE rather than by a SPIN CONTROL
** ROTATION and TRANSLATION are on just one image rather than on a COMPARISON / OVERLAY of TWO IMAGES

The best that I can do is:

    Public Function ROTATE01() As SimpleScript
        ROTATE01 = New SimpleScript
        Dim doc1, image1, doc2

        With Application.DocumentCommands.Active(ROTATE01)
            .Run(doc1)
        End With

        With Adjust.ImageCommands.Rotate(ROTATE01)
            .Interactive = True
            .Orient = Image.OrientType.RotateAngle
            .Angle = -117.70737479935R
            .Clip = MediaCy.IQL.Operations.mcWarpClip.mcwcClip
            .Visible = True
            .Run(doc1, image1)
        End With

        With Application.DocumentCommands.Activate(ROTATE01)
            .Run(image1, doc2)
        End With

    End Function


    Public Function TRANSLATE01() As SimpleScript
        TRANSLATE01 = New SimpleScript
        Dim doc1, image1

        With Application.DocumentCommands.Active(TRANSLATE01)
            .Run(doc1)
        End With

        With Select.RoiCommands.DeleteAll(TRANSLATE01)
            .Run(doc1)
        End With

        With Adjust.ImageCommands.ClipboardCopy(TRANSLATE01)
            .Run()
        End With

        With Adjust.ImageCommands.ClipboardPaste(TRANSLATE01)
            .Interactive = True
            .Location = New System.Drawing.Point(-314,-235)
            .Run()
        End With

    End Function

Problems . . .

ROTATE01 does not give the user the same tool as

    ADJUST RIBBON + GEOMETRY + ROTATE + PREVIEW

TRANSLATE01 gives the user the right tool but it opens the PROJECT EXPLORER and displays a prompt that the USER must interact with.

Questions . . .

1) Is there a way that a USER can ROTATE and TRANSLATE an IMAGE AA (Left) with the MOUSE / CURSOR to generate IMAGE BB (Right) without interacting with the PROJECT EXPLORER?
2) Is there a way to learn the amount of ROTATION and TRANSLATION that the USER deemed appropriate?




 

Thank you very much.

-- Matt








Answers

  • All --

    When I record the ROTATE and TRANSLATE functions using PREMIER, for the AA image above I get a

        ROTATE of 159.784541083543
        TRANSLATE of -47,-33 (pixels)

    but I need the MACRO to allow these to be set quickly and easily using the MOUSE rather than clicking BUTTONS or SPINBOXES.

    I'm basically looking for something like ADOBE PHOTOSHOP calls FREE TRANSFORM (CONTROL + T) and that would tell the MACRO what the values are for

        ** ROTATION ANGLE
        ** TRANSLATION X and Y

    Thanks.

    -- Matt



  • Matt,

    Are you aware that you can activate the Preview control and rotate the image interactively with mouse?



    Or you are looking for something else?

    Yuri
  • You could also copy the image to the clipboard and then paste it into the Annotation as a bitmap. (Or even better, you could just create a McGraphObjBitmap and use SetBitmap to assign the desired McImage for display).  The user could then select the bitmap and move/rotate it just like any other rectangular annotation object.  You would probably want to clear the McGraphObjBitmap.Style propertie's mcGraphobjStyle.mcgsAllowResize property, so that the user could only rotate and move the bitmap, but not resize it. 
  • Yuri and Craig --

    Thank you for your suggestions.

    ** Yuri **

    I am looking for the VB code that will trigger the FUNCTIONS that you showed in your SCREEN CAPTURE.  Doing this manually takes at least 3 MOUSE CLICKS and CAREFUL NAVIGATION.  They do this 100s of times a day so each click slows them down and fussy navigation is tiresome.

    When I recorded the ROTATE function that you suggest, I got the code (with a couple of small differences) that I included as ROTATE01.

    I have recorded this again as Yuri01 (without the "apply") and as Yuri02 (with an "apply") resulting in

        Public Function Yuri01() As SimpleScript
            Yuri01 = New SimpleScript
    
            With Application.RibbonCommands.SelectRibbonTab(Yuri01)
                .TabName = "Adjust"
                .Run()
            End With
    
        End Function
    
    
        Public Function Yuri02() As SimpleScript
            Yuri02 = New SimpleScript
            Dim doc1, image1, doc2
    
            With Application.RibbonCommands.SelectRibbonTab(Yuri02)
                .TabName = "Adjust"
                .Run()
            End With
    
            With Application.DocumentCommands.Active(Yuri02)
                .Run(doc1)
            End With
    
            With Adjust.ImageCommands.Rotate(Yuri02)
                .Orient = Image.OrientType.RotateAngle
                .Angle = 118.622956734463R
                .Clip = MediaCy.IQL.Operations.mcWarpClip.mcwcClip
                .Visible = True
                .Run(doc1, image1)
            End With
    
            With Application.DocumentCommands.Activate(Yuri02)
                .Run(image1, doc2)
            End With
    
        End Function
    

    I cannot determine how to make this PAUSE and allow the USER to interact with the IMAGE then proceed to the APPLY.

    The institution that is looking for this PREMIER AUTOMATION has purchased 3 PREMIER STATIONS to replace 3 PLUS STATIONS (with AUTOMATION) that they run 100s of samples through each day.  In their current system a GRID is put on the image and then the GRID is rotated to the selected angle (using the MOUSE), then the image is rotated to match the GRID.

    When I attempt the same thing with PREMIER, I have to work with the ANGLE through a DIALOG BOX rather than through the MOUSE.  The USER GROUP has said that doing this to 100s of images per day is a BIG PROBLEM that they worked around in PLUS.

    ** Craig **

    I attempted to follow your suggestion and I was able to PASTE / PASTE BITMAP within

        PREMIER + SELECT RIBBON + ANNOTATE TOOLS + PASTE

    Using the SELECT TOOL to activate the PASTED BITMAP OBJECT does allow me to ROTATE the OBJECT (when I get the MOUSE close enough to the ROTATION POINT) but the MACRO LANGUAGE does not seem to point me to the ANGLE of the ROTATION.  Here are two SUBS that I recorded trying to follow your suggestion.

        Public Function CRAIG01() As SimpleScript
            CRAIG01 = New SimpleScript
            Dim image1
    
            With Application.DocumentCommands.ActiveImage(CRAIG01)
                .Run(image1)
            End With
    
            With Select.AnnotationsCommands.MoveSelected(CRAIG01)
                .Overlay = Overlays.OverlayType.AnnotationsOverlay
                .Delta = New System.Drawing.PointF(-4.953369F,-2.972015F)
                .Run(image1)
            End With
    
        End Function
    
    
        Public Function Craig02() As SimpleScript
            Craig02 = New SimpleScript
            Dim image1, doc1
    
            With Application.DocumentCommands.ActiveImage(Craig02)
                .Run(image1)
            End With
    
            With Select.AnnotationsCommands.MoveSelected(Craig02)
                .Interactive = True
                .Overlay = Overlays.OverlayType.AnnotationsOverlay
                .Delta = New System.Drawing.PointF(-19.81352F,158.5081F)
                .Run(image1)
            End With
    
            With Select.AnnotationsCommands.SelectObject(Craig02)
                .Overlay = Overlays.OverlayType.AnnotationsOverlay
                .GraphicObject = 0
                .Selected = False
                .Run(image1)
            End With
    
            With Application.DocumentCommands.Define(Craig02)
                .Run(image1, doc1)
            End With
    
            With Select.AnnotationsCommands.BurnIn(Craig02)
                .Overlay = Overlays.OverlayType.AnnotationsOverlay
                .Run(doc1)
            End With
    
        End Function


    I added INTERACTIVE to the MoveSelected in CRAIG02 and now I think we are pretty close.  Two questions:

    1) How can I get the ANGLE that was generated by the USER so that I can use it in

        Adjust.ImageCommands.Rotate
    2) How do I implement your suggestion to:

    "You would probably want to clear the McGraphObjBitmap.Style propertie's mcGraphobjStyle.mcgsAllowResize property, so that the user could only rotate and move the bitmap, but not resize it."

    I could not find any VB code on my computer that has that style and the closest I could get in the HELP FILES is:

    Image-Pro Premier Automation Help
    mcGraphObjStyle Enumeration
    Automation ReferenceMediaCy.IQL.Display.Overlays ► mcGraphObjStyle Visual Basic

    and the closest command I could come up with is

            MediaCy.IQL.Display.Overlays.mcGraphObjStyle.mcgsAllowResize = False
    

    but PREMIER doesn't like it.

    It seems like I need something like

                .LineEndingStart = MediaCy.IQL.Display.Overlays.mcGraphObjLineEnding.mcgleNothing

    within

            With Select.Annotations.ShapeCommands.Shape(Nothing)
                .Overlay = Overlays.OverlayType.AnnotationsOverlay
                .ApplyTo = Overlays.ShapeAction.SelectedGraphicObject
                .LineEndingStart = MediaCy.IQL.Display.Overlays.mcGraphObjLineEnding.mcgleNothing
                .Run(doc1)
            End With

    but I don't know how to do this.

    ** **

    I hope you fellas can point me in a good direction so we can go from where we are now (close) to code that will allow me to create a BUTTON that will trigger a routine that will give them the a tool that will have a ROTATION TOOL and then press a OK / CONTINUE button.  After that, the routine will remember the desired ROTATION ANGLE (and maybe TRANSLATION in one step).

    Thanks again.

    -- Matt
  • Test Comment for Matt's ISP test.
  • All --

    I have adjusted the NOTIFICATION PREFERENCES as suggested earlier so hopefully the FORUM will work well now.

    I think that CRAIG02 is the closest thing to the TOOL / ROUTINE that I need.

    Can someone enlighten me on how to

        1) Allow
            1a) TRANSLATION (via MOUSE) and
            1b) ROTATION (via MOUSE)
            1c) but lock out SCALE / RESIZE
        2) Extract the TRANSLATION X and Y and ROTATION ANGLE

    I think we have 1a and 1b done.

    I don't understand the SYNTAX to make 1c happen based on CRAIG's advice.

    2 is probably something like remembering the DELTA but I don't see it under

    Image-Pro Premier Automation Help
    MoveSelected Class
    Automation ReferenceMediaCy.Commands.Overlays ► MoveSelected Visual Basic


    Thanks.

    -- Matt


  • Back to your actual question, Matt.  Before trying to address the issues that you bring up, I think we should try to step back and make sure that some of the fundamentals of Premier macro programming are clear(ish).

    Macro scripting in Premier actually supports two levels of API: Commands and native MediaCy.IQL calls.  When you record actions from the user interface as a macro, you are generating a SimpleScript consisting of a series of McCommand.Run calls.  As you can see from macros that you record and the one shown here from Yuri, the basic pattern is to access a predefined McCommand object, set its properties as desired and then call Run.  Here's an example from your Yuri01 recorded macro:
           With Adjust.ImageCommands.Rotate(Yuri02)
                .Orient = Image.OrientType.RotateAngle
                .Angle = 118.622956734463R
                .Clip = MediaCy.IQL.Operations.mcWarpClip.mcwcClip
                .Visible = True
                .Run(doc1, image1)
            End With
    
    Note the pattern above where the Orient, Angle, Clip and Visible properties of the Adjust.ImageCommands.Rotate McCommand are assigned before the command is Run.

    McCommand objects are wrappers around the code that executes various operations accessible from the UI; they internally consist of a mix of .NET code and calls to the native MediaCy.IQL image analysis support libraries (DLLs).   For operations that are not available from the UI, you can often craft a solution that uses these low-level libraries directly.  In particular, if you want to create a bitmap displaying an image which the user can rotate, you can do so with native IQL calls.

    I'll work up an example macro for you, but I have some other issues to deal with today, so it may take a couple of days before I can post it.
  • Craig --

    Thank you very much for the information and the guidance.

    There is much about PREMIER SCRIPTING that I have learned from RECORDED CODE and TRAINING / EXAMPLES provided by MEDIACY.COM but obviously there is much more for me to learn.

    I have looked at

    Image-Pro Premier Automation Help
    Rotate Property (parent)
    Automation ReferenceMediaCy.Automation.AdjustImageCommandsRotate[([( McCommand])]) Visual Basic

    and tried to manipulate the routines like YURI02 but I don't seem to be able to get the macro to access a PREMIER MODE similar to

        ADJUST RIBBON + GEOMETRY + ROTATE + PREVIEW

    and then wait for the USER to ADJUST before the APPLY happens.

    An example from you on how to do this through ROTATE or through ANNOTATIONS will be SUPER for me and the other folks here on the FORUM.

    Thanks again.

    -- Matt
  • All --

    I have developed a way to get the ROTATE and the TRANSLATE using a USER CREATED LINE.

    After the user creates a LINE along the CENTRAL AXIS of their image feature, the PREMIER APP extracts the CENTER and ANGLE for that LINE.  The PREMIER APP then uses the LINE CENTER and LINE ANGLE to drive a ROTATION and TRANSLATION modify the IMAGE so that the CENTRAL AXIS of the FEATURE is VERTICAL and CENTERED within the image.

    This can be repeated for FINE TUNING.

    This will work in the sort run but it would be super to have a MOUSE DRIVEN ROTATE and TRANSLATE that would emulate the mechanism they used in PLUS.

    Thanks.

    -- Matt
Sign In or Register to comment.