Extracting details of found blobs
I hope this isn't a duplicate post, my previous post doesn't seem to have saved. If it is a duplicate, please feel free to delete this one.
Below is a function that I wrote in IPP7 that I am trying to translate into IPP9. I have managed to open the file, get the mean intensity and do a bright object find, but I cannot work out how to extract the details of found objects.
Any guidance would be appreciated, I hope the comments in the code make it clear what I am trying to do.
Below is a function that I wrote in IPP7 that I am trying to translate into IPP9. I have managed to open the file, get the mean intensity and do a bright object find, but I cannot work out how to extract the details of found objects.
Any guidance would be appreciated, I hope the comments in the code make it clear what I am trying to do.
Sub Analyse(Filename As String)
Dim imgOrig As Integer
Dim hst As Integer
Dim MeanInt As Double
Dim StripeXCent As Double
Dim StripeYCent As Double
Dim StripeWidth As Double
Dim BlobXCent As Double
Dim BlobYCent As Double
Dim Stats(10) As Single
Dim NumSites As Integer
Dim Area() As Single
Dim CentY() As Single
Dim MaxArea As Double
Dim BlobNum As Integer
Dim i As Integer
'Load image
Do
imgOrig = IpWsLoad(Filename,"tif")
Wait 1
Loop Until imgOrig<>-1
'Get histogram mean
hst = IpHstCreate
IpHstUpdate
IpHstGet(GETSTATS,0,Stats(0))
IpHstDestroy()
MeanInt=Stats(0)
'Get stripe pos
ResetBlobEngine
'Set blob from hst mean to 65535
ret = IpSegSetRange(0, MeanInt, 65535)
IpBlbSetAttr(BLOB_FILLHOLES,1)
IpBlbEnableMeas(BLBM_CENTRX, 1)
IpBlbEnableMeas(BLBM_CENTRY, 1)
IpBlbEnableMeas(BLBMEAS_WIDTH, 1)
IpBlbCount()
IpBlbUpdate(0)
IpBlbMeasure()
'Find largest blob
IpBlbGet(GETNUMOBJ, 0, 0, NumSites)
If NumSites=0 Then
'No stripe blob found
StripeXCent=0
StripeYCent=0
StripeWidth=0
Else
ReDim Area(0 To NumSites-1) As Single
'Read the areas into t()
IpBlbData(BLBM_AREA, 0, NumSites-1, Area(0))
'Find the object with the largest area
MaxArea=0
BlobNum=0
For i=LBound(Area) To UBound(Area)
If Area(i)>MaxArea Then
MaxArea=Area(i)
BlobNum=i
End If
Next
'Record X and Y centroid
ReDim Area(0) As Single
IpBlbData(BLBM_CENTRX, BlobNum, BlobNum, Area(0))
StripeXCent=Area(0)
IpBlbData(BLBM_CENTRY, BlobNum, BlobNum, Area(0))
StripeYCent=Area(0)
IpBlbData(BLBMEAS_WIDTH, BlobNum, BlobNum, Area(0))
StripeWidth=Area(0)
End If
IpBlbDelete
'Get dot pos
ResetBlobEngine
'Set blob from hst mean *2.5 to 65535
ret = IpSegSetRange(0, MeanInt * 2.5, 65535)
IpBlbSetAttr(BLOB_FILLHOLES,1)
IpBlbEnableMeas(BLBM_CENTRX, 1)
IpBlbEnableMeas(BLBM_CENTRY, 1)
IpBlbEnableMeas(BLBM_AREA, 1)
IpBlbSetFilterRange(BLBM_AREA, 500.0, 20000.0)
IpBlbFilter()
IpBlbCount()
IpBlbUpdate(0)
IpBlbMeasure()
'Find blob nearest Stripe Y Centre
IpBlbGet(GETNUMOBJ, 0, 0, NumSites)
ReDim Area(0 To NumSites-1) As Single
ReDim CentreY(0 To NumSites-1) As Single
'Read the areas into t()
IpBlbData(BLBM_AREA, 0, NumSites-1, Area(0))
IpBlbData(BLBM_CENTRY, 0, NumSites-1, CentreY(0))
'Find the object with the largest area
MaxArea=9999
BlobNum=0
For i=LBound(Area) To UBound(Area)
If Area(i)>500 And Area(i)<20000 And Abs(CentreY(i)-StripeYCent)<MaxArea Then
MaxArea=Abs(CentreY(i)-StripeYCent)
BlobNum=i
End If
Next
'Record X centre
ReDim t(0) As Single
ret = IpBlbData(BLBM_CENTRX, BlobNum, BlobNum, t(0))
BlobXCent=t(0)
ret = IpBlbData(BLBM_CENTRY, BlobNum, BlobNum, t(0))
BlobYCent=t(0)
IpBlbDelete
WritePrivateProfileString ("DotFind", "StripeXCentre", Format(StripeXCent,"0.000"), "C:\JV\Logs\Last_Dot_Find.ini")
WritePrivateProfileString ("DotFind", "StripeYCentre", Format(StripeYCent,"0.000"), "C:\JV\Logs\Last_Dot_Find.ini")
WritePrivateProfileString ("DotFind", "StripeWidth", Format(StripeWidth,"0.000"), "C:\JV\Logs\Last_Dot_Find.ini")
WritePrivateProfileString ("DotFind", "BlobXCentre", Format(BlobXCent,"0.000"), "C:\JV\Logs\Last_Dot_Find.ini")
WritePrivateProfileString ("DotFind", "BlobYCentre", Format(BlobYCent,"0.000"), "C:\JV\Logs\Last_Dot_Find.ini")
WritePrivateProfileString ("DotFind", "Filename", Filename, "C:\JV\Logs\Last_Dot_Find.ini")
WritePrivateProfileString ("DotFind", "Date", CStr(Now), "C:\JV\Logs\Last_Dot_Find.ini")
IpDocCloseEx(imgOrig)
End Sub
0
Answers
-
Hello Richard,
Sorry for the delayed answer, for some reason your posting had been filed as spam by the forum filter, I just noticed that. Have you made progress in your project? There are a number of other posts on this forum category that should help you but we can also answer specific questions that you may have.
Pierre0 -
Yes thanks, I figured it out by recording macros and hunting through the help file.0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions