Suresh,
Thanks for posting the image, it really helps me understand what you are trying to accomplish.
You said you need to count the number of ridges on your pulley. I really think doing a simples edges detection will achieve what you need. The method "CWIMAQVision.FindEdges2" will do this for you. Below is example code from the NI Vision for Visual Basic Reference Help.
-----------------
' Find the first and last edge coordinates along a path defined by regions
' on Viewer1 and display the coordinates on the image.
Private Sub Run_Click()
Dim ProfileReport As New CWIMAQProfileReport
Dim EdgeOptions As New CWIMAQEdgeOptions
Dim EdgeCoordinates As New CWIMAQPoints
Dim EdgeReport As New CWIMAQEdgeReport
Dim J As Integer
' Find the coordinates of the points along the path
' defined by the regions on Viewer1
CWIMAQVision1.RegionsProfile CWIMAQViewer1.Image, CWIMAQViewer1.Regions, ProfileReport
' Find the first and last edges along the selected path
CWIMAQVision1.FindEdges2 CWIMAQViewer1.Image, ProfileReport(1).Coordinates, EdgeOptions, _
EdgeCoordinates, cwimaqEdgeProcessFirstAndLast, EdgeReport
' Display the results
For J = 1 To EdgeCoordinates.Count
CWMachineVision1.DrawCircularPoint CWIMAQViewer1.Image.Overlays(1), EdgeCoordinates(J), _
8, cwimaqOverlayModePaint, vbRed
Next
End Sub
-----------------
The catch is that your pulley might be in different locations for each image. If this is the case you will need to first detect the pulley and then use the position and orientation of the pulley to setup a coordinate system so that you do the edge detection along the correct line, no matter where your pulley appears in the image. Doing this in Visual Basic is not so straight forward and will require that you combine a few example programs together.
On the other hand, you could purchase Vision Builder for Automated Inspection. You would be able to setup an inspection which does exactly what I am talking about above within 1 week. I kid you not. And if you have to get the inspeciton of the pulley to integrate with some Visual Basic code, you in luck. Vision Builder for Automated Inspection ships with an ActiveX library which will allow you to communicate with Vision Builder for Automated Inspection from Visual Basic. Honestly, spending a few extra dollars to save you many hours of work and frustration will be worth it. Also, you do not need LabVIEW to run Vision Builder for Automated Inspection.
Follow the link below to learn more about Vision Builder for Automated Inspection...
I hope I answered your question,
Lorne Hengst
Applicaiton Engineer
National Instruments