How to operate Image-Pro Premier with VB.Net

Hi.

Excuse me, because I can not register, temporarily I am using an account of Japan Roper.

We are using Image-Pro Plus 7.0J in business.

This time our company has upgraded to Windows 10.
Because Image-Pro Plus 7.0J is not compatible with Windows 10, we are considering to purchase Image-Pro Premier that is compatible with Windows 10.

For some reasons, In Image-Pro Plus 7.0J, after creating a macro, We do not use it.
We copy a part of the macro and describe it in VB.Net, and we are operating Image-Pro Plus 7.0J with an exe file that is created with VB.Net.

We borrowed a demo version of Image-Pro Premier from Japan Roper that is funded by US Roper Technologies, and we tried to operate Image-Pro Premier with VB.Net as Image-Pro Plus 7.0J with VB.Net.
But we could not do it.

It seems that macros are described in Image-Pro Premier in a BASIC computer language different from VB.net.
We want to copy a part of the macro written in the different BASIC computer language and write it in VB.Net and then we would like to operate Image-Pro Premier with VB.Net.

Below are the contents which we could do by Image-Pro Plus 7.0J.

1. Open selected image
2. Draw two line profiles in the image
3. The operator manipulates the position of the two lines
4. Obtain the average brightness value in the vertical direction between the two lines
5. Save the acquired average brightness value in a file

Since the width of the line profile of Image-Pro Premier is only till 99, We can not acquire the average brightness value with wide width.
However, I believe that the same thing is possible with using loop statements(For-Next).

Could you give us some advice ?
Thanks.

Best Answer

  • Accepted Answer
    Yes, just put these 2 files to the folder with Image-Pro Premier.exe and start Premier. You will see Samples ribbon tab and the new button there.

    Yuri

«1

Answers

  • 2017-12-19-103844

    Morita --

    I am unable to determine all of the FEATURES and FUNCTIONS that are included in your MACRO for IMAGE-PRO PLUS.

    I have written a FUNCTION which paints 20 SAMPLE LINES (99 pixels wide) through a 2000 x 1600 pixel image to capture most of the VERTICAL INTENSITY PROFILE information.

    That macro is below.

    The IMAGE that the FUNCTION was tested on is below the FUNCTION.

    A SCREEN CAPTURE that shows the results in PREMIER and EXCEL is shown below the EXAMPLE IMAGE.

    If you and your organization need assistance with transferring the functionality of your PLUS MACRO to PREMIER, ALCES contracts our services.

    I hope this information is helpful.

    -- Matt

    Matthew M. Batchelor
    President and Applications Engineer
    Alces Imaging and Automation, LLC

    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

        Public Function NewMacro2() As SimpleScript
            NewMacro2 = New SimpleScript
            Dim doc1
    
            With Application.DocumentCommands.Active(NewMacro2)
                .Run(doc1)
            End With
    
            With Measure.LineProfile.ProfileCommands.RemoveAll(NewMacro2)
                .Run(doc1)
            End With
    
            Dim My_I As Integer
            For My_I = 0 To 19
    
                    With Measure.LineProfile.ProfileCommands.Add(NewMacro2)
                        .ProfileType = LineProfile.ProfileTypes.Line
                        .Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
                        .Points.Add(New System.Drawing.PointF( ( My_I * 100 ) + 45.5F,0F))
                        .Points.Add(New System.Drawing.PointF( ( My_I * 100 ) + 45.5F,1600F))
                        .Angle = 0R
                        .CreateEngine = True
                        .Run(doc1)
                    End With
    
                Next
        End Function
    




  • Hello Morita,

    Yes, in Image-Pro Premier you can use VB.NET to create your dialogs and macro code.

    Line Profile width currently has  limit of 99 (which will be lifted in the next version). The easiest way to get wider profile in X direction now would be to apply a Large Low Pass filter with width larger then 99 and height of 1, it will effectively average all pixels in horizontal direction, then you just use line profile of Width=1 to get average values along vertical direction.

    Here is a sample macro that applies 4001x1 low-pass filter:
        Public Function WideLowPass() As SimpleScript
            WideLowPass = New SimpleScript
            Dim image1
    
            With Application.DocumentCommands.ActiveImage(WideLowPass)
                .Run(image1)
            End With
    
            With Process.Filter.LargeCommands.LowPassLarge(WideLowPass)
                .Passes = 1
                .Width = 4001
                .Height = 1
                .Run(image1, image1)
            End With
    
        End Function

    The line profile:



    Yuri


     
  • Hello, Matt and Yuri.

    Thank you for your advices.
    I tried both ways on Image-Pro Premier and thought they were possible.

    I appreciate for your explaining of Macro. But most important part of my question is how to operate Image-Pro Premier with VB.net.

    There was a sample code of VB.Net for Premier in the following folder.(Below one)

    C:\Program Files\Media Cybernetics\Image-Pro Premier 9.3\Automation\Samples\VB.NET\MediaCy.Automation.Samples.VBClient

    I tried to do it, but I could not do it because of that the error happened.

    I read the error content and past questions of this forum, and I found that a specific directory is required to contain VB.Net sample files.
    However, I can not find which files should be put in where.
    Please tell me in detail.

    Thanks.

    Uemoto
    (Temporarily I am using  Mr. Morita's account of Japan Roper for that I ask this question.)

  • Hello Uemoto,

    It looks like your project cannot find reference assemblies. You may have the problem described in this topic: http://forums.mediacy.com/discussion/comment/2666#Comment_2666 
    Please check this link and see if you've mapped Premier folder to X:\ drive.  (All samples are configured to get assemblies from the X-drive and generate outputs to X:.)

    Regards,

    Yuri
  • Hello Yuri,

    Thank you for your advice.
    And please allow me to ask you one more question.

    I misunderstood how to mount the drive.
    I read the topic of 2666♯Comment_2666 before that question.
    So I thought that I could mount the drive by using a command "subst".

    However, I found that I could change the output destination by using a compile of property not using a command "subst".
    And so then, I could run the sample code without the error messages.

    However, an exception error happened when I push the "Attach" button.
    (Please check the image at the bottom)

    ----------------------------------------------------------
    Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
            Try
                _session = New Session("Image-Pro Premier 9.2 64-bit", 60)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    End Sub
    ----------------------------------------------------------

    I can't find where part I should fix.
    What does the ex.Message mean?

    Please tell me the method how to resolve this exception error.

    Thanks.

    Uemoto

  • Hello Uemoto,

    Yes you are right you don't need that X: drive but it does make things a little easier.

    To summarize:
    - you need all the dlls referenced in your project to be found at compile time.
    - you also need all the required dlls to be found at run-time (there may be be more than what is required to compile).

    It's not clear from where you are running your program (the output of the project)  but it sounds like it can't find something needed by one of the MediaCy dlls.

    This is why we use the X: drive as both the source of the references and the target folder of the project, so that everything is available. If you use an X: drive, you will probably need to adjust permissions to write files to the Image-Pro Premier folder. If you don't want to use this approach you can copy all the dlls from the Image-Pro Premier folder to your output folder instead and alter figure out which ones are really needed for your application.

    Pierre
  • Hello Pierre,

    Thank you for your advice.

    >>It's not clear from where you are running your program (the output of the project)

    The output of the project is "C:\Program Files\Media Cybernetics\Image-Pro Premier 9.3\Automation\Samples\VB.NET\MediaCy.Automation.Samples.VBClient".
    And the sample vbproj is the same folder.

    Then, I copied all the dlls from the Image-Pro Premier folder(C:\Program Files\Media Cybernetics\Image-Pro Premier 9.3) to the above folder.
    But the same error happened.

    I wonder if ""_session = New Session("Image-Pro Premier 9.2 64-bit", 60)"" is the cause.
    I am using Image-Pro Premier "9.3" 64-bit now.
    Although I fixed it to ""_session = New Session("Image-Pro Premier 9.3 64-bit", 60)"", the same error happened.

    What does ""("Image-Pro Premier 9.3 64-bit", 60)"" mean?
    If it means the folder(C:\Program Files\Media Cybernetics\Image-Pro Premier 9.3), Should I fix it to ""_session = New Session("C:\Program Files\Media Cybernetics\Image-Pro Premier 9.3", 60)""?

    Please tell me the method how to resolve this exception error.

    Thanks.

    Uemoto

  • edited December 2017
    Hello Uemoto,

    The easiest way is to set output to Premier folder (C:\Program Files\Media Cybernetics\Image-Pro Premier 9.3), you should also run the program from that folder. (that's how it's configured by default).

    The parameter in the Session constructor is the product name, it should match the registry key in 
    HKEY_LOCAL_MACHINE\SOFTWARE\Media Cybernetics\IQ Family\ tree. In your case you should use "Image-Pro Premier 9.3 64-bit".

    Yuri

  • Hello Yuri,

    Thank you for your advice.

    Then, I followed your advice.
    And I could run the sample code of "Attach".

    But I could not run the sample code of "Run" because of the same error.
    However, it is not big problem since what I want to run is not the sample code of "Run" but the Line profile code which we could do by Image-Pro Plus 7.0J.

    So I have written a code of the two line profile for VB.net.(Please check the code at the bottom)
    But I got only one line profile.

    I don't know where part I should fix.

    Please tell me the cause.

    Thanks.

    Uemoto


    ----------------------------------------------------------
    Imports MediaCy.Automation.Proxy
    Imports MediaCy.IQL.Application
    Imports MediaCy.Commands
    Imports MediaCy.Commands.LineProfile

    Public Class Form1

        Private _session As Session

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            Try
                _session = New Session("Image-Pro Premier 9.3 64-bit", 60)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

            Try
                Dim docList1 = Nothing, doc1 = Nothing
                Dim LineProfile = Nothing

                With Application.DocumentCommands.Open(_session)
                    .Filenames = New String() {"C:\Users\逆スタート_No1_5.tif"}
                    .Run(docList1)
                End With

                With Application.DocumentCommands.Activate(_session)
                    .Run(docList1(0), doc1)
                End With

                With Measure.LineProfileCommands.LineProfile(_session)
                    .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
                    .Run()
                End With

                With Application.RibbonCommands.SelectRibbonTab(_session)
                    .TabName = "LineProfile"
                    .Run()
                End With

                With Application.DocumentCommands.Active(_session)
                    .Text = "アクティブな書類"
                    .Run(doc1)
                End With

                With Measure.LineProfile.ProfileCommands.Adjust(_session)
                    .Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
                    .Points.Add(New System.Drawing.PointF(3146.219F, 665.5462F))
                    .Points.Add(New System.Drawing.PointF(3146.219F, 5808.403F))
                    .Angle = 0.0R
                    .Index = 0
                    .Run(doc1)
                End With

                With Measure.LineProfile.ProfileCommands.Add(_session)
                    .ProfileType = LineProfile.ProfileTypes.Line
                    .Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
                    .Points.Add(New System.Drawing.PointF(4029.58F, 665.5462F))
                    .Points.Add(New System.Drawing.PointF(4029.58F, 5808.403F))
                    .Angle = 0.0R
                    .CreateEngine = True
                    .Run(doc1)
                End With

            Catch ex As Exception
                'MsgBox(ex.Message)
            End Try

    End Sub
    End Class

    ----------------------------------------------------------

  • Hello Uemoto,

    It looks like your macro contains only one Measure.LineProfile.ProfileCommands.Add command, so only one profile is added.
    Below is a macro that adds 2 profiles:
        Public Function Add2Profiles() As SimpleScript
            Add2Profiles = New SimpleScript
            Dim doc1
    
            With Measure.LineProfileCommands.LineProfile(Add2Profiles)
                .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
                .Run()
            End With
    
            With Application.DocumentCommands.Active(Add2Profiles)
                .Run(doc1)
            End With
    
            With Measure.LineProfile.ProfileCommands.RemoveAll(Add2Profiles)
                .Run(doc1)
            End With
    
            With Measure.LineProfile.ProfileCommands.Add(Add2Profiles)
                .ProfileType = LineProfile.ProfileTypes.Line
                .Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
                .Points.Add(New System.Drawing.PointF(56.75676F,42.16216F))
                .Points.Add(New System.Drawing.PointF(300F,42.16216F))
                .Angle = 0R
                .CreateEngine = True
                .Run(doc1)
            End With
    
            With Measure.LineProfile.ProfileCommands.Add(Add2Profiles)
                .ProfileType = LineProfile.ProfileTypes.Line
                .Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
                .Points.Add(New System.Drawing.PointF(56.75676F,103.7838F))
                .Points.Add(New System.Drawing.PointF(295.1351F,103.7838F))
                .Angle = 0R
                .CreateEngine = True
                .Run(doc1)
            End With
    
        End Function

    Yuri
  • edited December 2017

    Hello Yuri,

    Thank you for your advice.

    Sorry, I mistook the sentence to paste.

    Then, I followed your advice.
    But two errors occurred.
    The error contents are below.

    1. An initial exception of 'System.ArgumentNullException' occurred in MediaCy.Automation.Proxy.dll.
    2. An initial exception of 'System.NullReferenceException' occurred in MediaCy.IQL.Application.dll.

    I think the cause of these errors is that the value of "ex.Message" can not get null.

    I tried your Macro and my Macro on Premier. And they worked correctly.
    But when I tried your Macro and my Macro on VB.net, they didn't work well.

    If I paste Premier Macro to VB.net, I get an error message which means "Type 'SimpleScript' is not defined".
    Then, I fixed 'SimpleScript' to work on VB.net. But I got above two errors.

    Please tell me the solution.

    Thanks.

    Uemoto

  • Hello Uemoto,

    When you use "Automation server" example, the macros recorded in IP Premier have to be adjusted to be compatible with the server code, for example "_session" should be used instead of SimpleScript name as in Button1_Click code above. (SimpleSctript type is not supported in automation server)

    You can use SimpleScript and any recorded macros in the IPPremier macro projects and apps. You can also use all the commands in "Addins", which are the best way to extend IP Premier functionality using VB.NET. The new Addins will have Ribbon bar buttons and panels as the native IP Premier modules.

    Let me know if Addins can be used for your tasks, and if yes, I can send you same sample code that can be used as programming examples.

    Regards,

    Yuri

  • Uemoto,

    As an example of VB.NET addin for Image-Pro Premier, I've attached a sample VB.NET project that shows how IPPremier can be extended using VB.NET.
    To test this project you have to:

    1. Map Image-Pro Premier folder to X:\ drive (explanation above).
    2. Unzip the attached project and load it to Visual Studio 2015. 
    3. Run the project in Debug mode. It will start Image-Pro Premier and add a new Ribbon tab "Samples" to the main ribbon. The Samples tab will contain the Sample tool button, clicking which will open the project panel with 2 buttons "Test Sobel" and "Draw 2 profiles":. Clicking the buttons will execute macros recorded in Premier. There are minor adjustments to the macros to resolve namespace conflicts, such as adding "Automation." in front of Application.... commands.



    The addin panel should look like this:



    Please check the project to see how the macro commands can be used in VB.NET addins.


    Yuri
  • Hello Yuri,

    Thank you for your advice and addin project.

    >>Let me know if Addins can be used for your tasks, and if yes, I can send you same sample code that can be used as programming examples.

    I have never used the addin function in VB.net. But I think I can probably do it.

    >>As an example of VB.NET addin for Image-Pro Premier, I've attached a sample VB.NET project that shows how IPPremier can be extended using VB.NET.
    >>To test this project you have to:
    >>2. Unzip the attached project and load it to Visual Studio 2015.

    We have Visual Studio not 2015 but 2010.
    So, I installed Visual Studio Community 2017 in my computer and tried to run the project in Debug mode.(I couldn't find a website to install Visual Studio 2015.)
    Then the following message appeared and IP Premier didn't start up.

    "Your application is in a break state, but all threads are running external code (usually system code or framework code), so there is no code to be displayed."

    Is this a error?
    I don't know what I should do.

    Please tell me the solution.

    Thanks.

    Uemoto

  • Hello Uemoto,

    I don't understand all error messages, but it looks like you are trying to run this DLL in  UserControlTestContainer, not in IP Premier.
    Please be sure that you mapped X:\ drive to IP Premier folder and Image-Pro Premier.exe is the start program, as on the screenshot below:



    Yuri
  • Hello Yuri,

    I wish you a Happy New Year.
    Thank you for all of your help last year.

    I mapped X:\ drive to IP Premier folder and Image-Pro Premier.exe.
    And I tried to run the project in Debug mode.

    Then, IP Premier did start up.
    But a new Ribbon tab "Samples" was not added.

    There seems to be the following error.
    DefaultSource Error: 2 : Object variable or With block variable not set.
    I couldn't find other error message.

    Please tell me how to add a new Ribbon tab "Samples" .

    Thanks.

    Uemoto

  • Hello Yuri,

    I'm sorry.
    I misunderstood that I got a new Ribbon tab called "サンプル" which meant "Samples" in English.
    Actually I got a new Ribbon tab called "点数" which meant "Score" in English.

    A new Ribbon tab "Samples" was added!
    Thank you so much!

    Below is a screenshot.
    I don't know the reason why there are three lines.
    Please tell me the reason.

    I will try various things.
    I will ask you again if I have something I don't know.

    Thanks.

    Uemoto

  • Hello Yuri,

    As for the previous question, I thought I got three lines.
    But I saw wrong. I got only two lines.
    I'm sorry for upsetting you.

    And please allow me to ask you two more questions.

    I made a Macro.
    The Macro contents are below.

    1.Put a rectangle(ROI) on the image
    2.Cut out the ROI area of ​​the image
    3.Apply a Low Pass filter to the ROI area of ​​the image
    4.Use line profile to get average values along vertical direction

    As for the first question, two lines will appear for some reason.(Please check the screenshot at the bottom)
    I want to get only one line.
    How can I solve it?

    As for the second question,
    I will divide the macro into two macros in order to modify the ROI area.
    After the operation of 1, I want to modify the ROI area and save the coordinate values of the modified ROI area ​​in other variables.
    Then, I want to operate from 2 to 4.
    Please tell me how to pass the coordinate values of the modified ROI area to other variables.

    Thanks.

    Uemoto

  • Because of the number of characters, I divided my comment into two.

    #Region "Recorded macros"
    Public Function test10() As SimpleScript
            test10 = New SimpleScript
            Dim image1, doc1, image2, doc2, image3, doc3

            With Automation.Application.RibbonCommands.SelectRibbonTab(test10)
                .TabName = "Select"
                .Run()
            End With

            With Automation.Application.DocumentCommands.ActiveImage(test10)
                .Text = "アクティブな画像"
                .Run(image1)
            End With

            With Automation.[Select].RoiCommands.Add(test10)
                '.ROIType = Features.ROI.ROITypes.Rectangle
                .ROIType = ROI.ROITypes.Rectangle
                .Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
                .Points.Add(New System.Drawing.PointF(2602.0F, 691.0F))
                .Points.Add(New System.Drawing.PointF(4477.0F, 5661.0F))
                .Angle = 0.0R
                .Run(image1)
            End With

            With Automation.Application.DocumentCommands.Define(test10)
                .Run(image1, doc1)
            End With

            With Automation.Adjust.ImageCommands.Crop(test10)
                .Visible = True
                .Run(doc1, image2)
            End With

            With Automation.Application.DocumentCommands.Activate(test10)
                .Run(image2, doc2)
            End With

            With Automation.Application.RibbonCommands.SelectRibbonTab(test10)
                .TabName = "Adjust"
                .Run()
            End With

            With Automation.Adjust.ImageCommands.Rotate(test10)
                .Orient = Image.OrientType.Rotate180
                .Visible = True
                .Run(doc2, image3)
            End With

            With Automation.Application.DocumentCommands.Activate(test10)
                .Run(image3, doc3)
            End With

            With Automation.Application.RibbonCommands.SelectRibbonTab(test10)
                .TabName = "Process"
                .Run()
            End With

            With Process.Filter.EnhancementCommands.Gauss(test10)
                .Passes = 1
                .KernelSize = Filters.mcKernelSize2.mcks5x5
                .Strength = 10
                .Run(doc3, image3)
            End With

            With Process.Filter.LargeCommands.LowPassLarge(test10)
                .Passes = 1
                .Width = 9999
                .Height = 1
                .Run(image3, image3)
            End With

            With Automation.Application.RibbonCommands.SelectRibbonTab(test10)
                .TabName = "Measure"
                .Run()
            End With

            With Measure.LineProfileCommands.LineProfile(test10)
                .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
                .Run()
            End With

            With Automation.Application.RibbonCommands.SelectRibbonTab(test10)
                .TabName = "LineProfile"
                .Run()
            End With

            With Measure.LineProfile.ProfileCommands.Add(test10)
                .ProfileType = LineProfile.ProfileTypes.Line
                .Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
                .Points.Add(New System.Drawing.PointF(187.6F, 2485.5F))
                .Points.Add(New System.Drawing.PointF(1688.4F, 2485.5F))
                .Angle = 0.0R
                .CreateEngine = True
                .Run(doc3)
            End With

            With Measure.LineProfile.ProfileCommands.Adjust(test10)
                .Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
                .Points.Add(New System.Drawing.PointF(889.5474F, 0.0F))
                .Points.Add(New System.Drawing.PointF(889.5474F, 4939.604F))
                .Angle = 0.0R
                .Index = 0
                .Run(doc3)
            End With

    End Function
    #End Region

  • Hello Uemoto,

    I'm glad that you've made the addin code work! So, now you are in VB.NET environment and can use all development and debugging tools available in Visual Studio.

    If you don't understand how you ended up with some result, the best way to find it out is to debug the program step by step. You can set break points in you macro and check the changes when you execute commands one by one. There you can  find the reason of 2 line profiles on your image. I suspect that the first profile is added by default when you activate line profile tool, so you ether can use that existing profile and modify coordinates (instead of adding your line) or remove all profiles before adding your line. You can check my macro Add2Profiles as example.

    Since you are in VB.NET environment you can create your own variables, arrays, classes (global or local) to keep your data. You can also pass variables as function parameters or return them from functions, the same way you would do it in normal VB.NET.

    Regards,

    Yuri



  • Hello Yuri,

    Thank you for your advice.

    >>You can set break points in your macro and check the changes when you execute commands one by one.

    I wanted to execute commands one by one.
    But I couldn't do them since the form of VB.net was not reflected in the form of IP Premier.

    I made three buttons on the form of VB.net and debugged the program.
    Then, IP Premier started up.
    But the form of IP Premier had only two buttons!

    After I finished debugging, I started up IP Premier again.
    Then, the form of IP Premier had three buttons!
    For the reason, I couldn't execute commands one by one.

    I don't know how to solve it.


    Then, as for my previous first question, I solved it with commands of "RemoveAll" and "Add".

    And as for my previous second question, I want to know about functions which can get the coordinate values of the ROI area.

    For example, when I got the coordinate values of the LineProfile in IP Plus 7.0J, I used "ret = IpProfGet(GETPOINTS, 0, LineProf_Points(0))".
    And I saved the coordinate values of the LineProfile in other variables.

    -------------------------------------------------
    Dim LineProf_Points(1) As POINTAPI
    ret = IpProfGet(GETPOINTS, 0, LineProf_Points(0))

    TextBox2.Text = LineProf_Points(0).x.ToString()
    TextBox3.Text = LineProf_Points(0).y.ToString()
    TextBox4.Text = LineProf_Points(1).x.ToString()
    TextBox5.Text = LineProf_Points(1).y.ToString()
    -------------------------------------------------

    "IpProfGet" is a function that obtains the coordinate values of the LineProfile in IP Plus 7.0J.
    Is there such a function which can get the coordinate values of the ROI area in IP Premier?
    If yes, please tell me the function.

    Thanks.

    Uemoto

  • Hello Uemoto,

    If you have different app dialogs running Premier from Debugger and from windows Explorer directly, it means that you either run different versions of Premier or you generate different versions of your addin DLL. If you have multiple Premier installations, be sure that you map the latest one to X:\ drive. Also, check that the DLL (IpPremierAddin1.dll) is in that folder and has the current date.
    When you fix all these problems you should be able to debug and run your addin step by step in VB.NET.

    Regarding variables for line coordinates. As I see in your macro the coordinates are defined already as numbers, like this:

            With Measure.LineProfile.ProfileCommands.Add(Draw2LineProfiles)
                .ProfileType = LineProfile.ProfileTypes.Line
                .Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
                .Points.Add(New System.Drawing.PointF(39.45424F, 248.0649F))
                .Points.Add(New System.Drawing.PointF(337.1664F, 247.3577F))
                .Angle = 0R
                .CreateEngine = True
                .Run(doc1)
            End With


    You can simply put them into variables and use Variables as command parameters:

            Dim p1 As New System.Drawing.PointF(39.45424F, 248.0649F)
            Dim p2 As New System.Drawing.PointF(337.1664F, 247.3577F)

            With Measure.LineProfile.ProfileCommands.Add(Draw2LineProfiles)
                .ProfileType = LineProfile.ProfileTypes.Line
                .Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
                .Points.Add(p1)
                .Points.Add(p2)
                .Angle = 0R
                .CreateEngine = True
                .Run(doc1)
            End With

    Or you want user to adjust line profile, and then read line profile coordinates?

    Yuri

  • Hello Yuri,

    Thank you for your advice.

    >>Or you want user to adjust line profile, and then read line profile coordinates?

    Yes.
    The initial position of the ROI area which I decided is only a reference position.

    Because the print image and size of each sample which we have are different, users need to adjust the position of the ROI area.
    So, I want to get the new position of the ROI area which users modified, and I want to save it ​​in other variables.
    Then users can use the macro with the values as the new initial position.

    Please tell me a function that can get the new position of the ROI area which users modified in IP Premier.

    Thanks.

    Uemoto

  • edited January 10
    Uemoto,

    Image ROI is exposed as ThisApplication.ActiveImage.Aoi object of class McRegions. You may look at the automation help to check all the available properties and functions.
    Here is a macro that  reads bounding rectangle of active image ROI:

        Public Sub ReadROI
            Dim r As Mediacy.IQL.ObjectManager.SINGLERECT=ThisApplication.ActiveImage.Aoi.BoundingRect
            Debug.Print (String.Format("ROI box = {0},{1},{2},{3}",r.left,r.top,r.right,r.bottom))
        End Sub
    
    You may also search this forum by "ActiveImage.Aoi" to find more examples of using this property.

    Yuri
     
  • Hello Yuri,

    Thank you for the function.

    I could get the position of the ROI area which I modified.
    Thank you so much!

    And please allow me to ask you two more questions.

    As for the first question,
    In IP Plus 7.0J, we can set the size of Gaussian blur to any size (for example, "size 15").
    But in IP Premier, we can set it to only the specified size (for example, "Kernel size 5×5").
     
    Beacause I set the size of Gaussian blur to "size 15" in IP Plus 7.0J, I want to set it to "size 15" also in IP Premier.
    How can I do it in IP Premier?

    As for the second question,
    In IPPremierAddin1, "SamplePanel.vb" seems to be not a form but an user control.
    I made a button and tried to switch "SamplePanel.vb" to another user control panel in IP Premier.
    But I couldn't do it.

    Is it possible for me to switch this panel to another user control panel in IP Premier like a form of exe file?
    If yes, please tell me how to do it.

    Thanks.

    Uemoto

  • edited January 12
    Hello Uemoto,

    IP Premier has equivalent 3D filter, that also works on 2D images, Gaussian 3D filter doesn't have size limits. You can also run it directly using IQL function (it requires reference to MediaCy.IQL.Filters.Volume.dll):

        Public Sub Gaussian3D
            ThisApplication.ActiveImage.Filter3D.Gaussian3D(15,15,1,1)
        End Sub
    Regarding opening a new form. You should use ShowDialog to show your form, here is the example (button click handler):

        Private Sub ButtonOpenForm1_Click(sender As Object, e As EventArgs) Handles ButtonOpenForm1.Click        Dim myForm As New Windows.Forms.Form 'use your own form class
    
            If myForm.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then
    
                '''
    
            End If
    
        End Sub
    
    

    Let me know if that's what you want.

    Regards,

    Yuri
  • Hello Yuri,

    Thank you for your advice.

    As for Gaussian blur,
    in IP Plus 7.0J, I can set the size and the strength of Gaussian blur to "size 15" and "strength 10".
    But in IP Premier, although I can set the size of Gaussian 3D filter to "size 15", I can't set the strength of it to "strength 10".

    I tried to apply Gaussian filter to my image in both Plus 7.0J and Premier.
    Though these results look the same, are they really the same? (The strength is not set in IP Premier.)
    Or is the strength irrelevant to Gaussian filter?
    Can I set the strength of Gaussian 3D filter to "strength 10" in IP Premier?


    As for a new form,
    I could do what I want to do.
    Thank you so much!

    Before asking questions on this forum, I tried to operate IP Premier with only VB form without using sample tool.
    But it seems difficult to operate IP Premier without using sample tool.
    However, I found it possible to operate IP Premier with VB form after using the sample tool.


    And please allow me to ask you one more question.

    Can I distribute my sample tool to other computers like exe files of VB?
    Is it necessary to install Visual Basic on each computer and debug "IPPremierAddIn1"?

    Please tell me how to distribute my sample tool to other computers.


    Thanks.

    Uemoto

  • Hello Uemoto,

    Gaussian 3D filter is equivalent to "strength 10" in IP Plus.

    Regarding the distribution: you will only need to distribute the DLL and Addin file, no VB installation is necessary, as it's a part of the system.

    Yuri
  • Hello Yuri,

    Thank you for the reply.

    >>Regarding the distribution: you will only need to distribute the DLL and Addin file, no VB installation is necessary, as it's a part of the system.

    Is the names of the DLL and Addin file "IPPremierAddIn1.dll" and "IPPremierAddIn1.Addin"?

    How do I use these two files to display my sample tool on IP Premier?
    Should I just put those files in the same folder containing IP Premier.exe?

    Please tell me how to do it in detail.


    Thanks.

    Uemoto

Sign In or Register to comment.