FFT TOOL in PREMIER . . .

2017-11-28-144301

All --

I am using the FFT TOOL in PREMIER (9.3.2) from a PREMIER APP.  The FFT TOOL is called in the SUBROUTINE below.

The DIALOG BOX for the FFT TOOL seems to be opened by the following code.
        'Create the FORWARD FFT IMAGE
        With Process.FFTCommands.Forward(Nothing)
            .Run(imageB, imageC)
        End With

The DIALOG BOX for the FFT TOOL seems to be closed by the following code.
        'Activate the FORWARD FFT IMAGE
        With Application.DocumentCommands.Activate(Nothing)
            .Run(imageC, docC)
        End With

        'Close the ACTIVE IMAGE
        ThisApplication.ActiveImage.Modified = False
        ThisApplication.ActiveImage.Close
Since the USER does not need to interact with the DIALOG BOX for the FFT TOOL, is there a modification that can be made that will:

    A) Keep the DIALOG BOX for the FFT TOOL from being displayed
    B) Close the DIALOG BOX for the FFT TOOL immediately after it is
        opened so it is on the screen for the minimum amount of time possible

Thanks.

-- Matt

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
    Private Sub button_Smooth_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button_Smooth.Click

        'Declare LOCAL VARIABLES
        Dim imageA, docA
        Dim imageB, docB
        Dim imageC, docC

        'Connect with ORIGINAL IMAGE
        With Application.DocumentCommands.ActiveImage(Nothing)
            .Run(imageA)
        End With

        'Extract the GREEN CHANNEL
        With Adjust.ImageCommands.ExtractChannel(Nothing)
            .Channel = 1
            .Interpretation = MediaCy.IQL.Engine.mcInterpretation.mciRGB
            .Run(imageA, imageB)
        End With

        'Activate the ORIGINAL IMAGE
        With Application.DocumentCommands.Activate(Nothing)
            .Run(imageA,docA)
        End With

        'Close the ACTIVE IMAGE
        ThisApplication.ActiveImage.Modified = False
        ThisApplication.ActiveImage.Close

        'Connect with the GREEN CHANNEL IMAGE
        With Application.DocumentCommands.Activate(Nothing)
            .Run(imageB, docB)
        End With

        'Call the TILE function to put the current image into the upper left hand corner
        Application.MDICommands.TileVertically(Nothing).Run()

        'Configure FFT TOOL
        With Process.FFTCommands.Options(Nothing)
            .Hanning = True
            .Transition = 50
            .Symmetric = True
            .PreserveNil = True
            .FilterType = MediaCy.IQL.Filters.mcfftFilterType.mcfftfLowPass
            .Run()
        End With

        'Create the FORWARD FFT IMAGE
        With Process.FFTCommands.Forward(Nothing)
            .Run(imageB, imageC)
        End With

        'Connect with the FORWARD FFT IMAGE
        With Application.DocumentCommands.Activate(Nothing)
            .Run(imageC, docC)
        End With

        'Delete ALL ROIS
        With [Select].RoiCommands.DeleteAll(Nothing)
            .Run(docC)
        End With

        'Select SINGLE ROI MODE
        With [Select].RoiCommands.MultipleROIs(Nothing)
            .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Unchecked
            .Run(docC)
        End With

        'Determine the ROI DIMENSIONS
        Dim Smooth_Image_Width As String = "272"
        Dim Smooth_Image_Height As String = "304"

        Dim MyLeft, MyRight, MyTop, MyBottom As Integer

        MyLeft = _
            (ThisApplication.Activeimage.Width / 2) - _
            (CLng(Smooth_Image_Width) / 2)
        MyRight = _
            (ThisApplication.Activeimage.Width / 2) + _
            (CLng(Smooth_Image_Width) / 2)
        MyTop = _
            (ThisApplication.Activeimage.Height / 2) - _
            (CLng(Smooth_Image_Height) / 2)
        MyBottom = _
            (ThisApplication.Activeimage.Height / 2) + _
            (CLng(Smooth_Image_Height) / 2)

        'Add RECTANGULAR ROI to FORWARD FFT IMAGE
        With [Select].RoiCommands.Add(Nothing)
            .ROIType = Features.ROI.ROITypes.Rectangle
            .Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
            .Points.Add(New System.Drawing.PointF(MyLeft,MyTop))
            .Points.Add(New System.Drawing.PointF(MyRight,MyBottom))
            .Angle = 0R
            .Run(imageC)
        End With

        'Perform the SELECTED FFT FILTER
        With Process.FFTCommands.ApplyFilter(Nothing)
            .Run(imageC)
        End With

        'Perform the INVERSE FFT FUNCTION and put the result into the GREEN CHANNEL IMAGE
        With Process.FFTCommands.Inverse(Nothing)
            .Run(docC, imageB)
        End With

        'Activate the FORWARD FFT IMAGE
        With Application.DocumentCommands.Activate(Nothing)
            .Run(imageC, docC)
        End With

        'Close the ACTIVE IMAGE
        ThisApplication.ActiveImage.Modified = False
        ThisApplication.ActiveImage.Close

        'Activate the GREEN CHANNEL IMAGE
        With Application.DocumentCommands.Activate(Nothing)
            .Run(imageB, docB)
        End With

        'Call the TILE function to put the current image into the upper left hand corner
        Application.MDICommands.TileVertically(Nothing).Run()

    End Sub

Best Answer

  • Accepted Answer
    Hi Matt,

    FFT options panel is shown automatically when FFT image is activated.

    There are several ways to handle the issue:

    1. Don't show FFT image. You can create FFT image as invisible, so it will not show and correspondingly no FFT panel will pop up:

            With Process.FFTCommands.Forward(Nothing)
                .Visible=False'create invisible FFT image
                .Run(doc1, image1)
            End With
    

    2. You can undock, move or resize FFT options panel to make it small or outside of the screen, so next time you create your FFT image, the panel will be shown with minimum impact on the screen.

    3. You can close the FFT panel using the following code (but the panel will pop up again when FFT image is activated):

            With Automate.ScriptingCommands.CodeCommand(Nothing)
                If .Run() Then
                    'close FFT Options panel
                    If ThisApplication.Panels.Control("FFTOptionsPanel") IsNot Nothing Then
                        ThisApplication.Panels.Remove("FFTOptionsPanel")
                    End If
                End If
            End With
    

    Since the goal of your macro is to apply LoPass filter using FFT, the first option, using invisible FFT image looks the best. I've modified your macro to use invisible image (imageC) and replaced some commands by low level IQL operators.

    Public Sub button_Smooth_Click
    
            'Declare LOCAL VARIABLES
            Dim imageA, docA
            Dim imageB, docB
            Dim imageC As McImage, docC
    
            'Connect with ORIGINAL IMAGE
            With Application.DocumentCommands.ActiveImage(Nothing)
                .Run(imageA)
            End With
    
            'Extract the GREEN CHANNEL
            With Adjust.ImageCommands.ExtractChannel(Nothing)
                .Channel = 1
                .Interpretation = MediaCy.IQL.Engine.mcInterpretation.mciRGB
                .Run(imageA, imageB)
            End With
    
            'Close the imageA
            imageA.Modified = False
            imageA.Close
    
            'Call the TILE function to put the current image into the upper left hand corner
            Application.MDICommands.TileVertically(Nothing).Run()
    
            'Create the FORWARD FFT IMAGE, INVISIBLE!!!
            With Process.FFTCommands.Forward(Nothing)
                .Visible=False
                .Run(imageB, imageC)
            End With
    
            'Determine the ROI DIMENSIONS
            Dim Smooth_Image_Width As String = "272"
            Dim Smooth_Image_Height As String = "304"
    
            Dim MyLeft, MyRight, MyTop, MyBottom As Integer
    
            'use imageC instead of ThisApplication.Activeimage!!!
            MyLeft = _
                (imageC.Width / 2) - _
                (CLng(Smooth_Image_Width) / 2)
            MyRight = _
                (imageC.Width / 2) + _
                (CLng(Smooth_Image_Width) / 2)
            MyTop = _
                (imageC.Height / 2) - _
                (CLng(Smooth_Image_Height) / 2)
            MyBottom = _
                (imageC.Height / 2) + _
                (CLng(Smooth_Image_Height) / 2)
    
            'Add RECTANGULAR ROI to FORWARD FFT IMAGE using Aoi property
            imageC.Aoi.SetBox(0,MyLeft,MyTop,MyRight,MyBottom)
            'Apply LOPASS filter, Hanning, Transition= 50
            imageC.FFT.FilterTransition=50
            imageC.FFT.ApplyFFTFilter(MediaCy.IQL.Filters.mcfftFilterType.mcfftfLowPass,True,True,2)
    
            'Perform the INVERSE FFT FUNCTION and put the result into the GREEN CHANNEL IMAGE
            With Process.FFTCommands.Inverse(Nothing)
                .Run(imageC, imageB)
            End With
    
            'Close the FFT IMAGE
            imageC.Modified = False
            imageC.Close
    
            'Call the TILE function to put the current image into the upper left hand corner
            Application.MDICommands.TileVertically(Nothing).Run()
        End Sub
    

    Regards, 

    Yuri

Answers

  • 2017-11-29-092411

    Yuri --

    Thank you for your prompt response and the information it contains.

    In addition to the suggestions on handling the FFT IMAGE and DIALOG BOX, there are other nuggets of gold embedded within your version of

        button_Smooth_Click

    I will be wiring these into this PROJECT later today and adopting them in future PROJECTS.

    Thanks again

    -- Matt
Sign In or Register to comment.