'
'
'
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Matrox.MatroxImagingLibrary
Namespace MImProcessing
Friend Class Program
Private Const IMAGE_FILE As String = MIL.M_IMAGE_PATH & "Cell.mim"
Private Const IMAGE_SMALL_PARTICLE_RADIUS As Integer = 1
Shared Sub Main(ByVal args() As String)
Dim MilApplication As MIL_ID = MIL.M_NULL
Dim MilRemoteApplication As MIL_ID = MIL.M_NULL
Dim MilSystem As MIL_ID = MIL.M_NULL
Dim MilDisplay As MIL_ID = MIL.M_NULL
Dim MilImage As MIL_ID = MIL.M_NULL
Dim MilExtremeResult As MIL_ID = 0
Dim MaxLabelNumber As MIL_INT = 0
Dim LicenseModules As MIL_INT = 0
MIL.MappAllocDefault(MIL.M_DEFAULT, MilApplication, MilSystem, MilDisplay, CType(MIL.M_NULL, IntPtr), CType(MIL.M_NULL, IntPtr))
MIL.MbufRestore(IMAGE_FILE, MilSystem, MilImage)
MIL.MdispSelect(MilDisplay, MilImage)
Console.Write(Constants.vbLf + "IMAGE PROCESSING:" + Constants.vbLf)
Console.Write("-----------------" + Constants.vbLf + Constants.vbLf)
Console.Write("This program extracts the dark particles in the image." + Constants.vbLf)
Console.Write("Press <Enter> to continue." + Constants.vbLf + Constants.vbLf)
Console.ReadKey()
MIL.MimBinarize(MilImage, MilImage, MIL.M_BIMODAL + MIL.M_LESS_OR_EQUAL, MIL.M_NULL, MIL.M_NULL)
Console.Write("These particles were extracted from the original image." + Constants.vbLf)
MIL.MsysInquire(MilSystem, MIL.M_OWNER_APPLICATION, MilRemoteApplication)
MIL.MappInquire(MilRemoteApplication, MIL.M_LICENSE_MODULES, LicenseModules)
If (LicenseModules And MIL.M_LICENSE_IM) <> 0 Then
Console.Write("Press <Enter> to continue." + Constants.vbLf + Constants.vbLf)
Console.ReadKey()
MIL.MimClose(MilImage, MilImage, IMAGE_SMALL_PARTICLE_RADIUS, MIL.M_BINARY)
MIL.MimOpen(MilImage, MilImage, IMAGE_SMALL_PARTICLE_RADIUS, MIL.M_BINARY)
MIL.MimLabel(MilImage, MilImage, MIL.M_DEFAULT)
MIL.MimAllocResult(MilSystem, 1, MIL.M_EXTREME_LIST, MilExtremeResult)
MIL.MimFindExtreme(MilImage, MilExtremeResult, MIL.M_MAX_VALUE)
MIL.MimGetResult(MilExtremeResult, MIL.M_VALUE, MaxLabelNumber)
MIL.MimFree(MilExtremeResult)
MIL.MimArith(MilImage, CInt(Fix(256 / CDbl(MaxLabelNumber))), MilImage, MIL.M_MULT_CONST)
MIL.MdispLut(MilDisplay, MIL.M_PSEUDO)
Console.Write("There were {0} large particles in the original image." + Constants.vbLf, MaxLabelNumber)
End If
Console.Write("Press <Enter> to end." + Constants.vbLf + Constants.vbLf)
Console.ReadKey()
MIL.MbufFree(MilImage)
MIL.MappFreeDefault(MilApplication, MilSystem, MilDisplay, MIL.M_NULL, MIL.M_NULL)
End Sub
End Class
End Namespace