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
Matthias





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"}
  .Run(docList1)
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
Radius_max=512/2
Radius_min=512/2

For Radius=Radius_max To Radius_min Step -1

  rgns=Bild_Canvas_erstellen.RegionFeatures
  rgns.AutoDisplay=True
 
  'Here comes the first ChangeType Error
  rgns.Profiles.SampleMode=MediaCy.IQL.Features.mcLineProfilesSampleModes.mclpsmFixedNumberOfSamples

  'This is also not working
  prof=rgns.Profiles
  prof.NumberOfSamplesDesired=ResProfile

  '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 
  Debug.Print(rgns.Profiles.SampleMode.ToString)


  ' The Profile can be set here to a Ellipse, this works
  rgns.SetEllipse(-1,Bild_Canvas_erstellen.Width/2,Bild_Canvas_erstellen.Height/2,Radius*2,Radius*2,90)
  
  nSamples=prof.NumberOfSamples(0)
  ReDim OneProfile(nSamples-1)
  OneProfile=rgns.Profiles.ProfileValues(0,0)

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

  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)
  Next

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

  If Radius>Radius_min Then
     RadiusRand=Radius
  End If


End Function


Answers

  • 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.

    Yuri
  • Hello Yuri,

    where can I download the 10.0.11 Version?

    Matthias
  • 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:



    Yuri
Sign In or Register to comment.