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

LineProfile Problem with ChangeType Error (works with IPP9.2 and not with IP10)

I have to change from Image Pro Premier 9.2 to Image Pro 10 and in the used Makros the LineProfile analysis ist not working. The LineProfile is used in different ways to detect edges in Images. In the code there should be created a circle as a LineProfile with 360 FixedNumberOfSamples. The image is in the "Bild_Canvas_erstellen". 

The phenomena is now, that if I wan't to assign the "FixedNumberOfSamples" I get an Error "ChangeType not supported" if I am running the code. Also is is not possible to display the SampleMode variable with the Debug.Print command.

If I am setting a break Point in the code, everything works in the upper Debug Window. There I get the property of the SampleMode Variable and I can also set it to the FixedNumberOfSamples, what's not possible in the code.

Als also mentioned, the code runs perfect in IPP9.2.

Because I haven't programmed the code myself, I hope somebody has an idea what's the problem here...

Thank you and Greetings

Here is a part of the Code:

Imports MediaCy.Viewers.ND.Gadgets
Option Explicit
Imports MediaCy.Addins.Measurements.McMMData
Imports MediaCy.AddIns.ICalibration
Imports MediaCy.Utilities.SystemEx
Imports MediaCy.AddIns.ICalibration.Commands
Imports MediaCy.AddIns.Scripting
Imports MediaCy.AddIns.Measurements
Imports MediaCy.AddIns.ThresholdTool.Gadgets
Imports MediaCy.AddIns.ThresholdTool
Imports MediaCy.AddIns.Measurements.Gadgets
Imports MediaCy.Commands
Imports MediaCy.IQL
Imports MediaCy.IQL.Engine
Imports MediaCy.IQL.Display
Imports MediaCy.IQL.ObjectManager
Imports MediaCy.IQL.Display.Overlays
Imports System.Xml

Public Module Module1

Public Bild_Canvas_erstellen As Engine.McImage

' Just to load a Image
Public Function TestMakro_IP10_Profile() As SimpleScript
TestMakro_IP10_Profile = New SimpleScript
Dim docList1 = New List(1), doc1, image1

With Application.DocumentCommands.Open(TestMakro_IP10_Profile)
  .Filenames = New String() {"D:\1 - ! TEST IMAGE PRO 10!\20bar-3bar\V1\Bild_C10001.TIF"}
End With

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

With Adjust.ImageCommands.Canvas(TestMakro_IP10_Profile)
  .Anchor = Image.CanvasAnchor.MidCenter
  .Size = New System.Drawing.Size(612,612)
  .Background = System.Drawing.Color.FromArgb(CType(0, Byte),CType(0, Byte),CType(0, Byte))
  .AverageBackground = False
  .Visible = True
  .Run(doc1, image1)
End With

' See comes the code that works in IPP9.2, but don't works in IP10
Dim i As Integer, j As Integer, HistThreshold As Double, c As String
Dim Radius_max As Integer, Radius_min As Integer, Radius As Integer, RadiusRand As Integer
Dim ResProfile As Integer = 360 'Number of Profile Points oft the Ellipse = 360°
Dim rgns As MediaCy.IQL.Features.McRegions
Dim prof As MediaCy.IQL.Features.McLineProfiles
Dim nSamples As Integer, Profil_Min As Double, Profil_Max As Double
Dim OneProfile() As Double
Dim AnzahlGrauwerte

Bild_Canvas_erstellen = image1

AnzahlGrauwerte=CInt(System.Math.Pow(2.0, CDbl(image1.BitsPerChannel)))

'Find the maximum Radius until the black Flange is detected

For Radius=Radius_max To Radius_min Step -1

  'Here comes the first ChangeType Error

  'This is also not working

  'It is also not possible to display the content of the variable. As mentioned above a direct display
  'in the debug window with ?rgns.Profiles.SampleMode shows the content 

  ' The Profile can be set here to a Ellipse, this works
  ReDim OneProfile(nSamples-1)

  'Search Position of the minimal and maximum Brightness for the bottom HalfCircle from (90° bis 270°)

  For i=91 To 270          ' Analyze the bottom HalfCircle
     If OneProfile(i)<Profil_Min Then Profil_Min=OneProfile(i)
     If OneProfile(i)>Profil_Max Then Profil_Max=OneProfile(i)

  If ((Profil_Max-Profil_Min)/CDbl(AnzahlGrauwerte))<0.2 Then Exit For
     If rgns.Count>0 Then
     End If
  If rgns.Count>0 Then
  End If

  If Radius>Radius_min Then
  End If

End Function


  • Hi Matthias,

    We had a temporary problem with scipting module, which was fixed in IP 10.0.11, so if you have earlier version of IP 10, please update it to the latest 10.0.11 version (your macro works in my tests in IP 10.0.11).
    Let me kknow if the update fixes the problem.

  • Hello Yuri,

    where can I download the 10.0.11 Version?

  • With the default options you supposed to get the update dialog automatically at startup. If you don't see that, than you can click "Check for Updates" button in the Help button dropdown:

Sign In or Register to comment.